I was wondering, is there a way to make global functions? I tried putting it at the end of the Lua Global Preferences, but, whenever I called the functions, they all returned as nil values. It's just that I use a lot of aliases on just about every single world. It'd be much easier to have it in one spot that all the worlds looked at instead of having to copy it into every single world file :)
Global Functions
Posted by Terry on Tue 29 Jul 2008 02:41 PM — 6 posts, 22,359 views.
Yes, global functions should be possible... after all, the sandbox is affecting the global namespace (of sorts). what do you mean when you say that the functions returned as nil values? Do you mean that they weren't found, or that they returned nil?
Putting stuff in the Lua sandbox should work, however I wouldn't do it that way.
That is exactly what Plugins are for. To try to put them into the sandbox would mean scripting the creation of them, this is a very roundabout way of doing it. Plus, the sandbox is stored in the Windows Registry, if you ever re-install MUSHclient, or change PCs, or re-install Windows, you will lose it.
Take a look at plugins, you can very easily turn all your aliases into one or more plugins, and you can have plugins automatically load into every world.
Quote:
I use a lot of aliases on just about every single world ...
I use a lot of aliases on just about every single world ...
That is exactly what Plugins are for. To try to put them into the sandbox would mean scripting the creation of them, this is a very roundabout way of doing it. Plus, the sandbox is stored in the Windows Registry, if you ever re-install MUSHclient, or change PCs, or re-install Windows, you will lose it.
Take a look at plugins, you can very easily turn all your aliases into one or more plugins, and you can have plugins automatically load into every world.
How would I call functions from plugins? Would I use 'require <plugin>'?
I'm not sure I understand that question. Do you mean call plugins from functions?
It isn't really clear what you are trying to do. You talked about making "global functions" but it seems like you really want global aliases.
Perhaps a few examples would help, of what you are doing.
It isn't really clear what you are trying to do. You talked about making "global functions" but it seems like you really want global aliases.
Perhaps a few examples would help, of what you are doing.
Well, now that I think about it, I guess it's more of a module that I'm looking to make. (That's where I got the 'require <plugin>' idea from, anyway.) I asked before about a CommandNote() function, and someone answered on how to do it. I was just trying to figure out how to utilize it, and also utilize custom global functions in the future.