Page 1 of 3
Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 10:44 am
by Yoder
Can I add something to my waypoints to make Rom bot show in the window title what Ive gathered so far vs how much exp Ive earner
Idealy I would have it say
RoM Bot Player****(Gathered #Number Gathered# "Item monitored")
Item monitored could be staticaly assigned so only 1 number would change
Currently it says something like
RoM Bot Player**** (exp ####/HR)
Not at home rite now but I think Thats about right.
This could be used to monitor items gathered using Harvest waypoints, Gold for Clops KS, and Eggs too. Im sure their are other uses.
Please let me know if this is already available otherwise if it can be made
Yoder
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 1:02 pm
by kanta
Check this thread started by Lisa:
http://www.solarstrike.net/phpBB3/viewt ... =27&t=2034
It tracks some character info and gold gained. Maybe you could modify it for what you want.
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 2:37 pm
by Yoder
This could work for what I want.
If I can find where the current window title is defined I can work from there.
Any help please,
Thanks
Yoder
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 3:59 pm
by Yoder
Code: Select all
-- Set window name, install timer to automatically do it once a second
local displayname = string.sub(load_profile_name, 1, 4) .. "****";
setWindowName(getHwnd(), sprintf("RoM Bot %s [%s]", BOT_VERSION, displayname));
settings.loadProfile(load_profile_name);
settingsPrintKeys(); -- print keyboard settings to MM and log
registerTimer("timedSetWindowName", secondsToTimer(1), timedSetWindowName, load_profile_name);
player.BotStartTime_nr = os.time(); -- remember bot start time no reset
player.level_detect_levelup = player.Level; -- remember actual player level
store = CStore()
Ok,
Ive found this in bot.lua and I think this is where it is setting the window name (probably why it says set window name) can I change this in a profile after its been set? or would I need to edit it here to make it an option first?
I was thinking their would need to be an option to read Inventory rather than read EXP.
Not asking for it to be done for me tho, Id like to work through this and actually see it happen, so just lookin for a nudge in the right direction here
Yoder
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 7:58 pm
by Yoder
Code: Select all
local LAST_PLAYER_X = 0;
local LAST_PLAYER_Z = 0;
function timedSetWindowName(profile)
local displayname = string.sub(profile, 1, 4) .. "****";
if( (player.X ~= LAST_PLAYER_X) or (player.Z ~= LAST_PLAYER_Z) ) then
setWindowName(getHwnd(), sprintf(language[600],
BOT_VERSION, displayname, player.X, player.Z, player.ExpPerMin, player.TimeTillLevel));
LAST_PLAYER_X = player.X;
LAST_PLAYER_Z = player.Z;
end
end
So where is the formula for player.ExpPerMin and player.TimeTillLevel
I assume as this refreshes when player coords change that this is where I want to make my changes
Now I can use help XD
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 8:36 pm
by lisa
Code: Select all
setWindowName(getHwnd(), sprintf(language[600],
BOT_VERSION, displayname, player.X, player.Z, player.ExpPerMin, player.TimeTillLevel));
This is what is doing the text on your window, alter that and you alter what is being shown.
This should change the text to I like monkeys
Code: Select all
setWindowName(getHwnd(), "I like monkeys")
Does that help you?
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 9:21 pm
by rock5
To put this into practic, I wonder if you could just replace the timedSetWindowName function somewhere in your own code. Then when the timer calls for it, it runs your version. I don't know if that would work but it's worth trying.
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 10:27 pm
by Yoder
Code: Select all
storecharinfo(player.Name,"Eggs,"..inventory:itemTotalCount(204792)..",Cakes,"..inventory:itemTotalCount(204791))
So I have the addon working to store the character info, but how can I use this same string to show counts on the window
Code: Select all
setWindowName(getHwnd(), sprintf(language[600],
BOT_VERSION, displayname, player.X, player.Z, player.ExpPerMin, player.TimeTillLevel));
This is good string of code and if I could repurpose the calculations and put them into a new addon much like the first string of code has its own addon, then I could end up with something like
Code: Select all
if( os.difftime(os.time(), self.LastExpUpdateTime) > self.ExpUpdateInterval ) then
--local newExp = RoMScript("GetPlayerExp()") or 0; -- Get newest value
--local maxExp = RoMScript("GetPlayerMaxExp()") or 1; -- 1 by default to prevent division by zero
local newExp = self.XP or 0;
local maxExp = memoryReadRepeat("intptr", getProc(), addresses.charMaxExpTable_address, (self.Level-1) * 4) or 1;
self.LastExpUpdateTime = os.time(); -- Reset timer
if( type(newExp) ~= "number" ) then newExp = 0; end;
if( type(maxExp) ~= "number" ) then maxExp = 1; end;
Where Exp calculations would be changed to be Item per hour, with the variable that you desire being set at the beginning of a waypoint
My problem is I dont know LUA at all yet and simply reading through code and mashing it together is tedious.
Ill keep at it, but does anyone know if I can define my own variables within my own addon?
something like
WaypointType = gather
namevar1 = monitored item 1
namevar2 = monitored Item 2
GatherItem1 = inventory:itemTotalCount(204792)
GatherItem2 = inventory:itemTotalCount(204791))
For example Below is not working code
Code: Select all
setWindowName(player.Name,"namevar1,"..GatherItem1..",namevar2,"..GatherItem2))
You could monitor the Waypoint file to see if its Gather or Level and then it would change the window readout accordingly
If you could define variables you could make a new variable using the ExpPerMin calcualtions as well
Code: Select all
self.ItemPerMin = ItemGainSum / ( valueCount * self.ItemUpdateInterval / 60 );
This is all in theory, but by making a calc like that with some added new variables you could then calulate gold herbs eggs cards daily items and monitor them using rombot obviously you could use ItemGainSum exported to a list to quickly calculate totals if you like too.
And thats my whole idea currently XD
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 10:56 pm
by lisa
try
Code: Select all
setWindowName(getHwnd(),sprintf(player.Name.." "..GatherItem1.." "..GatherItem2))
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:06 pm
by Yoder
Sigh still no worky
dont I need to define the variables tho
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:13 pm
by lisa
sorry forgot the print and didn't check the ()
Code: Select all
setWindowName(getHwnd(),sprintf(player.Name.." "..GatherItem1.." "..GatherItem2))
I assumed you had done the code for
and
already.
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:16 pm
by Yoder
Interesting
attempt to concatenate global 'gatherItem2' (a nil value)
how do I define these variables
GatherItem 1 and 2
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:18 pm
by Yoder
O.o nice with the fast responses
thats what I thought but was getting errors
Seems this is working.
So I assume I can then pull the calc function out of the Player.lua and remanufacture it to meet my needs while defining variables?
Thanks for the help so far
Yoder
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:24 pm
by Yoder
Strange I can define static values but Im guessing im typing this wrong.
I want the values to be
GatherItem2 = inventory:itemTotalCount(204792)
but when I enter it like that I get the error
Inventory (a nil value)
I thought this was reading the inventory and making a count. doesnt the inventory update on startup ?
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:29 pm
by lisa
Sorry I thought you had it mostly done, you just needed to know how to implement it.
Code: Select all
local GatherItem1 = inventory:itemTotalCount(208473) -- lvl 66 health pot
local GatherItem2 = inventory:itemTotalCount(208480) -- lvl 66 mana pot
setWindowName(getHwnd(),sprintf(player.Name.."health pots: "..GatherItem1.." mana pots: "..GatherItem2))
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:31 pm
by lisa
also there was a patch recently and the new addresses haven't been found yet, I am surprised you can do anything with bot =)
Re: Change exp Per Hour in Window title
Posted: Tue Sep 06, 2011 11:33 pm
by Yoder
I was busy today

bot is working and addressing for eggs seems ok now so thats why I was using them
I tested the readouts using the original linked script and was receving correct numbers
But Ill have to stop here for the night
Re: Change exp Per Hour in Window title
Posted: Wed Sep 07, 2011 9:52 am
by Yoder
Good Morning
So here is what Ive thought about
Code: Select all
local GatherItem1 = inventory:itemTotalCount(208473) -- lvl 66 health pot
local GatherItem2 = inventory:itemTotalCount(208480) -- lvl 66 mana pot
local ItemPerMin1 = GatherItem1 / ( valueCount * self.ExpUpdateInterval / 60 ); --This should still work
local ItemPerMin2 = GatherItem2 / ( valueCount * self.ExpUpdateInterval / 60 ); -- to calculate per min
local LAST_PLAYER_X = 0;
local LAST_PLAYER_Z = 0;
function timedSetWindowName(profile)
local displayname = string.sub(profile, 1, 4) .. "****";
if( (player.X ~= LAST_PLAYER_X) or (player.Z ~= LAST_PLAYER_Z) ) then
setWindowName(getHwnd(),sprintf(player.Name.."health pots: "..GatherItem1.." mana pots: "..GatherItem2));
LAST_PLAYER_X = player.X;
LAST_PLAYER_Z = player.Z;
end
end
But I get an error when starting the bot,
Code: Select all
[b]5: attempt to index global 'inventory' (a nil value)[/b]
[/color]
Re: Change exp Per Hour in Window title
Posted: Wed Sep 07, 2011 10:06 am
by lisa
I am guessing this is in functions.lua around line 400?
2 things come to mind
first is that classes/inventory.lua hasn't been loaded yet which is why it is returning inventory as nil.
the other is something else has gone wrong, there must be more to the error message. what else did it say?
Re: Change exp Per Hour in Window title
Posted: Wed Sep 07, 2011 10:10 am
by rock5
Where did you put the code? Or did you just edit the existing code?
If you edited the existing code, 'inventory' may not have been defined yet. I don't see any way around it.
But I think you could put this somewhere where it will be called after the bot has started, such as a userfunction or in an event such as an 'onload' event. It would then overwrite the existing code and inventory would already exist.