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