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
➜ Help w/stat rolling script
Help w/stat rolling script
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Brie
(2 posts) Bio
|
Date
| Mon 11 Aug 2003 05:17 PM (UTC) |
Message
| I'm really stuck and I'm not sure what I'm doing wrong. Any help would be appreciated.
This is the output from the mud:
Your character's base stats have been rerolled...
New Previous
Strength 14 14
Dexterity 14 16
Intelligence 13 12
Wisdom 12 13
Charisma 9 11
Constitution 18 16
Luck 15 13
This is a script that a friend sent me:
<triggers>
<trigger
enabled="y"
match="Charisma *"
name="ccha"
script="checkcha"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
<trigger
enabled="y"
match="Constitution *"
name="ccon"
script="checkcon"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
<trigger
enabled="y"
match="Dexterity *"
name="cdex"
script="checkdex"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
<trigger
enabled="y"
match="Intelligence *"
name="cint"
script="checkint"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
<trigger
enabled="y"
match="Luck *"
name="clck"
script="checklck"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
<trigger
enabled="y"
match="Strength *"
name="cstr"
script="checkstr"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
</triggers>
dim rerollstats
sub checkstr(strtriggerName, trig_line, arrWildCards)
rerollstats = 0
dim str
str = 16
if arrWildCards(1) >= str then
rerollstats = 1
end if
end sub
sub checkdex(strtriggerName, trig_line, arrWildCards)
dim dex
dex = 16
if arrWildCards(1) >= dex then
rerollstats = 1
end if
end sub
sub checkint(strtriggerName, trig_line, arrWildCards)
dim int
int = 0
if arrWildCards(1) >= int then
rerollstats = 1
end if
end sub
sub checkwis(strtriggerName, trig_line, arrWildCards)
dim wis
wis = 0
if arrWildCards(1) >= wis then
rerollstats = 1
end if
end sub
sub checkcha(strtriggerName, trig_line, arrWildCards)
dim cha
cha = 0
if arrWildCards(1) >= cha then
rerollstats = 1
end if
end sub
sub checkcon(strtriggerName, trig_line, arrWildCards)
dim con
con = 0
if arrWildCards(1) >= con then
rerollstats = 1
end if
end sub
sub checklck(strtriggerName, trig_line, arrWildCards)
dim lck
lck = 12
if arrWildCards(1) >= lck then
rerollstats = 1
end if
reroll()
end sub
sub reroll()
if rerollstats = 1 then
world.send "reroll"
rerollstats = 0
else
world.send "touch orb"
end if
end sub
For some reason it just keeps sending reroll to the mud, even if the ouput is well over 16 on str and dex. I played around with it a bit and couldn't get it to work, so I attempted to code one based off other forum posts. I don't know how to script really, so I'm not surprised it doesn't work.. but here's what I came up with.
<triggers>
<trigger
enabled="y"
match="(Strength|Dexterity|Intelligence|Wisdom|Charisma|Constitution|Luck)\s*(\d+)\s*(\d+)$"
name="Stats"
script="checkstats"
send_to="12"
sequence="100"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
</triggers>
dim rerollstats
sub checkstats(strtriggerName, trig_line, arrWildCards)
rerollstats = 0
dim str, dex, int, wis, cha, con, lck
str = 18
dex = 18
int = 0
wis = 0
cha = 0
con = 0
lck = 12
if arrWildCards(2) >= str and _
if arrWildCards(2) >= dex and _
if arrWildCards(2) >= int and _
if arrWildCards(2) >= wis and _
if arrWildCards(2) >= cha and _
if arrWildCards(2) >= con and _
if arrWildCards(2) >= lck then
rerollstats = 1
end if
reroll()
end sub
sub reroll()
if rerollstats = 1 then
world.send "reroll"
rerollstats = 0
else
world.send "touch orb"
end if
end sub
The last script gives me an error message at this line: if arrWildCards(2) >= dex and _
So.. can please someone enlighten me to the error of my ways? Thanks again. | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #1 on Mon 11 Aug 2003 06:59 PM (UTC) |
Message
| I believe the super IF checking you do is not using the correct VB syntax. You would likely want it to be more like this:
if (arrWildCards(2) >= str) and _
(arrWildCards(2) >= dex) and _
(arrWildCards(2) >= int) and _
(arrWildCards(2) >= wis) and _
(arrWildCards(2) >= cha) and _
(arrWildCards(2) >= con) and _
(arrWildCards(2) >= lck) then
rerollstats = 1
end if
Now, that might get your script working, technically, but I believe the logic is wrong. Remember, you are calling this same script once for each attribute presented to you. What will happen is the script will be called 7 times, but each iteration will wipe out the value of "rerollstats", and what you end up doing is checking the value of "luck" for all your stats. In other words, if "luck" was 13, then your script will check if str is => 13, and dex => 13, and int => 13, etc...
I would either go back to the method handed to you by a friend (One trigger for each attribute), or else use one trigger and make a check in the script to see which attribute it was.
For example:
<triggers>
<trigger
enabled="y"
match="(Strength|Dexterity|Intelligence|Wisdom|Charisma|Constitution|Luck)\s*(\d+)\s*(\d+)$"
name="Stats"
script="Store_Stats"
send_to="12"
sequence="100"
>
</trigger>
</triggers>
Dim Str, Dex, Int, Wis, Cha, Con, Lck
Sub Store_Stats (TriggerName, TriggerLine, arrWildcards)
Select Case arrWildcards(1)
Case "Strength"
Str = arrWildcards(2)
Case "Dexterity"
Dex = arrWildcards(2)
Case "Intelligence"
Int = arrWildcards(2)
Case "Wisdom"
Wis = arrWildcards(2)
Case "Charisma"
Cha = arrWildcards(2)
Case "Constitution"
Con = arrWildcards(2)
Case "Luck"
Lck = arrWildcards(2)
Check_Stats
End Select
End Sub
Sub Check_Stats
if (Str => 18) and _
(Dex => 18) and _
(Int => 0) and _
(Wis => 0) and _
(Cha => 0) and _
(Con => 0) and _
(Lck => 12) then
World.Send "touch orb"
else
World.Send "reroll"
end if
End Sub
|
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Magnum
Canada (580 posts) Bio
|
Date
| Reply #2 on Mon 11 Aug 2003 07:07 PM (UTC) |
Message
| BTW: Two logic errors in your friends original script:
"1" means the value is acceptable, but he rerolls if the value is "1"
Any SINGLE attribute meeting your requirements sets the value to "1"
I won't bother to advise a fix for that method. |
Get my plugins here: http://www.magnumsworld.com/muds/
Constantly proving I don't know what I am doing...
Magnum. | Top |
|
Posted by
| Brie
(2 posts) Bio
|
Date
| Reply #3 on Mon 11 Aug 2003 07:44 PM (UTC) |
Message
| Thank you very much :) | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #4 on Mon 11 Aug 2003 10:19 PM (UTC) |
Message
| You also have a problem with the trigger match. The original was matching on:
However what the MUD sends is:
That means the wildcard will be "9 11" which will not give the right results.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Norry
(16 posts) Bio
|
Date
| Reply #5 on Tue 12 Apr 2005 02:42 AM (UTC) |
Message
| I was helping someone set this script up and realized there are a couple of errors in Magnum's trigger. First, it sends to script instead of world. Second, it's not set up as a regular expression.
It should look like this instead:
<triggers>
<trigger
enabled="y"
match="(Strength|Dexterity|Intelligence|Wisdom|Charisma|Constitution|Luck)\s*(\d+)\s*(\d+)$"
name="Stats"
regexp="y"
script="Store_Stats"
sequence="100"
>
</trigger>
</triggers>
| 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,975 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top