Gammon Forum
Entire forum
MUSHclient
VBscript
Scripting Variables and Returning
Scripting Variables and Returning
|
It is now over 60 days since the last post. This thread is closed.
  Refresh page
Posted by
| Zeppy
USA (15 posts) bio
|
Date
| Tue 13 Mar 2001 01:03 PM (UTC) |
Message
| This is likely a very simple set up, but for some reason it eludes me at the moment. I have a very simple variable setup that I'd like to do.
Currently I have a trigger for when I am disarmed that simply reacts to a disarm prompt and sends commands to get weapon and wield weapon.
What I want to do is set the weapon to a variable and then return it from within the trigger.
So here is the essence of it:
world sends:
soandso disarms you!
trigger sends to world:
get $weapon
wield $weapon
So "$weapon" would be the variable in this case. I'd like to set the variable with an alias then returns that value within the above trigger. Simple enough I'm sure, but I'm having major cerebral flatulations in deciding how to code it.
Suggestions? | top |
|
Posted by
| Zeppy
USA (15 posts) bio
|
Date
| Reply #1 on Tue 13 Mar 2001 01:16 PM (UTC) |
Message
| OK. Now that I posted it, I think I got an answer on another thread. Let me see if this is about right...
alias: weapon
send: nothing
script: weapon_varset
script:
sub onaliasweapon_varset(varname, weapon)
world.setvariable curweapon, weapon
end sub
Then when I want to send that to the world I would have this:
trigger: soandso disarms YOU!
send: get @curweapon;wield @curweapon
expand variables: checked
Is that right or am I just kidding myself? | top |
|
Posted by
| Nick Gammon
Australia (22,982 posts) bio
Forum Administrator |
Date
| Reply #2 on Tue 13 Mar 2001 01:28 PM (UTC) Amended on Tue 13 Mar 2001 01:33 PM (UTC) by Nick Gammon
|
Message
| You are very close. :)
I would make the script quote the weapon variable name, and also the alias needs three arguments (the third being a list of wildcards), like this:
sub onaliasweapon_varset (strAliasName, strOutput, arrWildCards)
world.setvariable "curweapon", arrWildCards (1)
end sub
The alias now needs to match on a wildcard (the weapon name), you need to specify a label before it will let you type in a script name, and the script name needs to match what you specified in the alias (onaliasweapon_varset), like this:
alias: weapon *
send: nothing
label: weapon_varset
script: onaliasweapon_varset
I would probably put the trigger response over multiple lines, but if it works, then leave it alone. Also, maybe use a wildcard so it works if anyone disarms you.
trigger: * disarms YOU!
send: get @curweapon
wield @curweapon
expand variables: checked
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Zeppy
USA (15 posts) bio
|
Date
| Reply #3 on Wed 14 Mar 2001 12:41 PM (UTC) |
Message
| Let me make sure I have one element correct. The line "onalias" has no more function than anything else. So if I wanted to call the script "Sub weapons" it would be just the same as calling it "Sub onaliasweapon_var" right?
Sorry for the lame questions...I try do better. :-) | top |
|
Posted by
| Nick Gammon
Australia (22,982 posts) bio
Forum Administrator |
Date
| Reply #4 on Wed 14 Mar 2001 12:52 PM (UTC) Amended on Wed 14 Mar 2001 12:53 PM (UTC) by Nick Gammon
|
Message
| I'm not absolutely sure I understand the question.
The alias calls a subroutine (sub) by name. The subroutine has to have the name you specify. The name doesn't matter, but it has to agree between what the alias specifies, and what the sub has.
You could call it "rocketship" if you want to, but you have to do that in two places, eg.
Alias
Match: test
Label: blahblah
Script: rocketship
Script
sub rocketship (strAliasName, strOutput, arrWildCards)
world.note "test alias script"
end sub
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | top |
|
Posted by
| Zeppy
USA (15 posts) bio
|
Date
| Reply #5 on Thu 15 Mar 2001 07:38 AM (UTC) |
Message
| OK cool. You answered the question fine. Sorry I wasn't more clear. Thanks a ton and keep up the great work! It's really a fantastic application! | 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.
15,428 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
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.