Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ Delcaring functions.
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Shigs
(27 posts) Bio
|
Date
| Mon 11 Aug 2008 12:04 PM (UTC) |
Message
| Where should function declerations be placed, when making a plugin inorder to make them accessible, by all triggers/aliases/ etc.
In the script space? When is this script initiated, on installation? on running of the client?
Thanks
Shigs. | Top |
|
Posted by
| Larkin
(278 posts) Bio
|
Date
| Reply #1 on Mon 11 Aug 2008 06:15 PM (UTC) |
Message
| Put your Lua script in the plugin's script space, yes. It will be accessible to all triggers, aliases, etc in that plugin. If you want scripts to be accessible to multiple plugins or worlds, put them in modules (similar to the included little sample/utility scripts) and use the "require" keyword to load them into your script space.
The script will execute when the plugin is loaded, so when you open the world. | Top |
|
Posted by
| Nick Gammon
Australia (23,159 posts) Bio
Forum Administrator |
Date
| Reply #2 on Mon 11 Aug 2008 10:07 PM (UTC) |
Message
| As part of the plugin installation (loading) the script is processed and thus any global declarations are processed. Then it calls OnPluginInstall, if present. However for that to work the function OnPluginInstall must already exist, so therefore executing all global declarations is the very first thing that happens.
See for yourself by putting a line like this at the bottom of the script part in a plugin:
Note ("Script reloading: ", os.date ("%c"))
When you see that, the plugin is loading its script. Note that you may not see that at world startup because plugins load before the main output window is initialized, and thus the message may disappear. You could try appending it to a notepad instead, which will always work. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,694 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top