|
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Mon Jan 29, 2007 6:22 am
Seem to have a bug in my list management, help! |
Pretty simple, in this world there are "teleport pills" they have to be from the same type of location to work. So city to city location is possible, not city to forest or whatever. When I check teleportlist I get a list of pills in my hands. The list seems to build up fine, but when I try to use my ailias to use a "city pill" it gets mixed up. First of all it starts out without a value so its just sending the comman get blank from sack; eat blank (so it does notta) then from there it seems to jump around the list from item 1 to 3 then back to 2 then to 4 and finally, it doesnt know when I'm out of pills. Very annoying. Someone help please.
command: teleportlist
Pattern: ^Pill(%d)(%s)Image: Center Square.
Value: citypill = %1; #additem citylist pill@citypill
ailias: CPILL
get %item( @citylist, @citycount) from sack
eat %item( @citylist, @citycount)
#if (@citycount >= (%numitems( @citylist))) {@citycount = 0}
#delitem citylist %item( @citylist, @citycount)
#add citycount 1
#if (%numitems( @citylist)=0) {#say YOU ARE OUT OF CITY PILLS!} |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Mon Jan 29, 2007 2:41 pm |
Instead of bug-fixing, how about just:
get @citylist.1 from sack
eat %pop(citylist)
#if (!@citylist) {#show Out of pills.}
Although if you really want to bug fix I'm guessing that the errors are: you start off with citycount = 0 (after you run out of pills), so it's trying to get the 0th item from the list, except ZMud starts the count at 1, there is no 0th item. And then you add to citycount while you -remove- an item from the list, which is a logic error--since city count = 1 at the first working instance, and then you delete the first entry, that means the new first entry is actually an unused pill anyway (previously #2 in the list). |
|
|
|
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Mon Jan 29, 2007 4:41 pm I like your version much better! |
I like your version much better! I'm not sure what all those commands do yet, but I'm looking them up. That seems to be much simpler and less prone to errors. I'm looking into where my logic broke too, thanks a lot gamma_ray.
|
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Mon Jan 29, 2007 5:02 pm |
No problem, just ask if you've got more questions.
|
|
|
|
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Mon Jan 29, 2007 5:21 pm Hate to be nit picky |
Once the list is depleted the ailias still tries to get (blank) from sack and eat (blank). Only problem I could see is within the mudd itself. This act could break certain defences. Is there anyway to get it to not attempt any action when the list is empty? If not that is still really nifty and works much better than what I was using. Cheers.
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Jan 29, 2007 5:37 pm |
Try this:
#if (@CityList) {get @citylist.1 from sack;eat %pop(citylist)} {#show Out of pills!} |
|
|
|
dazed-n-confused999 Wanderer
Joined: 03 Aug 2004 Posts: 79
|
Posted: Mon Jan 29, 2007 6:30 pm That is solid! |
I had to make the get pill from sack and eat pill part a seperate ailias for the if statement, proabably my lack of zmud knowlege. Now with that working and changing #if (!@citylist) {#show Out of pills.} to read that was the last pill you just ate, that is going to work like solid gold. Thanks both of you
|
|
|
|
|
|