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
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Fri Apr 27, 2007 2:16 pm   

[1.30] Somethng weird with #FORALL and my local variable
 
I've been scratching my head for about an hour over this one, and I still see nothing wrong with my code. I'm wondering if anyone else can see something wrong or maybe this is a bug.

I have an alias to loop and check a data record variable to find the body part with the most deep wounds. My echo message tells me that the left leg is the only one with any wounds (525, in this test), but the local variable still ends up with "leftarm" in it instead. Now, "leftarm" is the last one in the loop iteration, so I'm thinking something's happening to the stack after the loop?

Code:
#ALIAS i_woundhealing {
$wound_heal = "head"
$wounding = @woundamt($wound_heal)
#FORALL {chest|gut|rightleg|leftleg|rightarm|leftarm} {
  $cwound = @woundamt(%i)
  #IF ($cwound > $wounding) {
    #SAY "Compare: "$wound_heal" at "$wounding" to "%i" at "$cwound
    $wound_heal = %i
    $wounding = $cwound
  }
}
#SAY "You should heal your "$wound_heal
}


@woundamt is a custom function that returns 0 if the key doesn't exist or the value or the key if it does exist.
@wounds is a data record variable that had only one key/value pair ("leftleg" => 525).

The output I get from running this is simply:
Compare: head at 0 to leftleg at 525
You should heal your leftarm

Help?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Apr 27, 2007 4:18 pm   
 
Try running this same test with the following change.

$wounding = @woundamt($wound_heal)
To
$wounding = @woundamt("head")

Tell us if the result is the same.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Apr 27, 2007 4:28 pm   
 
It would also be interesting to see the results of saying $cwound after you set it.

#say "Wound damage to the "%i" is "$cwound
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
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