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
➜ VBscript
➜ Auto reroller sends one extra unwanted repeat of command
Auto reroller sends one extra unwanted repeat of command
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Wraithian
USA (16 posts) Bio
|
Date
| Sat 08 Nov 2003 10:22 PM (UTC) |
Message
| Ok. I'm currently playing a WoT based mud that lets you "roll" for stats. I made me a trigger/variable/script combo to help me get the perfect stats.... I have a small problem in it, however, that makes my trigger useless.
Here is the problem: The trigger and script will happily reroll the stats till it finds the ones I want. When it does find it, the script does stop. However, I find that it stops one revolution too late: in other words, it stops right after it sends an extra "n" to the mud.
Here is the trigger/variable/script info:
Stat Triggers:
- Label: trgStatCon/trgStatInt/trgStatWis (to match the purpose of each stat trigger)
- Trigger text: constitution/intelligence/wisdom : %1
- Action: Sends the %1 value of each trigger to its corresponding variable: varStatCon, varStatInt and varStatWis
- Sequence: 90 for all three triggers.
Prompt trigger:
- Label: trgStatCheck
- Trigger text: Do you wish keep these stats? *
- Action: call script ScriptStatCheck
- Sequence: 100 (hopefully forcing this trigger to let the others fire first)
Script Code:
Sub ScriptStatCheck (trgStatCheck, theoutput, Wildcards)
dim iCon, iInt, iWis
'Assign each script variable the value of its matching mud variable
iCon = World.GetVariable ("varStatCon")
iInt = World.GetVariable ("varStatInt")
iWis = World.GetVariable ("varStatWis")
'evaluate rolled stats
if iCon >= 20 and iInt >= 20 and iWis >= 20 then
World.Sound "sound.wav"
exit sub
else
World.DoAfter 1, "n" 'Tell the mud these stats aren't wanted, reroll again.
'After "n" is sent to the world, the mud again rolls stats, displays the
'new stats, and, of course, the prompt line again.
'So the trigger fires again, and continues to do so until the if condition is true.
end if
end sub
Anything I'm doing wrong? The script/trigger always fires one extra command that ruins the effectiveness of the pair. Sorry if my code isn't the best.
| Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #1 on Tue 11 Nov 2003 06:45 AM (UTC) |
Message
| I'm a bit worried about the "DoAfter". I think it will send the "n" a second too late.
I would do a "Send" rather than DoAfter, because the DoAfter will introduce a timing problem. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #2 on Tue 11 Nov 2003 06:46 AM (UTC) |
Message
| In other words, if the MUD re-rolls in half a second, the "n" arrives after one second, so that interval will give you the "n" you don't want. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Tue 11 Nov 2003 06:57 AM (UTC) |
Message
| But shouldnt that not matter? since there would be a correlation between the "n"s and the prompts?
It just adds a lag time... Since the mud wouldnt have anything else sent until a y or n was recieved. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Wraithian
USA (16 posts) Bio
|
Date
| Reply #4 on Tue 11 Nov 2003 07:08 AM (UTC) |
Message
| Sadly, I had already considered using send instead of doafter, and it still does the same... and yes, I sorta figured that doafter wouldn't do much, since doafter would wait for the trigger to fire first. I just put it there so that it's not a constant stream of "n"s.
I sadly get the same result with world.send as I do with world.doafter. The trigger line is on a line by itself, so that shouldn't pose any problems... in fact, here's a paste from the mud's stat roller:
Strength : 11
Intelligence : 16
Wisdom : 14
Dexterity : 12
Constitution : 22
Do you wish keep these stats (y/n)?
I was thinking it may have something to do with the mud sometimes not sending out a linefeed, but I'm not altogether sure of that. | Top |
|
Posted by
| Johnathan Allen
(49 posts) Bio
|
Date
| Reply #5 on Tue 11 Nov 2003 09:49 AM (UTC) |
Message
| Well... A few things. Try using cInt() on the variables. Perhaps they're being read as text strings instead of numbers? That would screw up your evaluations, since your looking for a numerical value.
if cInt(iCon) >= 20 and cInt(iInt) >= 20 and cInt(iWis) >= 20 then
Or, if that doesn't solve it:
In the ScriptStatCheck sub, add this right above the evaluation part. This will show you if its picking up the values correctly.
World.Note "Con: " & iCon & "Int: " & iInt & "Wis: " & iWis
| Top |
|
Posted by
| Nick Gammon
Australia (23,097 posts) Bio
Forum Administrator |
Date
| Reply #6 on Tue 11 Nov 2003 07:48 PM (UTC) Amended on Tue 11 Nov 2003 09:40 PM (UTC) by Nick Gammon
|
Message
|
Quote:
I was thinking it may have something to do with the mud sometimes not sending out a linefeed, but I'm not altogether sure of that.
You are probably right about that, as it would effectively be reacting to the 2nd-last roll. This topic has been covered at some length before, and I think I did a stat roller plugin, or example, that showed how to detect a line without a linefeed - basically you use a timer that checks the last line in the buffer. This timer would also have the effect of slowing down replies to one a second. |
- 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.
19,284 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top