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 ➜ General ➜ Variables & Local Variable in LUA

Variables & Local Variable in LUA

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


Pages: 1  2 

Posted by Candido   USA  (78 posts)  Bio
Date Reply #15 on Thu 07 Jul 2011 07:16 PM (UTC)
Message
Mushclient should have a super _G for cross plugin lua variables!

In world

superglobal x="hi"


In plugin

tprint(_SG)

...

"x"="hi"

:)
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #16 on Thu 07 Jul 2011 08:43 PM (UTC)
Message
That's awfully difficult to do, since every plugin has its own script space. If you had an _SG table, you'd need to copy anything in it to every other plugin. And some values, like tables, can be changed without affecting _SG, so there's no easy way to tell the other plugins that the table changed.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Candido   USA  (78 posts)  Bio
Date Reply #17 on Thu 07 Jul 2011 09:38 PM (UTC)
Message
Yes, that was more of an idle thought. A more realistic solution is to just let CallPlugin call functions from the main world, since lua variables can be returned directly from CallPlugin.
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #18 on Thu 07 Jul 2011 09:47 PM (UTC)
Message
You can get at main world client variables (not Lua variables) easily enough.

But really, the whole idea of plugins is they are self-contained, otherwise they could all have shared the same script space.

I would personally regard "main world" scripts and variables for things like testing scripts before they go into plugins, or for minor additions to a particular world.

Plugins give you the flexibility to have self-contained scripts, variables, etc. and also can easily be shared between different world files (eg. different characters on a particular MUD).

Another useful thing you can do with plugins is impose "source control" on them. That is, install Git and then do a "git commit" from time to time, to keep track of what changes you are making and when. This helps keep track of earlier versions. Often it is helpful when dealing with scripts to look back at an earlier version and see why feature X might have worked before but has stopped working now.

Of course you can do that with the main world file as well, but with everything in together it is less easy to see what purpose each part has.

- Nick Gammon

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

Posted by Candido   USA  (78 posts)  Bio
Date Reply #19 on Thu 07 Jul 2011 09:56 PM (UTC)
Message
I've thought about doing it that way, but the sacrifice you make with plugins is that it's not easy to edit their trigs and aliases on the fly. What's the point of having mushclient's nice trigger/alias GUI if all your important triggers and aliases are in plugins? Seems a bit like subverting the whole client.
Top

Posted by Candido   USA  (78 posts)  Bio
Date Reply #20 on Thu 07 Jul 2011 09:58 PM (UTC)
Message
Also while I understand the idea of plugins being self-contained, that's already been compromised pretty thoroughly. Plugins have huge amounts of infrastructure for communicating with each other, just not with the main world.
Top

Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #21 on Fri 08 Jul 2011 01:18 AM (UTC)
Message
case sensitive..Lua~~~..right -_-"

Actually I check via wiki, Lua is a script language that mainly for Game purpose, do there any other usage of it? just like Javascript for web, I just want to know the benifit besides mud and game developing if I learn "Lua" very well XD....

For sure, my mainly purpose is enjoy the fun from make AI robot system for mud, great UI and plugin but I decide change from z/cmud to mush, it really take time to learn, and no zscript that I learn jscript / VBscript / Lua is no difference for me :D...
I choose Lua because everybody said it's powerful only -.-"...

I have further question about mush, I make it in other post, thanks for all guys suuuuuport me to learn...lol
Top

Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #22 on Fri 08 Jul 2011 01:31 AM (UTC)
Message
plugins....

I'm also considering about the script structure of my new trigger in mush...which part put in script file...which part put in core world file..which part put in plugin file...it's totally different concept with Cmud..-.-"
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #23 on Fri 08 Jul 2011 03:27 AM (UTC)
Message
Candido said:

I've thought about doing it that way, but the sacrifice you make with plugins is that it's not easy to edit their trigs and aliases on the fly. What's the point of having mushclient's nice trigger/alias GUI if all your important triggers and aliases are in plugins? Seems a bit like subverting the whole client.


It's not that bad. The XML in the triggers is pretty self-documenting, so changing something like:


enabled = "y"


isn't that much harder to follow then checking or unchecking a box.

To add whole new batches of triggers/aliases you can do what I do ... set one or more up up in the GUI interface, then hit the Copy button, switch to the plugin, and paste the resulting XML in.

You can also organise plugins better by using the XML comments, and grouping related things together (you can have more than one set of triggers in a plugin).


- Nick Gammon

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

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #24 on Fri 08 Jul 2011 03:30 AM (UTC)
Message
Tkl1129 said:

case sensitive..Lua~~~..right -_-"

Actually I check via wiki, Lua is a script language that mainly for Game purpose, do there any other usage of it? just like Javascript for web, I just want to know the benifit besides mud and game developing if I learn "Lua" very well XD....


Lua is pretty widely used, whereas zscript is for a particular MUD client.

Apart from other game-related instances (eg. World of Warcraft) it is a powerful general tool. For example, a while back I used a Lua script to process hundreds of email messages in individual files, locate the message headers, etc. and then put the resulting messages into a MySQL database.

Compared to things like Javascript, Lua is very compact and easy to learn IMHO.

- Nick Gammon

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

Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #25 on Fri 08 Jul 2011 03:47 AM (UTC)
Message
Oh..thats mean if I want to manage plugins well...except makes new plugin copy from tri & alias...I'm also able to learn the format of XML ?

-_-"...what a big project..
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #26 on Fri 08 Jul 2011 04:01 AM (UTC)

Amended on Fri 08 Jul 2011 04:03 AM (UTC) by Twisol

Message
It's really pretty easy to deal with. I usually just copy the <plugin> prologue from another plugin and change the name, id, etc., add a <script> section for my code, and export aliases/triggers from MUSHclient and paste them somewhere else. For example, this is a good skeleton plugin:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<muclient>

<!-- Change everything here to fit your plugin -->
<!-- Get a new ID from Edit -> Generate Unique Id -->
<plugin
   name="MyPlugin"
   author="Soludra"
   id="043e0976013412f26cf9a395"
   language="Lua"
   purpose="Stuff"
   date_written="2011-07-07"
   requires="4.74"
   version="1.000"
   >
</plugin>

<!-- Paste aliases, triggers, etc. here. -->

<script><![CDATA[

-- Code goes here!

]]></script>
</muclient>

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,158 posts)  Bio   Forum Administrator
Date Reply #27 on Fri 08 Jul 2011 04:40 AM (UTC)
Message
Tkl1129 said:

Oh..thats mean if I want to manage plugins well...except makes new plugin copy from tri & alias...I'm also able to learn the format of XML ?

-_-"...what a big project..


It's not that big. ;)

Triggers, aliases and timers are either easily modified or copied from the GUI interface. The rest is basically the script part or stuff you are unlikely to modify often.

I suggest you stop thinking along the lines of "how do I convert zscript to MUSHclient scripting?" and start thinking about what is the underlying problem you are trying to solve.

There are a lot of examples on this website, and various plugins that other people have written are a good guide to how you can go about things. Stuff like mappers, healing systems, health bars, etc.


- Nick Gammon

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

Posted by Tkl1129   Hong Kong  (43 posts)  Bio
Date Reply #28 on Fri 08 Jul 2011 05:22 AM (UTC)
Message
I'm trying my best to do it /_\"...

I'd read many many post and reading the book "programming in Lua" already..-.-"

Lua basics I can learn from book...those function also can, but I keep ask here because I want to find a shortcut to access which part I'm able to learn...or some part even I read book and read post still don't understand XD...zscript, I throw it away already XD, when I decide to learn Lua :P

I will try harder to read the post in forum..hope can answer my "stupid" questions :P
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.


81,741 views.

This is page 2, subject is 2 pages long:  [Previous page]  1  2 

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.