1. Hi, I want to thank the author of this book who led me to learn a scripting language.

    I have a question about the scripts applied to a Frame Object, I tried to handle an "OnEnter" script on the Default ChatFrame for example by outputing a simple message with "print()" like this: getglobal("ChatFrame1"):SetScript("OnEnter", function () print("Hello World!") end)

    it's doesn't work even for an simple Frame created with CreateFrame() but when i create it by using XML and setting the scripts tag 'OnEnter' it worked nicely. So what's the probleme with Lua here ?.

  2. Are you getting any Lua errors? Also, how are you trying to run your code (.lua, /run, other)?

    Also, is getglobal() defined by the WoW environment? I'm not aware of such a function in baseline Lua.

  3. I've got no errors, i'm runnig with a .lua file and i've also tried with the global table _G[] But no results

  4. Could you paste your .lua and .toc, as well as providing both file names? I believe that you're running into an issue with the file not being loaded here.

    Also, I honestly wouldn't :SetScript on a frame you didn't create yourself unless your intention is to override default behavior. Consider using :HookScript with the same arguments instead.

  5. Consider using :HookScript with the same arguments instead.

    I've also tried with this anyway ! here is my simple files:

    -toc

          ## interface: 50300
          ## title: Test
          ## notes: Test
          ## defaultstate: disabled
    
          Test.lua
    

    -lua

    _G["ChatFrame1"]:HookScript("OnEnter", function () print("Hello world!") end)

    • Did you enable the addon? You have DefaultState: disabled set.
    • How is your addon's folder named? How are the .toc and the .lua named?
  6. My addon folder structur are fine, and obviously i checked it before starting to play.

  7. So if you add something like print("Test message!") to the .lua file, it will be printed?

  8. Yes any other code works

  9. It's possible that frames need to have mouse enabled for OnEnter/OnLeave to fire. That might be it.

  10. Yeah You're right a frame need to be mouse enabled to respond mouse events, so far i found the XML atribute enableMouse must be set to true to handle scripts.

    thx for your help !

  11. You can simply call :EnableMouse(true) too.