Need help declaring a new Variable

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
mannimal
Posts: 1
Joined: Thu Jan 28, 2010 6:39 pm

Need help declaring a new Variable

#1 Post by mannimal »

Ah.... ok........ i am new to micromakro and sadly programming isn't my forte.

atm. I am doing a script that logs out, selects a new character, logs in, lvls him up to lvl 10 , logs out, picks a new etc.

What i need now is some kind of global variable which i want to use as a counter so that the same character doesn't get
picked twice. An Integer-Type, that i can access and change from the waypoint.xml.
Everything else is pretty easy, but where do i declare this variable? how can i read it? how can i change it ?

so if a character becomes lvl 10 and goes whereever he should, then:

CHARNUMBER = CHARNUMBER + 1 ............or something like that

and for picking a new character:

if (CHARNUMBER == 1) then
blablabla;
end;
if(CHARNUMBER == 2) then
andsoon.............

i am greatful for any directions :mrgreen:
User avatar
Administrator
Site Admin
Posts: 5353
Joined: Sat Jan 05, 2008 4:21 pm

Re: Need help declaring a new Variable

#2 Post by Administrator »

You could put CHARNUMBER = 0 at the top of rom/bot.lua, if you want. Unless it says 'local' in front of the variable, it's global. Variables in Lua do not need to be specifically declared; they will be created when you use them.

If you wanted to get fancy, you could even do this inside just your waypoint scripts:

Code: Select all

CHARNUMBER = CHARNUMBER or 0; -- if CHARNUMBER hasn't been created yet, create it and set it to 0.

-- do something with it

CHARNUMBER = CHARNUMBER + 1; -- increment
There's also 'free' variables built into the player class. You could use player.free_counter1 instead of CHARNUMBER. It's already created for you.
Post Reply