Page 1 of 1
How exactly does a local variable gets increased?
Posted: Fri Dec 03, 2010 4:09 am
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
Re: How exactly does a local variable gets increased?
Posted: Fri Dec 03, 2010 5:12 am
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:
or is is +=? I never remember. =+ would be more logical tho.
Re: How exactly does a local variable gets increased?
Posted: Fri Dec 03, 2010 6:35 am
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.
Re: How exactly does a local variable gets increased?
Posted: Fri Dec 03, 2010 2:41 pm
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:
Should var be var + 1, or should it be assigned to +1?
Re: How exactly does a local variable gets increased?
Posted: Tue Dec 07, 2010 9:54 am
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
Re: How exactly does a local variable gets increased?
Posted: Tue Dec 07, 2010 11:02 am
by rock5
Code: Select all
printf("Done our rounds, loading new waypoints..."\n");
Maybe that line?
Re: How exactly does a local variable gets increased?
Posted: Tue Dec 07, 2010 11:04 am
by botje
ooooh, that extra " ? xd
damn it
Botje