Incrementing Variables

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot.

Moderator: MacroQuest Developers

Meatball
orc pawn
orc pawn
Posts: 14
Joined: Sun Feb 22, 2004 8:39 am

Incrementing Variables

Post by Meatball » Tue Apr 27, 2004 7:08 pm

I ran into problems using /varadd to increment variables. It seemed to work for a while, but a few minutes into the script, the numeric values would become floating point numbers instead of integers. I got it fixed and thought I'd post my solution here.

Old Code

Code: Select all

/varadd intCounter 1
New Code

Code: Select all

/varset intCounter ${Math.Calc[@intCounter+1].Int}
Hope this helps someone out.

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Tue Apr 27, 2004 7:27 pm

you could just declare your variable as an int, with mq2datavars

/declare intCounter int
/varcalc intCounter ${intCounter}+1
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

Meatball
orc pawn
orc pawn
Posts: 14
Joined: Sun Feb 22, 2004 8:39 am

Post by Meatball » Wed Apr 28, 2004 7:18 am

Sorry Lax, didn't know the new variable declarations were live yet. Hell, I would've used the new variables in all my macro conversions if I'd realized that. Oh well, something to update today while offset are being found.