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
➜ Need help developing a multi-variable script
|
Need help developing a multi-variable script
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Corsi
(2 posts) Bio
|
| Date
| Fri 04 Jul 2008 04:12 PM (UTC) Amended on Fri 04 Jul 2008 04:13 PM (UTC) by Corsi
|
| Message
| I've been toying around with Lua on MUSHclient to create a script to use in a game, but so far I have been unsuccessful in getting it right. I looked through other forum posts but couldn't piece together how to use extended variables to switch the variables each time.
I'm trying to make a script that will build a ship on a MUD.
General syntax for the building is:
buildship <ship> <part>
where ship is the name of the ship frame and part is the name of one of four parts (hull, circuits, weapons, engines). I was trying to use extended variables, but couldn't place the script right for this part, so I used normal triggers to do it.
Once a part is built, the success message (as I don't fail the process) is:
You finish modifying the ship.
which should route back to the buildship <ship> <part> command using the same part.
Once one part of the ship is complete, it will say (upon trying to build the same part again):
Your <ship> doesnt need any more of that.
which was the queue to start building on a different part. I wanted the script to move to circuits (if currently on hull), weapons (if currently on circuits), or engines (if currently on weapons), but I couldn't figure out how to alter the variables to do this.
Can anyone help me develop a script that would do this? For all intents and purposes, I lack scripting knowledge, but I've been using the resources and still couldn't get the script right.
I'm using Lua, MUSHclient 4.24. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sat 05 Jul 2008 10:32 AM (UTC) |
| Message
| It always helps to show what you have done already, as that indicates if you are very close, or a long way off.
Assuming you have kicked off the process with an alias that sets up the "ship" variable, and the "part" variable starting with "hull", then these triggers should move you along:
<triggers>
<trigger
enabled="y"
expand_variables="y"
match="You finish modifying the ship."
sequence="100"
>
<send>buildship @ship @part</send>
</trigger>
<trigger
enabled="y"
expand_variables="y"
match="Your * doesnt need any more of that."
send_to="12"
sequence="100"
>
<send>
require "var"
nextpart = {
hull = "circuits",
circuits = "weapons",
weapons = "engines",
engines = "done",
}
-- move on
var.part = nextpart [var.part]
if var.part ~= "done" then
Send ("buildship @ship " .. var.part)
end -- if not done
</send>
</trigger>
</triggers>
If that doesn't work, and you can't work out why, please copy and paste your exact triggers and aliases (see: http://mushclient.com/copying) and the actual output from the MUD.
See: http://mushclient.com/pasting for how to copy the above into the client. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Corsi
(2 posts) Bio
|
| Date
| Reply #2 on Sat 05 Jul 2008 02:49 PM (UTC) |
| Message
| This was pretty much exactly what I needed.
I already had set up the variables using /world.setvariable, so this code should work perfectly.
Thank you very much! | | 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.
14,229 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top