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
➜ General
➜ Script / plugins organizing
|
Script / plugins organizing
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Rdiniz
Brazil (21 posts) Bio
|
| Date
| Thu 21 Feb 2019 02:56 PM (UTC) |
| Message
| Hello everyone,
in the mud I play, we're allowed to mplay, so I'm looking for a way to centralize the scripts, triggers, alias, etc, so I could change them at one place only and not n-plicating the world files as I do today.
My current setup, which works perfectly if I replicate the world files, are like this:
- /Mushclient/lua/mainmud.lua (big file containing most of the logics, variables, scripts I need)
- /Mushclient/worlds/mud.lua (small .lua file just requiring tprint, movewindow and mainmud
- /Mushclient/worlds/world01.MCL (bigish file containing most of the alias I use, triggers, timers, etc. This is the file I replicate for each alt)
- /Mushclient/worlds/plugins/mud1.xml, mud2.xml, mud3.xml (Isolated and working plugins I have that sometimes calls mainmud.lua functions using /funcName()
I tried to use plugin wizard to export aliases and triggers from world01.MCL, removing them from .mxl file so that I could make the changes I need only on the generated plugin. While I was able to create the plugin file, a LOT of funcions are messed up now, I think variables arent shared or something like that.
What could I do to make it work well?
Thanks in advance | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Thu 21 Feb 2019 11:51 PM (UTC) |
| Message
| Each plugin has its own script space, so that Lua variables are not shared between plugins and the main world file.
This shouldn’t be an issue if you do everything in plugins.
There are functions that let you access world variables (not Lua variables) from plugins and vice-versa (look for GetPluginVariable).
If you move your functions from mainmud.lua to also be in the plugin that you are moving your aliases and triggers into the problem should mainly go away. Plugins can have a script section. You can “dofile” if you want to make things more modular.
There are other ways of having plugins communicate with each other, such as CallPlugin.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Rdiniz
Brazil (21 posts) Bio
|
| Date
| Reply #2 on Fri 22 Feb 2019 01:58 AM (UTC) |
| Message
| Thank you Nick, I'll try that.
Small question: There's no need to set external script file if I move everything to plugin file? | | Top |
|
| Posted by
| Rdiniz
Brazil (21 posts) Bio
|
| Date
| Reply #3 on Fri 22 Feb 2019 03:36 AM (UTC) |
| Message
| Issue #1:
on mainmud.lua I had a list I initialized it as:
Then I had this function:
function addGroupie(name, hp, maxHp, mana, maxMana, leader, align, class, race, level)
groupieFormat = "/groupList.%s = {hp=%d, maxHp=%d, mana=%d, maxMana=%d, leader=%s, align=%d, class=%q, race=%q, level=%q}"
groupieText = string.format(groupieFormat, name, hp, maxHp, mana, maxMana, leader, align, class, race, level)
Execute(groupieText)
end
How should I handle this table on the plugin context? | | Top |
|
| Posted by
| Rdiniz
Brazil (21 posts) Bio
|
| Date
| Reply #4 on Fri 22 Feb 2019 09:27 PM (UTC) |
| Message
| Just found out the answer for last question, if anyone needs something like that:
function addGroupie(name, hp, maxHp, mana, maxMana, leader, align, class, race, level)
groupList[name] = {hp=hp, maxHp=maxHp, mana=mana, maxMana=maxMana, leader=leader, align=align, class=class, race=race, level=level}
end
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Sat 23 Feb 2019 06:41 AM (UTC) |
| Message
|
Rdiniz said:
Thank you Nick, I'll try that.
Small question: There's no need to set external script file if I move everything to plugin file?
No. The external script file is purely optional. |
- 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.
16,956 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top