Register forum user name Search FAQ

Gammon Forum

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 ➜ Global Functions

Global Functions

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Terry   USA  (87 posts)  Bio
Date Tue 29 Jul 2008 02:41 PM (UTC)
Message
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 :)
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Tue 29 Jul 2008 03:41 PM (UTC)
Message
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?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #2 on Tue 29 Jul 2008 09:05 PM (UTC)
Message
Putting stuff in the Lua sandbox should work, however I wouldn't do it that way.

Quote:

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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Terry   USA  (87 posts)  Bio
Date Reply #3 on Wed 30 Jul 2008 03:26 AM (UTC)
Message
How would I call functions from plugins? Would I use 'require <plugin>'?
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #4 on Wed 30 Jul 2008 05:45 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Terry   USA  (87 posts)  Bio
Date Reply #5 on Thu 31 Jul 2008 02:58 AM (UTC)
Message
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.
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.


17,488 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.