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.
 Entire forum ➜ MUSHclient ➜ General ➜ Request for a COMPLETE script example

Request for a COMPLETE script example

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


Posted by Thd   (2 posts)  Bio
Date Fri 04 Jan 2008 05:10 AM (UTC)
Message
I am a Zmud user. Several days' study of MushClient just give me a quite brief awareness of this soft.
Questions:
1. Should all triggers be put in a single XML file, and functions in another .lua/.js file ? Is it possible to put all of these stuffs into one file ? Which is better ? Why ?
2. Can Anyone post a COMPLETE script example to explain how it runs ?
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #1 on Fri 04 Jan 2008 05:12 AM (UTC)
Message
Have you looked over other posts?
http://www.gammon.com.au/forum/?id=8359

Is that a complete script you were looking for?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #2 on Fri 04 Jan 2008 05:51 AM (UTC)

Amended on Fri 04 Jan 2008 05:53 AM (UTC) by Nick Gammon

Message
Thanks Zeno for a good reference.

The brief answer is that if you are going to use .xml files (ie. plugins) then related triggers and scripts should be in the same file. It makes sense that the script functions that relate to triggers should be in the same file with them.

The plugin the Zeno refers to is an example. Almost all of the plugins that are on this site, or supplied in the MUSHclient download, illustrate this.

Also see this: http://www.gammon.com.au/forum/?id=6030

- an introduction to scripting.

- Nick Gammon

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

Posted by Thd   (2 posts)  Bio
Date Reply #3 on Fri 04 Jan 2008 06:30 AM (UTC)
Message
Thanks all !
What I really want is to put all (triggers, alias, variables, functions) in a single lua or jscript file, but not a xml file, for I'm not formiliar with xml.

Yes, I found a set of scripts for Medievia, such as itemid.jvs. Learning now. :-)
Top

Posted by Shadowfyr   USA  (1,788 posts)  Bio
Date Reply #4 on Fri 04 Jan 2008 04:59 PM (UTC)
Message
The plugin architecture doesn't really allow for that. You could do it, by doing something like:

OnOpen()
  createtrigger ...
  createtrigger ...
  ... etc.

in the main script file, but that is going to delay the client, since instead of just parsing the world file, or a plugin, its going to have to run the Lua/Jscript code *first*, to build the list of triggers, and other stuff (and its a lot harder to edit them, not the least because the functions for creating them don't directly support all options, and if you do it the easy way, with ParseXML, you *still* have to use XML). XML isn't that hard, and Mushclient has a plugin builder, so you can create all your script, aliases, triggers, and so on, then use the plugin builder to place all of them into a plugin. I.e., you don't have to write one manually. Editing it after it exists is still not as easy as I would like, but creation can be done by creating all the needed features, testing them, then simply exporting those to a plugin.

Note however, if you don't use plugins, then it still does have the old system. Under that system you only have access to a limited number of functions from the client, which you can see under the "scripting" settings, but all triggers, aliases and timers are saved in the "world" file, while your script is kept in a separate .lua or .js file. The only limitation is, as I said, *most* special callbacks are not supported in the old system. However, you are probably not going to be using any of those in the short term, in most cases.
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #5 on Fri 04 Jan 2008 07:39 PM (UTC)
Message
The amount of XML that MUSHclient uses is quite easy to pick up. If you take a look at a world file, it's all broken down into simple divisions based on what each part does. Triggers have their own group, aliases another, etc. I would recommend just opening up a world file in a text editor and start reading through it, since that worked well for me.

As for seeing a "complete" script, there are example scripts included with MUSHclient, as well as a LOT of plugins posted both within the forums and on MUSHclient's web page. Also, take a look here: http://www.gammon.com.au/mushclient/scripting.htm for the "scripting a simple alias" which will show you how to implement your own script off of an alias.

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #6 on Fri 04 Jan 2008 07:54 PM (UTC)

Amended on Fri 04 Jan 2008 07:57 PM (UTC) by Nick Gammon

Message
The XML format is not that onerous to use, if you want everything in a single, easily portable file. (In other words, one you can send to other players, or use in multiple worlds of your own).

Basically there is an XML structure around the triggers, aliases and timers, which I will show below. To flesh it out you just copy and paste triggers from the GUI interface. To see how to do this, see http://www.mushclient.com/copying


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

<muclient>
<plugin
   name="Plugin_Name_Here"
   author="Author Name Here"
   id="e64351cb024eba7b8d6d0461"
   language="Lua"
   purpose="Plugin Description Here"
   requires="4.00"
   version="1.0"
   >

<description trim="y">
<![CDATA[

  Put free-format help text (if any) here.
  (Explain what the aliases do, for example)

]]>
</description>

</plugin>

<!--  Triggers  -->

<triggers>

  <!--  Put your triggers here (copy and paste from GUI interface)  -->

</triggers>

<!--  Aliases  -->

<aliases>
 
  <!--  Put your aliases here (copy and paste from GUI interface)  -->

</aliases>

<!--  Timers  -->

<timers>
  
  <!--  Put your timers here (copy and paste from GUI interface)  -->

</timers>

<!--  Script  -->


<script>
<![CDATA[

  -- Put your Lua scripts here.
  -- Inside CDATA blocks you don't need to use special treatment
  -- for < and > symbols.

]]>
</script>


</muclient>



The only thing you should change for each new plugin is to change the id="e64351cb024eba7b8d6d0461" line (near the top) to have a different unique identifier. Use the Edit menu in MUSHclient -> Generate Unique ID, to get a new one.

This file can be saved as a logical name (eg. my_plugin.xml) and then installed in MUSHclient using File menu -> Plugins.

After that you can edit it (double-click the plugin in the plugin list is one way of doing that), to amend the script, or triggers, aliases and timers.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


26,021 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.