Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Turncoat
Newbie


Joined: 19 Sep 2011
Posts: 5

PostPosted: Mon Sep 19, 2011 12:19 am   

Incrementing a Variable
 
Sounds simple, or at least I thought it would be.

I have a class named Bottrix and that is where all of the scripts for this current project reside. Now, an alias is supposed to increase the variable "currentStep" by 1 each time the alias is used (the rest of the alias works, just the incrementing does not). I have tried several ways, and most of the time it creates a variable at the top level and increments that, which I don't want.

So my question is, how do I increment a variable by 1 in the current class (or a specific class)?


Currently I have cMUD 2.37. Maybe one day I will have money and be able to upgrade.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Sep 19, 2011 12:42 am   
 
You can use the absolute path of the variable: //module/class/.../class/variable. You can use relative paths too, so the variable in the current class would be ./variable.
Reply with quote
Turncoat
Newbie


Joined: 19 Sep 2011
Posts: 5

PostPosted: Mon Sep 19, 2011 1:12 am   
 
You wouldn't use the @ sign? Such as.. ./@variable , so it would just be ./variable ?

I also reread the MATH help file, and realized you could specify a class name at the end..

#MATH currentStep @currentStep+1 Bottrix

Ah, tired and scripting.. sometimes doesn't go that great together.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Mon Sep 19, 2011 2:01 am   
 
It would be @./variable, actually.
Reply with quote
Turncoat
Newbie


Joined: 19 Sep 2011
Posts: 5

PostPosted: Mon Sep 19, 2011 2:35 am   
 
ooooh, Thanks Daern!!
Reply with quote
Stowslee
Wanderer


Joined: 20 Apr 2008
Posts: 69
Location: Watervliet, NY

PostPosted: Fri Sep 30, 2011 10:56 am   
 
personally I always use

#var ThisVariable %eval(@ThisVariable +1)
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Fri Sep 30, 2011 1:55 pm   
 
In CMUD, you want to stay away from %eval as much as possible. CMUD is smarter about being able to evaluate things now. Using %eval does lag a bit more than just doing @var+1.
Reply with quote
Stowslee
Wanderer


Joined: 20 Apr 2008
Posts: 69
Location: Watervliet, NY

PostPosted: Sat Oct 01, 2011 12:49 am   
 
Glad I posted that, I have a bunch of aspects that rely on the %eval function. Thank you!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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