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
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Wed Jul 18, 2007 5:25 pm   

#if & #addkey variables (solved)
 
Running a mock battle and having problems with determining the end of the battle.

Assigning a test variable for the purpose of...well, testing..
#addkey testing Trollemite {50}
#addkey testing Vitae {50}


Part of the whole script includes deciding whom is attacking whom and for how much damage. This is part of it and it works:
#add testing.@{CombatantB} {-@howmuchdamage}

Now, the problem is this, once CombatantB reaches 0 or less how do i get it to know?
#if (@testing.@{CombatantB}.##### <= 0) {end} {continue}
.##### represents whatever should go there i guess.
I've tried %key, %iskey, %rec & %val all to no success.

Of course, I could have that #if slightly convoluted and have my whole thought on that wrong.
Crying or Very sad I feel like I should know this somehow, but I don't know Crying or Very sad
_________________
http://www.Aardwolf.com

Last edited by Vitae on Fri Jul 20, 2007 1:35 pm; edited 1 time in total
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Jul 18, 2007 5:57 pm   
 
I'm going to have to assume that the #addkey testing Trollemite {50} is the start damage. In which case you may want to use something like this:

#var Trollemite {%eval(%db(@testing.Trollemite)-@howmuchdamage)} - in place of #add testing.@{CombatantB} {-@howmuchdamage}

and

#IF (@Trollemite<=0) {end} {continue} - in place of #if (@testing.@{CombatantB}.##### <=0) {end} {continue}

Of course, if you want to remove the variable at the end, you can just use #unvar Trollemite.

I don't have zMUD in front of me, but I will tonight. It's touch and go right now, but give it a try and see if it works. Or don't. I'll just bug you on my flist later. :P

Charneus
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Wed Jul 18, 2007 6:12 pm   
 
#addkey testing Trollemite {50} is the start. Like starting with 50HP

I'm potentially going to have more than 2 Combatant's

I'm tracking everyones HP in the one var type created with #addkey so #add testing.@{CombatantB} {-@howmuchdamage} works much better than having separate variables for each combatant.

Hit me up on flist.
_________________
http://www.Aardwolf.com
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Jul 18, 2007 10:45 pm   
 
The problem, I think, is the implicit concatenation you're doing of the variable names. #add %concat("testing.",@CombatantB) whatever might give you better results.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Vitae
Enchanter


Joined: 17 Jun 2005
Posts: 673
Location: New York

PostPosted: Thu Jul 19, 2007 1:40 pm   
 
Got it!

#if (%db( @testing, @{CombatantB})<= 0) {end} {continue}
_________________
http://www.Aardwolf.com
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