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 » Fri Dec 03, 2010 4:09 am

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 » Fri Dec 03, 2010 5:12 am

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 » Fri Dec 03, 2010 6:35 am

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: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: How exactly does a local variable gets increased?

#4 Post by Administrator » Fri Dec 03, 2010 2:41 pm

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 » Tue Dec 07, 2010 9:54 am

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 » Tue Dec 07, 2010 11:02 am

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 » Tue Dec 07, 2010 11:04 am

ooooh, that extra " ? xd

damn it :roll:

Botje

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests