Page 1 of 1

Where do I place the code snippet from the Wiki-XP per Hr

Posted: Tue Oct 27, 2009 12:29 pm
by Leopardfist
I found the snippet of code from the wiki for showing exp per hour, and I understand it goes into the bot.lua script, but where in the script should I paste it?

I have line numbers in my VS turned on, so you can give me a line number area and tell me before such and such or whatever. Id LOVE to have this ability, but dont wanna mess around with the script blindly.

Thanks!

<EDIT>

i TRIED PLACING THE CODE INTO THE BOT.LUA SCRIPT AND GOT AN ERROR FOR THE LAST LINE OF CODE.

'>' expected near 'expPerMin'

It could also be a ')', cant really tell.

The code I used is:

Code: Select all

local expGained = 0;
local startTime = os.time();
local lastAnnounce = os.time();
 
local lastTotalExp = 0;
while(true) do
  local newTotalExp = memoryReadInt(proc, experienceaddr, experience_offset);
  if( newTotalExp > lastTotalExp ) then
    expGained = expGained + (newTotalExp - lastTotalExp);
  end
 
  -- has 10 seconds elapsed? update the exp/min
  if( os.difftime(os.time(), lastAnnounce) > 10 ) then
    local timeElapsed = os.difftime(os.time(), startTime);
    local expPerMin = 0;
    if( timeElapsed == 0 ) then timeElapsed = 1; end; -- prevent division by zero
 
    expPerMin = expGained/(timeElapsed/60.0);
    lastAnnounce = os.time();
    printf("Exp/min: %0.1f\n" expPerMin);
  end
 
end

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Tue Oct 27, 2009 1:46 pm
by d003232
Leopardfist wrote:

Code: Select all

printf("Exp/min: %0.1f\n" expPerMin);
That line should be

Code: Select all

printf("Exp/min: %0.1f\n", expPerMin);

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Tue Oct 27, 2009 8:22 pm
by Leopardfist
OK, now I get the error:

scripts\rom/bot.lua:466: Wrong number of parameters supplied to memoryReadInt().

Code: Select all

 local newTotalExp = memoryReadInt(proc, experienceaddr, experience_offset);

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Wed Oct 28, 2009 1:47 am
by d003232
Leopardfist wrote:OK, now I get the error:

scripts\rom/bot.lua:466: Wrong number of parameters supplied to memoryReadInt().

Code: Select all

 local newTotalExp = memoryReadInt(proc, experienceaddr, experience_offset);
I don't know, what you want to do with that coding? It's not from/for the RoM Bot. There are no memory adresses for 'experience' defined. Perhaps you should look for a ingame addon?

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Wed Oct 28, 2009 11:04 am
by Leopardfist
d003232 wrote:
Leopardfist wrote:OK, now I get the error:

scripts\rom/bot.lua:466: Wrong number of parameters supplied to memoryReadInt().

Code: Select all

 local newTotalExp = memoryReadInt(proc, experienceaddr, experience_offset);
I don't know, what you want to do with that coding? It's not from/for the RoM Bot. There are no memory adresses for 'experience' defined. Perhaps you should look for a ingame addon?

It's from your Wiki!

http://www.solarstrike.net/wiki/index.p ... e=Snippets

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Wed Oct 28, 2009 11:58 am
by d003232
Leopardfist wrote:It's from your Wiki!

http://www.solarstrike.net/wiki/index.p ... e=Snippets
That are examplex how to do some tasks with the micromacro environment. But they are no ready to use within the RoM Bot, perhaps they are even not usefull or practicable within the bot.

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Wed Oct 28, 2009 12:36 pm
by Administrator
That code there is meant to be a general example. If I remember correctly, some user asked about how to do that in another game, for which I provided that example.

If you can provide offsets for exp/total exp, I can add this to the bot.

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Wed Nov 04, 2009 8:23 pm
by j_schlott
im not sure how i would find offsets, but theres functions to return current exp and max exp

Code: Select all

GetPlayerExp()
GetPlayerMaxExp()

Re: Where do I place the code snippet from the Wiki-XP per Hr

Posted: Thu Nov 05, 2009 4:56 pm
by Administrator
This has been added in r394.