|
Turncoat Newbie
Joined: 19 Sep 2011 Posts: 5
|
Posted: 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. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: 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.
|
|
|
|
Turncoat Newbie
Joined: 19 Sep 2011 Posts: 5
|
Posted: 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. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Sep 19, 2011 2:01 am |
It would be @./variable, actually.
|
|
|
|
Turncoat Newbie
Joined: 19 Sep 2011 Posts: 5
|
Posted: Mon Sep 19, 2011 2:35 am |
ooooh, Thanks Daern!!
|
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: Fri Sep 30, 2011 10:56 am |
personally I always use
#var ThisVariable %eval(@ThisVariable +1) |
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: 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.
|
|
|
|
Stowslee Wanderer
Joined: 20 Apr 2008 Posts: 69 Location: Watervliet, NY
|
Posted: 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!
|
|
|
|
|
|