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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Wrens
Novice


Joined: 01 Jun 2003
Posts: 32
Location: USA

PostPosted: Fri Nov 24, 2006 4:07 am   

coin counting script
 
Got another good question. I use the below script to fill information in a button telling me what money I have on me. Works wonderfully in ZMud. Made changes that I thought would make it work. It compiles, but, all that goes into the varible for the buttons is the copper values. Suggestions, and why don't it work?


copperk = "0"
copperl = "0"
copperd = "0"
#TEMP {&%*{kron} Kronars.} {
copk = "0"
broK = "0"
silk = "0"
golk = "0"
plak = "0"
kron = %replace( @Kron, "," , "|")
kron = %replace( @kron, "and ", "")
#FORALL @kron {
#IF {%word( %i, 2)= copper} {copk = %eval( %word( %i, 1))}
#echo @copk
#IF {%word( %i, 2)= bronze} {brok = %eval( %word( %i, 1)*10)}
#IF {%word( %i, 2)= silver} {silk = %eval( %word( %i, 1)*100)}
#IF {%word( %i, 2)= gold} {golk = %eval( %word( %i, 1)*1000)}
#IF {%word( %i, 2)= platinum} {plak = %eval( %word( %i, 1)*10000)}
}
#MATH copperk (@copk + @brok + @silk + @golk + @PlaK)
#UNTR {No coins on you.}
}
#TEMP {&%*{liru} Lirums.} {
copperl = "0"
copl = "0"
brol = "0"
sill = "0"
goll = "0"
plal = "0"
liru = %replace( @liru, ", ", "|")
liru = %replace( @liru, "and ", "")
#FORALL @liru {
#IF {%word( %i, 2)= copper} {copl = %eval( %word( %i, 1))}
#IF {%word( %i, 2)= bronze} {brol = %eval( %word( %i, 1)*10)}
#IF {%word( %i, 2)= silver} {sill = %eval( %word( %i, 1)*100)}
#IF {%word( %i, 2)= gold} {goll = %eval( %word( %i, 1)*1000)}
#IF {%word( %i, 2)= platinum} {plal = %eval( %word( %i, 1)*10000)}
}
#MATH copperl (@copl + @brol + @sill + @goll + @Plal)
#UNTR {No coins on you.}
}
#TEMP {&%*{dok} Dokoras.} {
copperd = "0"
copd = "0"
brod = "0"
sild = "0"
gold = "0"
plad = "0"
dok = %replace( @dok, ", ", "|")
dok = %replace( @dok, "and ", "")
#FORALL @dok {
#IF {%word( %i, 2)= copper} {copd = %eval( %word( %i, 1))}{}
#IF {%word( %i, 2)= bronze} {brod = %eval( %word( %i, 1)*10)}{}
#IF {%word( %i, 2)= silver} {sild = %eval( %word( %i, 1)*100)}{}
#IF {%word( %i, 2)= gold} {gold = %eval( %word( %i, 1)*1000)}{}
#IF {%word( %i, 2)= platinum} {plad = %eval( %word( %i, 1)*10000)}{}
}
#MATH copperd (@copd + @brod + @sild + @gold + @Plad)
#UNTR {No coins on you.}
}
#TEMP {No coins on you.} {
copperl = "0"
copperk = "0"
copperd = "0"
#UNTR {&%*{dok} Dokoras.}
#UNTR {&%*{kron} Kronars.}
#UNTR {&%*{liru} Lirums.}
}
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Fri Nov 24, 2006 10:02 am   
 
Remove all the "" from the variable assignments that are numeric, e.g. copperd = "0" should be copperd = 0. Otherwise copperd will be a string and not an integer.
Reply with quote
Wrens
Novice


Joined: 01 Jun 2003
Posts: 32
Location: USA

PostPosted: Fri Nov 24, 2006 8:25 pm   
 
Sorry, I tried the removal of the " " It gives me the same behavior: only the coppers are counted. Example:

5 bronze, and 53 copper Kronars.

the varible Copperk becomes 53. Only the first if seems to be working.

Thanks for the answer though. I have tried putting in a the second part of the #If command as a {#noop} Same thing. Any other suggestions?


Thanks
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Fri Nov 24, 2006 10:30 pm   
 
This is a pretty complex script. I suggest you break it down into more manageable pieces until you isolate which part is not working. If you're still stuck at that point, it will be easier for us to help you.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4662
Location: Pensacola, FL, USA

PostPosted: Sat Nov 25, 2006 6:24 am   
 
#TR {(%d) bronze*({Kronars|Dokoras|Lirums}).} {#VAR bro%left(%2, 1) %1}
#TR {(%d) copper*({Kronars|Dokoras|Lirums}).} {#VAR cop%left(%2, 1) %1}
#TR {(%d) gold*({Kronars|Dokoras|Lirums}).} {#VAR gol%left(%2, 1) %1}
#TR {(%d) platinum*({Kronars|Dokoras|Lirums}).} {#VAR pla%left(%2, 1) %1}
#TR {(%d) silver*({Kronars|Dokoras|Lirums}).} {#VAR sil%left(%2, 1) %1}

#FUNC kronar {@copk + (@brok*10) + (@silk*100) + (@golk*1000) + (@plak*10000)}
#FUNC lirum {@copl + (@brol*10) + (@sill*100) + (@goll*1000) + (@plal*10000)}
#FUNC dokora {@copd + (@brod*10) + (@sild*100) + (@gold*1000) + (@plad*10000)}
_________________
Discord: Shalimarwildcat
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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