The orginal code should work fine. This is not accurate:
Originally Posted by Galaxy119
Print needs to be run as part of a defined function.
|
print can be run anywhere, at any time. In fact,
no function can only be called from inside another function; that's just not how Lua works, and wouldn't really make much sense -- if functions could only be called from inside other functions, how would you call those outer functions to make anything happen in the first place?
However, if you're using an addon that makes the chat frame keep more messages in its scroll-back history, then anything
printed before that addon loads will be erased. You can (usually, depending on the addon) work around this by waiting until the PLAYER_LOGIN event to
print your message.
Other than that, we need more context in order to figure out your problem. If you're using
print in an addon, show the rest of the code.
If you're typing
/run print("Hello world") the chat box and it's not working, either some other addon is interfering and/or there is something horribly wrong with your WoW installation; try deleting your Cache folder.
Some other general tips for addon development, or even troubleshooting in general:
- Make sure you have an error display running. I'm biased toward
Bugger since I wrote it, but BugSack or Swatter will work too.
- When trying to diagnose problems, disable any other addons you're normally running. This will quickly rule out (or confirm) that the problem is caused by interference with another addon. You can use an addon like ACP to save sets of enabled addons, so you don't have to manually go back through and check all the ones you want to re-enable. I have several sets like this -- one "minimal" that only enables the addon manager and error display for use when debugging problems, "light" that only enables the bare minimum addons for solo play during addon development, and "standard" that enables all the addons I want during normal play.