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
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Mon Apr 26, 2004 6:15 am   

Script to look through receipts
 
I've got this script i'm working on to look through large numbers of receipts. I've got it working so that I can look through the receipts for one item at a time, but now i really want it to be able to look through and get out the receipts for a full armor set. (receipts are a way to store equipment, kinda, and you can only see what they're for by looking at them individually).

Here is the script I have so far, feel free to suggest ways to clean it up :D

#CLASS {Misc|Chest stuff}
#ALIAS golooking {
#IF (@tofind < 29) {
#T+ rt1
#LOOP %sum( @tofind + 1) {take receipt @rcontain}
} {
#T+ rt2
#LOOP 29 {take receipt @rcontain}
}
}
#VAR rcontain {pack}
#VAR receiptitem {thick}
#VAR tofind {90}
#VAR whatrfor {a pair of thick metal boots|a pair of ebony-steel plate vambraces|a shining steel breastplate|a pair of ebony-steel plate greaves|a pair of heavy metal gauntlets}
#VAR foundreceipt {1}
#VAR numon {1} {1}
#VAR fullabs {a pair of thick metal boots|a full metal helmet and visor|a shining steel breastplate|a pair of ebony-steel plate vambraces|a pair of ebony-steel plate greaves|a pair of heavy metal gauntlets}
#ONINPUT {getreceipt (%w) (*)} {
foundreceipt = 0
rcontain = %1
receiptitem = %2
#VAR whatrfor ""
#VAR tofind ""
exa %1
}
#TRIGGER "receipttrigger" {~[(%d)~] a receipt} {tofind = %1}
#TRIGGER {It is a receipt for (*) from (*).} {whatrfor = %1}
#TRIGGER "rt2" {a receipt: You can't carry that many items.} {
inventory
#VAR numon 1
#UNTIL {(@foundreceipt = 1) OR (@numon = 29)} {
exa @numon~.receipt
#ADD numon 1
#WAIT 1000
}
#IF (@foundreceipt = 1) {
#ADD numon -1
#IF (@rcontain = "pack") {
put @numon~.receipt 2.pack
#loop (@tofind - 1) {put receipt @rcontain}
} {
put @numon~.receipt pack
#loop (@tofind - 1) {put receipt @rcontain}
}
} {
#ECHO No @receiptitem found.
#IF (@rcontain = pack) {#LOOP @tofind {put receipt 2.pack}} {#LOOP @tofind {put receipt pack}}
exa @rcontain
golooking
}
#T- rt2
} "" {disable}
#TRIGGER "rt1" {There doesn't seem to be a receipt in a (*).} {
inventory
#VAR numon 1
#UNTIL (@foundreceipt = 1) {
exa @numon~.receipt
#ADD numon 1
#WAIT 1000
}
#IF (@foundreceipt = 1) {
#ADD numon -1
#IF (@rcontain = "pack") {
put @numon~.receipt 2.pack
#loop (@tofind - 1) {put receipt @rcontain}
} {
put @numon~.receipt pack
#loop (@tofind - 1) {put receipt @rcontain}
}
} {#ECHO No @receiptitem found.}
#T- rt1
} "" {disable}
#TRIGGER {{@receiptitem}} {foundreceipt = 1}
#CLASS 0


I have the list of a full armor set under the variable @fullabs. Now i just need to figure out how to get it to go through until it comes to one of the items, put that receipt in my pack, delete that item from the list, then keep going, looking for the other items. Not sure exactly how to go about this...
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 313
Location: Australia

PostPosted: Mon Apr 26, 2004 12:07 pm   
 
Try this:

#CLASS {Misc|Chest stuff}
#alias getreceipt {#var RContain "%1"
#VAR whatrfor %null
#VAR RCount 0
#var LookList "%-2"
get receipt @RContain
exa receipt
#TRIGGER {It is a receipt for (*) from *.} {whatrfor = %1
#IF (%ismember(@WhatrFor,@LookList)) {#delitem LookList "@WhatrFor"
#IF (@rcontain = "pack") {put receipt 2.pack} {put receipt pack}
get @RCount.receipt @RContain
exa receipt} {#IF (@rcontain = "pack") {put receipt pack} {put receipt 2.pack}
#add RCount 1
get @RCount.receipt @RContain
exa receipt}}}
#class 0

To use: GetReceipt <ReceiptContainer> <List of Armor to Find>
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