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 with creating a script
|
Need help with creating a script
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Drazzen
(11 posts) Bio
|
| Date
| Wed 04 Dec 2002 04:55 AM (UTC) |
| Message
| Ok..on the mud I play (Aetolia.com) I need to execute some commands after I am initially stunned. To date I have been using the 'Send To World (speedwalk delay)' option on the trigger but to do so I need to set my speed walk delay to 2100. As you can see that would make the word speedwalk a joke.
I am seeking to get help to create a simple script that I can use to replace those triggers. Also I am comfused as to whether I will need to create a new script for each trigger.
This is a basic rundown of what happens.
1. Person attacks me causing a 2 second stun
2. Immediately following that attack person inflicts me with one of quite a few afflictions.
3. Stun wears off
4. I am able to eat/apply the cure for the affliction.
This is VERY important in my mud because afflications can stack and really leave you crippled.
Another question is is there a way to script this scenario so that rather then have a set timer the script waits for the words 'You are no longer stunned' before taking care of the affliction that was applied during the stun.
Here are two examples of how this looks in the mud (First is a special skill that applies 2 afflictions rather then one and second is the normal attack)
---------------------
With a soft hiss, <NAME> launches herself at you, battering you in a frenzied
flurry of strikes.
H:1771 M:2230 B:84% [eb]
<NAME>'s eyes meet yours, suddenly locking your gaze to her. She utters a sharp, unintelligible whisper, and you break free of her piercing gaze.
Your mind feels suddenly confused and jumbled.
Your mind feels somewhat slower and more plodding.
approx 2 second later : You are no longer stunned.
--------------------
With a soft hiss, <NAME> launches himself at you, battering you in a frenzied flurry of strikes.
H:1708 M:2230 B:84% [eb]
<NAME>'s eyes meet yours, suddenly locking your gaze to his. He utters a sharp, unintelligible whisper, and you break free of his piercing gaze.
Your mind feels somewhat slower and more plodding.
approx 2 second later : You are no longer stunned.
---------------------
Lastly do I have to have Windows script installed on my PC for scripting to work? The majority of the time I play from work (hehe) and I cannot install it on that PC.
Thanks in advance for all help with this.
| | Top |
|
| Posted by
| Shadowfyr
USA (1,792 posts) Bio
|
| Date
| Reply #1 on Wed 04 Dec 2002 05:03 PM (UTC) Amended on Wed 04 Dec 2002 05:05 PM (UTC) by Shadowfyr
|
| Message
| Hmm.. First things first.. Yes you do need windows scripting for it to work. However, unless they intentionally removed it and don't use web access or internet explorer, then it should already be on the system, since it is part of the standard installation of Internet Explorer. The only thing installing a new version would do is upgrade it to support features or bug fixes that the older version wouldn't (something any decent company should be doing anyway).
As for the rest of your problem.. It isn't too complicated. ;) First things first is to use the triggers names to ID the afflictions:
Match: Your mind feels suddenly confused and jumbled.
Name: Confused
Script: Add_Affliction
Match: Your mind feels somewhat slower and more plodding.
Name: Mind_Slow
Script: Add_Affliction
Note how the same script is used to do things for all situations. ;) As for that:
sub Add_Affliction (tname, output, wilds)
if world.getvariable("Afflictions") <> "" then
world.setvariable "Afflictions", world.getvariable("Afflictions") & "," & tname
else
world.setvariable "Afflictions", tname
end if
end sub
Basically a string is built up like:
Confusion,Mind_Slow,...
When the 'You are no longer stunned' bit arrives the variable needs to be split into an array and processed:
Match: You are no longer stunned.
Name: No_Stun
Script: No_Stun
sub No_Stun (tname, output, wilds)
dim arr, count, temp
arr = split(world.getvariable("Afflictions"),",") 'Generate an array.
if ubound(arr) > 0 then
for count = 0 to ubound(arr)
call Cure_It(arr(count))
next
else
if arr <> "" then
call Cure_It(arr)
end if
end if
world.setvariable "Afflictions", ""
end sub
sub Cure_It (type)
select case temp
case "Confusion"
world.send "..." 'Add whatever command you need here.
case "Mind_Slow"
world.send "..." 'Add whatever command you need here.
case ... 'Add any other types.
end select
end sub
Using a seperate sub to do the actually application allows checking to make sure something is actually in the array and that it is in fact an array before trying to do anything with it, otherwise errors could happen. | | Top |
|
| Posted by
| Drazzen
(11 posts) Bio
|
| Date
| Reply #2 on Wed 04 Dec 2002 05:30 PM (UTC) Amended on Wed 04 Dec 2002 05:43 PM (UTC) by Drazzen
|
| Message
| Will this fire if I am stunned but there are no coresponding afflictions?
And where is this data you listed actually placed :
Match: Your mind feels suddenly confused and jumbled.
Name: Confused ***(Is this the trigger label?)***
Script: Add_Affliction ***(Is this placed in the area of the trigger editor that says Script?)***
Forgive me if I am seeming a dunce on this...its been a long while since I coded anything and trying to put this all together.
Lastly do No_Stun and Cure_it need to be in seperate script files or in the same one? | | Top |
|
| Posted by
| Shadowfyr
USA (1,792 posts) Bio
|
| Date
| Reply #3 on Wed 04 Dec 2002 05:45 PM (UTC) Amended on Wed 04 Dec 2002 05:50 PM (UTC) by Shadowfyr
|
| Message
| <triggers>
<trigger
match="Your mind feels suddenly confused and jumbled."
name="Confused"
script="Add_Affliction"
enabled="y">
</trigger>
<trigger
match="Your mind feels somewhat slower and more plodding."
name="Mind_Slow"
script="Add_Affliction"
enabled="y">
</trigger>
<trigger
match="You are no longer stunned."
name="No_Stun"
script="No_Stun"
enabled="y">
</trigger>
</triggers>
And yeah, you got them right. You would add additional triggers that called Add_Affliction for other stuff and add corresponding 'case "type"' sections to the Cure_It sub as needed to handle them. The above versions should allow you to cut and paste them directly into the trigger editor. ;)
And yes, it will fire even if you are not afflicted, but it checks to make sure that the variable actually contains something before doing anything and if it is empty will basically do nothing. It would be possible to change it so the trigger for the stun going away is enabled/disabled as needed, but the amount of time spent in a script is so small in cases like this that you would have to be using a old 16mhz 386 to notice the difference. ;)
BTW <to Nick> I just noticed that.. Why is it 'name' in the xml, but label in the trigger editor? It is slightly confusing in that respect. | | Top |
|
| Posted by
| Drazzen
(11 posts) Bio
|
| Date
| Reply #4 on Wed 04 Dec 2002 05:49 PM (UTC) Amended on Wed 04 Dec 2002 06:08 PM (UTC) by Drazzen
|
| Message
| Ok...and what if I am afflicted but there is no stun. Would I just set a regular trigger to cure me without looking for the stunned message?
And for your last post I am confused. Where in the trigger editor would that be placed.
Is all the above in one script and if so how does it look when layed out. Placed in what order I mean.
Right now I have 3 scripts : Add_Affliction, On_Stun, Cure_It
Should all of these have been in the same script with the triggers listed below?
-------
This confuses me as it looks like a Java array: (How does this corespond to the editor?)
<triggers>
<trigger
match="Your mind feels suddenly confused and jumbled."
name="Confused"
script="Add_Affliction"
enabled="y">
</trigger>
<trigger
match="Your mind feels somewhat slower and more plodding."
name="Mind_Slow"
script="Add_Affliction"
enabled="y">
</trigger>
<trigger
match="You are no longer stunned."
name="No_Stun"
script="No_Stun"
enabled="y">
</trigger>
</triggers>
--------
world.send "..." ***(If I need two commands here with a carridge return between them how would look)***
For instance if I needed Outb Goldenseal <return> Eat Goldenseal. | | Top |
|
| Posted by
| Shadowfyr
USA (1,792 posts) Bio
|
| Date
| Reply #5 on Wed 04 Dec 2002 06:05 PM (UTC) |
| Message
| Ok.. First off scripts work one of two ways.. They either get placed into a single 'global' world script so that they can all be accessable from the world. So you would drop all the script parts into a file like 'Myscripts.vbs', point mushclient to this script in the 'script' settings and set the type to vbscript. The other method uses xml to integrate both the triggers and the script into a single 'plugin' file. This is a bit complex to do, so it is easier for something simple like this to use the first approach. ;)
No stun, but afflicted... You do know how to complicate things.. lol Right now the answer is that it doesn't know how to deal with that situation as written. You could use regular triggers to do it in such a case, but that creates other issues.. One possibility is an alias like:
<alias
match="Cureme"
name="acure"
script="No_Stun"
enabled="y"
</alias>
You would have to type the alias, but it would then process any existing afflictions as though the client had instead recieved the un-stunned triggering line. The only other option is to find some other line that can be used like the 'You are no longer stunned.' one to initiate the trigger.
As for where to put things like what is above.. In newer versions there are two extra buttons in the editors, one is 'Copy' an the other is 'Paste'. Mushclient will recognize the above for instance and being an alias and thus if you select it, copy it and then go into the alias editor you will see the 'paste' button active. Hitting that automatically adds the alias you copied from here into the list. Same for triggers and the trigger editor. ;) | | Top |
|
| Posted by
| Drazzen
(11 posts) Bio
|
| Date
| Reply #6 on Wed 04 Dec 2002 06:21 PM (UTC) |
| Message
| Ok so in that global script file I place all the elements that you have provided me above. When the world loads will it automatically run this script and be looking for any and all trigger instances? If so great!! And if so Will it matter how I place the above in the script?
| | Top |
|
| Posted by
| Shadowfyr
USA (1,792 posts) Bio
|
| Date
| Reply #7 on Wed 04 Dec 2002 06:29 PM (UTC) |
| Message
| | Yes. As long as you make sure to enable the scripting, set it to the right script type and remember to save it, the script will load with the world each time. As for the order you place things.. Scripts don't seem to particualarly care what order the subs are in. However, you can use 'global' variables and the like that appear outside of a sub-end sub section and I am not sure how that gets handled, so placing such things if you do use them 'before' anything else may be a good idea. However, in this case you aren't using any thing like that, so it isn't an issue for now. | | Top |
|
| Posted by
| Drazzen
(11 posts) Bio
|
| Date
| Reply #8 on Wed 04 Dec 2002 06:33 PM (UTC) |
| Message
| Ok..I placed all the subs in with the triggers following.
About that world.send element. Is it possible to send two seperate commands? Like so:
sub Cure_It (type)
select case temp
case "Confusion"
world.send "..." 'Add whatever command you need here.
world.send "..." 'Add whatever command you need here.
case "Mind_Slow"
world.send "..." 'Add whatever command you need here.
world.send "..." 'Add whatever command you need here.
case ... 'Add any other types.
end select
end sub | | Top |
|
| Posted by
| Shadowfyr
USA (1,792 posts) Bio
|
| Date
| Reply #9 on Wed 04 Dec 2002 07:08 PM (UTC) Amended on Wed 04 Dec 2002 07:54 PM (UTC) by Shadowfyr
|
| Message
| Yes. Each 'Case' is a seperate execution block. It works a bit like an if then statement with else, it basically replaces this:
if a then
do something
do something else
else if b then
do other stuff
do more other stuff
else if c then
...
else
...
end if
with:
select case variable
case a
do something
do something else
case b
do other stuff
do more other stuff
case c
...
case else
...
end select
This is not only easier to read, but is supposed to be generally faster in interpreted languages. It also become extremely useful when you have 40+ things to test against. ;) lol | | Top |
|
| Posted by
| Drazzen
(11 posts) Bio
|
| Date
| Reply #10 on Wed 04 Dec 2002 07:33 PM (UTC) |
| Message
| Thanks for all your help Shadowfyr!
I think I have enough to start. Just trying to determine how not to have existing triggers overlap the script so that I can deal with individual afflictions with no stun.
| | Top |
|
| Posted by
| Shadowfyr
USA (1,792 posts) Bio
|
| Date
| Reply #11 on Wed 04 Dec 2002 08:11 PM (UTC) Amended on Wed 04 Dec 2002 09:01 PM (UTC) by Shadowfyr
|
| Message
| Well.. One possibility would be like>
match="You eat an apple."
name="Remove_A"
script="Remove_It"
match="You apply a bandage."
name="Remove_B"
script="Remove_It"
sub Remove_It(tname, output, wilds)
dim temp
temp = split(world.getvariable("Afflictions"),",")
if ubound(temp) > 0 then
world.setvariable "Afflictions",""
end if
end sub
And use one of these for each response you get from treating the affliction. In this case if you have been afflicted with more than one, do to not having a way to treat it when it happened, then the variable is left alone so that when the stun does go away everything is treated, otherwise it ends up clearing the variable so that the 'cured' problem doesn't carry over to the next case where you are stunned. As long as there is no chance that a new affliction will hit you before you successfully eat, drink or apply something it should work. If there is a possibility of this then the issue becomes more complicated, but I am not sure how often you are likely to have something that goes:
afflicted
afflicted
cure the first one
stunned
afflicted
unstunned
This is the 'only' case where it may be a potential issue since it will in effect 'miss' the second affliction (since the successful cure will clear the variable and erase what the un-stun trigger needed in that instance). This may not even be a problem depending on how things work. | | 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.
33,696 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top