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 ?.

    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.

    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

    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.

    Consider using :HookScript with the same arguments instead.

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


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


    _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?

    My addon folder structur are fine, and obviously i checked it before starting to play.

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

    Yes any other code works

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

    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 !

    You can simply call :EnableMouse(true) too.