Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
PrestoPimp
Apprentice


Joined: 18 Sep 2001
Posts: 175
Location: USA

PostPosted: Thu Feb 27, 2003 7:47 pm   

Putting two dice totals into variable
 
I'm having a little trouble with my dice score bot, maybe you all could help me.
The bot is supposed to see these 3 lines of text:

Bardios empties a dicing cup.
The six sided die rolls out onto the ground and the result is... 2
The six sided die rolls out onto the ground and the result is... 3


I have this trigger pattern setup:
@player1 empties a dicing cup. (@player1 being Bardios in this case)

and this command to try to capture each dice total to 2 variables:

#IF (@p1rollnum = 1) {
#TEMP {The six sided die rolls out onto the ground and the result is... (%n)} {#VAR p11die %1}
#TEMP {The six sided die rolls out onto the ground and the result is... (%n)} {#VAR p12die %1}
#WAIT 2500
#IF (@p11die=@p12die) {
say Doubles! Roll again.
#MATH p1roll1total (@p1roll1total+@p11die+@p12die)
} {
#MATH p1roll1total (@p1rollltotal+@p11die+@p12die)
#VAR p1rollnum 2)
}
}


This seems like it would work to me but when Player 1 rolls the dice, I see:
Bardios empties a dicing cup.
The six sided die rolls out onto the ground and the result is... 3
Variable: p11die 0
Variable: p12die 0
The six sided die rolls out onto the ground and the result is... 2


And then 2.5 seconds later he says that there were doubles. Someone help please!

-Prestopimp

Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Thu Feb 27, 2003 9:28 pm   
 
The #WAIT command and temporary triggers can be a bit squirrely. I suggest you rewrite this to not use either of them.

The following triggers store all dierolls as a string list in a variable named @dieroll. Note that in version 6.40 you can now refer to list items using the . operator.



#TR {@player1 empties a dicing cup.} {#T+ getroll; dieroll = ""}

#TR getroll {The six sided die rolls out onto the ground and the result is... (%n)} {
#IF (@p1roll = 1) {
#ADDITEM dieroll %1
#IF (%numitems(dieroll) = 2) {
#T- getroll
#ADD p1roll1total (@dieroll.1 + @dieroll.2)
#IF (@dieroll.1 = @dieroll.2) {
say Doubles! Roll again.
} {
#VAR p1roll 2
}
} {#NOOP}
} {#NOOP}
}


Dumping the cup initiates the variable. Once the variable has two rolls stored, it processes the data. I did some other tweaking to streamline things a bit. Here's a version you can cut and paste:

#TR {@player1 empties a dicing cup.} {#T+ getroll; dieroll = ""}

#TR getroll {The six sided die rolls out onto the ground and the result is... (%n)} {#IF (@p1roll = 1) {#ADDITEM dieroll %1; #IF (%numitems(dieroll) = 2) {#T- getroll; #ADD p1roll1total (@dieroll.1 + @dieroll.2); #IF (@dieroll.1 = @dieroll.2) {say Doubles! Roll again.} {#VAR p1roll 2}} {#NOOP}} {#NOOP}}

Troubadour
(Win 98, Pentium III, 550 MHz)
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Thu Feb 27, 2003 9:29 pm   
 
most likely the problem is being called caused by the #wait command. This probably prevents your other two triggers from firing. The #temps can be replace by trigger states, and the last state can do all the calculations:

#tr {@player1 empties a dicing cup.} {}
#cond {The six sided die rolls out onto the ground and the result is... (%d)} {
#var p11die %1}
#cond {The six sided die rolls out onto the ground and the result is... {%d) {
#var p12die %1
#math p1roll1total (@p1roll1total+@p11die+@p12die)
#if (@p11die = @p12die) {
say Doubles! Roll again.} {
#var p1rollnum 2}}


--edit--
hehe, 1 minute to slow
--------

moon.icebound.net:9000
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net