Page 1 of 1

self.free_counters, self.free_flags request

Posted: Sun Sep 11, 2011 6:54 pm
by imaginethat
hi
I have a request, and hoping it is a small one that should be a simple addition to the pawn.lua file. OR, maybe I am going about things the wrong way.

I was wondering if the number of counters/flags/fields could be increase a bit.

As I am adding functionality to my bot as I learn how to do it, I am finding it harder to get my bot to keep track of things it needs to do at certain point in the game/map. Mainly when its time to go to a town and sell stuff, buy stuff, check mail, send mail, repair, check dailies, check quests etc etc, there is a "todo" list when in town.

I have no real clue how to implement local/global variables, so all my functions I treat as little isolated events, and create and reset variables when in that function, so when going from waypoint file to waypoint file etc, i am loosing track of what the bot is up to and what it needs to do, unless I constantly run the checks for all the things it may need to do before heading out of town.

I have not used the free_flags/counters, as there is only 3 of each, and would not really be enough to implement what I am thinking of trying (todo list that needs to be ticked off before leaving town).

Could the counters be increased to 10-15? It looks to me to be very easy to add these extra line (copy paste). but I do not know if that would have any impact on memory/loading times etc.

Thanks

Re: self.free_counters, self.free_flags request

Posted: Sun Sep 11, 2011 7:00 pm
by Administrator
Really, just assigning them should work. 'player.free_counter123456789 = 2' will create the variable and assign it to 2. If you rely on that variable, though, you should make sure it is actually available. For example:

Code: Select all

if( player.free_counter123456789 ~= nil ) then
  -- this counter actually has a value, so we can use it.
end

Re: self.free_counters, self.free_flags request

Posted: Sun Sep 11, 2011 7:04 pm
by imaginethat
wow, fast reply, thanks Administrator.
That sounds too easy ;-)

(just to clarify for ) So that variable would be "global" (not that I really understand what the 'really' means), so in the bot session I could go from waypoint file to waypoint file, any number of functions, and that variable (as long as I have created it) will be there, and only effected by what I directly assign to it?
awesome, that means I have an endless todo list capability.

Thanks again

Re: self.free_counters, self.free_flags request

Posted: Sun Sep 11, 2011 7:49 pm
by Administrator
Well, the player object is global, so any variables inside it will also be available globally through the player object (unless it is a local variable inside a function, but don't worry about that). Short answer is, yes.