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
Darkwytch
Novice


Joined: 20 Feb 2004
Posts: 41
Location: USA

PostPosted: Fri Jan 21, 2005 10:00 am   

problem counting and buying...
 
I am haveing a problem with a script that i have that will buy me reagents and put them into contianers that i have designated... I continously buys more then what i need instead of only buying the exact amount of what i need.. could someone help me and tell me what i did wrong with it?



Code:


#CLASS {Completed Scripts|Reagents|Reagent Buying}
#ALIAS airreagcheck {#T+ airreagcheck
look in 3.gnomish}
#ALIAS earthreagcheck {#T+ earthreagcheck
look in 2.gnomish}
#ALIAS firecheck {#T+ firecheck
l 4.gnomish}
#ALIAS waterreagcheck {#T+ waterreagcheck
look in 5.gnomish}
#ALIAS etherealreagcheck {#T+ etherealreagcheck
look in 7.gnomish}
#ALIAS gemcheck {#T+ gemcheck
look in 6.gnomish}
#VARIABLE earthreagneed {0}
#VARIABLE earthreagbuyfull {0}
#VARIABLE earthreageednotfull {0}
#VARIABLE earthreagtotal {103}
#VARIABLE airreagneed {0}
#VARIABLE airreagbuyfull {0}
#VARIABLE airreagneednotfull {0}
#VARIABLE airreagtotal {103}
#VARIABLE waterreagneed {0}
#VARIABLE waterreagbuyfull {0}
#VARIABLE waterreagneednotfull {0}
#VARIABLE waterreagtotal {103}
#VARIABLE etherealreagtotal {0}
#VARIABLE etherealreagneed {0}
#VARIABLE etherealreagneednotfull {3}
#VARIABLE seedtotal {0}
#VARIABLE gemneed {0}
#VARIABLE gemneednotfull {0}
#VARIABLE gembuyfull {0}
#VARIABLE firereagtotal {}
#VARIABLE firereagneed {}
#VARIABLE firereagneednotfull {}
#VARIABLE firereagbuyfull {}
#CLASS 0
#CLASS {Completed Scripts|Reagents|Reagent Buying|earthreagcheck} {disable}
#TRIGGER {~((%d)~) a mandrake leaf} {#VARIABLE earthreagneed 0
#VARIABLE earthreagbuyfull 0
#VARIABLE earthreagneednotfull 0
#VARIABLE earthreagtotal 0
#VARIABLE earthreagtotal %1
#MATH earthreagneed (103-@earthreagtotal)
#MATH earthreagbuyfull (@earthreagneed/20)
#VARIABLE earthreagneednotfull %mod( @earthreagneed, 20)
#REPEAT @earthreagbuyfull {shop buy 20 leaf
put all.reagent-earth 2.gnomish}
shop buy @earthreagneednotfull leaf
put all.reagent-earth 2.gnomish
#T- earthreagcheck}
#TRIGGER {~((%s)(%d)~) a mandrake leaf} {#VARIABLE earthreagneed 0
#VARIABLE earthreagbuyfull 0
#VARIABLE earthreagneednotfull 0
#VARIABLE earthreagtotal 0
#VARIABLE earthreagtotal %1
#MATH earthreagneed (103-@earthreagtotal)
#MATH earthreagbuyfull (@earthreagneed/20)
#VARIABLE earthreagneednotfull %mod( @earthreagneed, 20)
#REPEAT @earthreagbuyfull {shop buy 20 leaf
put all.reagent-earth 2.gnomish}
shop buy @earthreagneednotfull leaf
put all.reagent-earth 2.gnomish
#T- earthreagcheck}
#CLASS 0
#CLASS {Completed Scripts|Reagents|Reagent Buying|waterreagcheck} {disable}
#TRIGGER {~((%d)~) a shimmering white fish scale} {#VARIABLE waterreagneed 0
#VARIABLE waterreagbuyfull 0
#VARIABLE waterreagneednotfull 0
#VARIABLE waterreagtotal 0
#VARIABLE waterreagtotal %1
#MATH waterreagneed (103-@waterreagtotal)
#MATH waterreagbuyfull (@waterreagneed/20)
#VARIABLE waterreagneednotfull %mod( @waterreagneed, 20)
#REPEAT @waterreagbuyfull {shop buy 20 scale
put all.reagent-water 5.gnomish}
shop buy @waterreagneednotfull scale
put all.reagent-water 5.gnomish
#T- waterreagcheck}
#TRIGGER {~((%s)(%d)~) a shimmering white fish scale} {#VARIABLE waterreagneed 0
#VARIABLE waterreagbuyfull 0
#VARIABLE waterreagneednotfull 0
#VARIABLE waterreagtotal 0
#VARIABLE waterreagtotal %1
#MATH waterreagneed (103-@waterreagtotal)
#MATH waterreagbuyfull (@waterreagneed/20)
#VARIABLE waterreagneednotfull %mod( @waterreagneed, 20)
#REPEAT @waterreagbuyfull {shop buy 20 scale
put all.reagent-water 5.gnomish}
shop buy @waterreagneednotfull scale
put all.reagent-water 5.gnomish
#T- waterreagcheck}
#CLASS 0
#CLASS {Completed Scripts|Reagents|Reagent Buying|airreagcheck} {disable}
#TRIGGER {~((%d)~) a feather from a roc} {#VARIABLE airreagneed 0
#VARIABLE airreagbuyfull 0
#VARIABLE airreagneednotfull 0
#VARIABLE airreagtotal 0
#VARIABLE airreagtotal %1
#MATH airreagneed (103-@airreagtotal)
#MATH airreagbuyfull (@airreagneed/20)
#VARIABLE airreagneednotfull %mod( @airreagneed, 20)
#REPEAT @airreagbuyfull {shop buy 20 roc
put all.roc 3.gnomish}
shop buy @airreagneednotfull roc
put all.roc 3.gnomish
#T- airreagcheck}
#TRIGGER {~((%s)(%d)~) a feather from a roc} {#VARIABLE airreagneed 0
#VARIABLE airreagbuyfull 0
#VARIABLE airreagneednotfull 0
#VARIABLE airreagtotal 0
#VARIABLE airreagtotal %1
#MATH airreagneed (103-@airreagtotal)
#MATH airreagbuyfull (@airreagneed/20)
#VARIABLE airreagneednotfull %mod( @airreagneed, 20)
#REPEAT @airreagbuyfull {shop buy 20 roc
put all.roc 3.gnomish}
shop buy @airreagneednotfull roc
put all.roc 3.gnomish
#T- airreagcheck}
#CLASS 0
#CLASS {Completed Scripts|Reagents|Reagent Buying|gemcheck} {disable}
#TRIGGER {~((%d)~) a petrified seed} {#VARIABLE gemneed 0
#VARIABLE gembuyfull 0
#VARIABLE gemneednotfull 0
#VARIABLE gemtotal 0
#VARIABLE gemtotal %1
#MATH gemneed (103-@gemtotal)
#MATH gembuyfull (@gemneed/20)
#VARIABLE gemneednotfull %mod( @gemneed, 20)
#REPEAT @gembuyfull {shop buy 20 seed
put all.gem 6.gnomish}
shop buy @gemneednotfull seed
put all.gem 6.gnomish
#T- gemcheck}
#TRIGGER {^Vandemaar's Trunk is an enchanted piece of furniture,} {#T- trunkthree} "" {disable}
#TRIGGER {~((%s)(%d)~) a petrified seed} {#VARIABLE gemneed 0
#VARIABLE gembuyfull 0
#VARIABLE gemneednotfull 0
#VARIABLE gemtotal 0
#VARIABLE gemtotal %1
#MATH gemneed (103-@gemtotal)
#MATH gembuyfull (@gemneed/20)
#VARIABLE gemneednotfull %mod( @gemneed, 20)
#REPEAT @gembuyfull {shop buy 20 seed
put all.gem 6.gnomish}
shop buy @gemneednotfull seed
put all.gem 6.gnomish
#T- gemcheck}
#CLASS 0
#CLASS {Completed Scripts|Reagents|Reagent Buying|etherealreagcheck} {disable}
#TRIGGER {~((%d)~) a soul in a bottle} {#VARIABLE etherealreagneed 0
#VARIABLE etherealreabuyfull 0
#VARIABLE etherealreagneednotfull 0
#VARIABLE etherealreagtotal 0
#VARIABLE etherealreagtotal %1
#MATH etherealreagneed (103-@etherealreagtotal)
#MATH etherealreagbuyfull (@etherealreagneed/20)
#VARIABLE etherealreagneednotfull %mod( @etherealreagneed, 20)
#REPEAT @etherealreagbuyfull {shop buy 20 soul
put all.reagent-ethereal 7.gnomish}
shop buy @etherealreagneednotfull soul
put all.reagent-ethereal 7.gnomish
#T- etherealreagcheck}
#TRIGGER {^Vandemaar's Trunk is an enchanted piece of furniture,} {#T- trunkthree2} "" {disable}
#TRIGGER {~((%s)(%d)~) a soul in a bottle} {#VARIABLE etherealreagneed 0
#VARIABLE etherealreabuyfull 0
#VARIABLE etherealreaneednotfull 0
#VARIABLE etherealreagtotal 0
#VARIABLE etherealreagtotal %1
#MATH etherealreagneed (103-@etherealreagtotal)
#MATH etherealreagbuyfull (@etherealreagneed/20)
#VARIABLE etherealreagneednotfull %mod( @etherealreagneed, 20)
#REPEAT @etherealreagbuyfull {shop buy 20 soul
put all.reagent-ethereal 7.gnomish}
shop buy @etherealreagneednotfull soul
put all.reagent-ethereal 7.gnomish
#T- etherealreagcheck}
#CLASS 0
#CLASS {Completed Scripts|Reagents|Reagent Buying|firereagcheck} {disable}
#TRIGGER {~((%d)~) a pinch of sulfur} {#VARIABLE firereagneed 0
#VARIABLE firereagbuyfull 0
#VARIABLE firereagneednotfull 0
#VARIABLE firereagtotal 0
#VARIABLE firereagtotal %1
#MATH firereagneed (103-@firereagtotal)
#MATH firereagbuyfull (@firereagneed/20)
#VARIABLE firereagneednotfull %mod( @firereagneed, 20)
#REPEAT @firereagbuyfull {shop buy 20 sulfur
put all.sulfur 4.gnomish}
shop buy @firereagneednotfull sulfur
put all.sulfur 4.gnomish
#T- firereagcheck} "" {disable}
#TRIGGER {~((%s)(%d)~) a pinch of sulfur} {#VARIABLE firereagneed 0
#VARIABLE firereagbuyfull 0
#VARIABLE firereagneednotfull 0
#VARIABLE firereagtotal 0
#VARIABLE firereagtotal %1
#MATH firereagneed (103-@firereagtotal)
#MATH firereagbuyfull (@firereagneed/20)
#VARIABLE firereagneednotfull %mod( @firereagneed, 20)
#REPEAT @firereagbuyfull {shop buy 20 sulfur
put all.sulfur 4.gnomish}
shop buy @firereagneednotfull sulfur
put all.sulfur 4.gnomish
#T- firereagcheck} "" {disable}
#CLASS 0
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5187

PostPosted: Fri Jan 21, 2005 10:44 am   
 
I would start by eliminating some duplication and add some braces. Also I believe repeat will do things once even if it is given a value of 0 for count, use #WHILE instead. The addition of a few #IFs will make things even better. Finally cut the size of the script in half by improving your pattern. I only did the earth one:
#CLASS {Completed Scripts|Reagents|Reagent Buying|earthreagcheck} {disable}
#TRIGGER {~(([ 0123456789])~) a mandrake leaf} {#VARIABLE earthreagneed 0
#VARIABLE earthreagbuyfull 0
#VARIABLE earthreagneednotfull 0
#VARIABLE earthreagtotal {%1}
#MATH earthreagneed (103-@earthreagtotal)
#IF (@earthreagneed) {#MATH earthreagbuyfull (@earthreagneed/20)
#VARIABLE earthreagneednotfull %mod( @earthreagneed, 20)
#WHILE (@earthreagbuyfull) {shop buy 20 leaf
#ADD @earthreagbuyfull -1}
#IF (@earthreagneednotfull) {shop buy @earthreagneednotfull leaf}
put all.reagent-earth 2.gnomish}
#T- earthreagcheck}
#CLASS 0
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Darkwytch
Novice


Joined: 20 Feb 2004
Posts: 41
Location: USA

PostPosted: Sun Jan 23, 2005 6:44 pm   
 
Thank you that worked out great
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Fri Jan 28, 2005 9:28 pm   
 
can cut out a few variables using something like:
Code:
#CLASS {Completed Scripts|Reagents|Reagent Buying|earthreagcheck} {disable}
#TRIGGER {~(([ 0123456789])~) a mandrake leaf} {  #VAR earthreagtotal {%1}
#WHILE (@earthreagtotal < 103) { #var buying %eval(103-@earthreagtotal)
#var buying %if(@buying > 20,20,@buying)
shop buy @buying leaf
#ADD earthreagtotal @buying}
put all.reagent-earth 2.gnomish
T- earthreagcheck}
#CLASS 0
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
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