[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Variables & Local Variable in LUA

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Variables & Local Variable in LUA
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Fri 08 Jul 2011 05:22 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Fri 08 Jul 2011 04:40 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Fri 08 Jul 2011 04:01 AM (UTC)  quote  ]

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
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Fri 08 Jul 2011 03:47 AM (UTC)  quote  ]
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..
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Fri 08 Jul 2011 03:30 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Fri 08 Jul 2011 03:27 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Fri 08 Jul 2011 01:31 AM (UTC)  quote  ]
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..-.-"
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Fri 08 Jul 2011 01:18 AM (UTC)  quote  ]
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
[Go to top] top

Posted by Candido   USA  (78 posts)  [Biography] bio
Date Thu 07 Jul 2011 09:58 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Candido   USA  (78 posts)  [Biography] bio
Date Thu 07 Jul 2011 09:56 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Thu 07 Jul 2011 09:47 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Candido   USA  (78 posts)  [Biography] bio
Date Thu 07 Jul 2011 09:38 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by Twisol   USA  (2,229 posts)  [Biography] bio
Date Thu 07 Jul 2011 08:43 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Candido   USA  (78 posts)  [Biography] bio
Date Thu 07 Jul 2011 07:16 PM (UTC)  quote  ]
Message
Mushclient should have a super _G for cross plugin lua variables!

In world

superglobal x="hi"


In plugin

tprint(_SG)

...

"x"="hi"

:)
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Thu 07 Jul 2011 10:01 AM (UTC)  quote  ]
Message
Twisol said:

However you *could* assign nil to getfenv, as well. Lovely!


Lol. Yes you *could* do that.

There are a lot of things you could do. ;)

@Tkl1129 - the language is Lua, not LUA. May as well get the name right.

It is very powerful, that power can be abused. Your ultimate goal would hopefully be to write scripts that work well, and also are very easy to maintain.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


2,993 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]