How exactly does a local variable gets increased?

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

How exactly does a local variable gets increased?

#1 Post by botje »

i have a waypoint thats basicly a round of harvesting.

i want to do this 3 times, then move away to dump.

so i do know i use Local Counter

but how do i increase the Counter variable after a round? is it as in other languages?

so counter = counter +1?

any help is apriciated ^^

Botje
User avatar
Giram
Posts: 191
Joined: Thu Aug 26, 2010 3:34 pm
Location: Finland

Re: How exactly does a local variable gets increased?

#2 Post by Giram »

I have done it like this:

Code: Select all

player.free_counter1 = player.free_counter1 + 1;
I am not sure if its possible to do shorter way:

Code: Select all

player.free_counter1 =+ 1;
or is is +=? I never remember. =+ would be more logical tho.
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How exactly does a local variable gets increased?

#3 Post by rock5 »

I never heard of that being available in lua.

Just tried both. Neither works.

We'll just have to do it the long way.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
Administrator
Site Admin
Posts: 5353
Joined: Sat Jan 05, 2008 4:21 pm

Re: How exactly does a local variable gets increased?

#4 Post by Administrator »

The += operator is not available in Lua. =+ would not be more logical because it would be a parsing nightmare. You could not differentiate when it means to increment and when to assign. For example:

Code: Select all

var=+1
Should var be var + 1, or should it be assigned to +1?
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: How exactly does a local variable gets increased?

#5 Post by botje »

Code: Select all

<onLoad>
		player.free_counter1 = 0;
		
		function Return()
			printf("Counter:  "..player.free_counter1.."\n");
			if player.free_counter1 > 2 then
				printf("Done our rounds, loading new waypoints..."\n");
				loadPaths("DragonFang/FromDragonFang");
			else
				player.free_counter1 = player.free_counter1 +1;
			end
		end
		
		settings.profile.options.WAYPOINT_DEVIATION = 50;
	</onLoad>
says it cant parse it, wtf am i doing wrong then?

Botje
User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: How exactly does a local variable gets increased?

#6 Post by rock5 »

Code: Select all

printf("Done our rounds, loading new waypoints..."\n");
Maybe that line?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan
User avatar
botje
Posts: 656
Joined: Wed Oct 27, 2010 7:17 am

Re: How exactly does a local variable gets increased?

#7 Post by botje »

ooooh, that extra " ? xd

damn it :roll:

Botje
Post Reply