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

Gammon Forum

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

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Request for a COMPLETE script example
Home  |  Users  |  Search  |  FAQ
Register forum user name
Forgotten password?

Request for a COMPLETE script example

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

Posted by Thd   (2 posts)  [Biography] bio
Date Fri 04 Jan 2008 05:10 AM (UTC)
I am a Zmud user. Several days' study of MushClient just give me a quite brief awareness of this soft.
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 ?
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #1 on Fri 04 Jan 2008 05:12 AM (UTC)
Have you looked over other posts?

Is that a complete script you were looking for?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
[Go to top] top

Posted by Nick Gammon   Australia  (21,675 posts)  [Biography] 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

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

Posted by Thd   (2 posts)  [Biography] bio
Date Reply #3 on Fri 04 Jan 2008 06:30 AM (UTC)
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. :-)
[Go to top] top

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

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

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #5 on Fri 04 Jan 2008 07:39 PM (UTC)
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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,675 posts)  [Biography] 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

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>

   author="Author Name Here"
   purpose="Plugin Description Here"

<description trim="y">

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



<!--  Triggers  -->


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


<!--  Aliases  -->

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


<!--  Timers  -->

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


<!--  Script  -->


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



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
[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.


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

Go to topic:           Search the forum

[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]