Change exp Per Hour in Window title

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Message
Author
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#21 Post by lisa » Wed Sep 07, 2011 10:36 am

I just did a userfunction and called it from commandline, works perfectly.

Code: Select all

function setwindow()
	printf("does function\n")
	local GatherItem1 = inventory:itemTotalCount("Phirius Token Coin")
	local GatherItem2 = inventory:itemTotalCount("Simple First Aid Potion")
	setWindowName(getHwnd(),sprintf(player.Name.." Phirius coins: "..GatherItem1.." Health Pots: "..GatherItem2))
end
You could probably call it from onleavecombat in profile or some other way. I tried to set up a timer but for some reason the timer wasn't working for me, pretty sure I had this issue when I first worked on gm monitor and timers would only work if you actually did a WP and not commandline. Could probably test that a bit more.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Change exp Per Hour in Window title

#22 Post by rock5 » Wed Sep 07, 2011 10:41 am

I wonder if you could replace the original timer or replace the function it calls.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#23 Post by lisa » Wed Sep 07, 2011 10:45 am

Ok this is the solution to what you want.

userfunction

Code: Select all

function setwindow()
unregisterTimer("timedSetWindowName");
	local function _window()
	local GatherItem1 = inventory:itemTotalCount("Phirius Token Coin")
	local GatherItem2 = inventory:itemTotalCount("Simple First Aid Potion")
	setWindowName(getHwnd(),sprintf(player.Name.." Phirius coins: "..GatherItem1.." Health Pots: "..GatherItem2))
	end
	registerTimer("setwindow", secondsToTimer(1), _window);
end
call the function setwindow() only once, I did it in the onload of the WP and bobs your aunty, job done, thank the ball boys and the lines man.

I actually really like this, Rock you should do it for millers WP, not like you need coords or xp/hr while in millers.


I did this in the WP onload and also works like a charm, so can be customized for your WP.

Code: Select all

<onload>
	unregisterTimer("timedSetWindowName");
	local function _window()
		local GatherItem1 = inventory:itemTotalCount("Phirius Token Coin")
		local GatherItem2 = inventory:itemTotalCount("Simple First Aid Potion")
		setWindowName(getHwnd(),sprintf(player.Name.." Phirius coins: "..GatherItem1.." Health Pots: "..GatherItem2))
	end
	registerTimer("setwindow", secondsToTimer(1), _window);
</onload>
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Yoder
Posts: 24
Joined: Tue Sep 06, 2011 10:24 am

Re: Change exp Per Hour in Window title

#24 Post by Yoder » Wed Sep 07, 2011 3:11 pm

You have interpreted my ramblings into this working piece of art.

and you have suguested exactly what I planned to do with this.

it would be great tho to make it fairly strait forward so people could set up gather waypoints and track their progress on other items more quickly.

I generaly keep windows pretty small wen running millers and find I have to streach the window to read my current total. Writing totals to a file is annoying because I dont need the file after I have the total.

This should be just the fix

and like you said when your using a waypoint where EXP doesnt matter you can put this in to show atleast some relevant data

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#25 Post by lisa » Wed Sep 07, 2011 7:17 pm

pop this in the onload for millers WP you use.

Code: Select all

unregisterTimer("timedSetWindowName");
   local function _window()
   local GatherItem1 = inventory:itemTotalCount(204792) --golden eggs
   local GatherItem2 = inventory:itemTotalCount(204795) -- millers cake
   setWindowName(getHwnd(),sprintf(player.Name.." Golden Eggs: "..GatherItem1.." Miller Cake: "..GatherItem2))
   end
   registerTimer("setwindow", secondsToTimer(30), _window);
It won't say how many you have gatherede since you started, it is purely a total of how many you actually have. I also changed the timer to every 30 seconds, instead of every second. Could probably make it more as you don't get golden eggs all the time.

Actually the id for millers is probably wrong, I think that is id for the eggs you hand in for quest to get the millers.

Haven't got the time atm to get the right id for millers cake, you can just change it if you know it.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Yoder
Posts: 24
Joined: Tue Sep 06, 2011 10:24 am

Re: Change exp Per Hour in Window title

#26 Post by Yoder » Wed Sep 07, 2011 10:09 pm

Code: Select all

   unregisterTimer("timedSetWindowName");
   local function _window()
      local GatherItem1 = inventory:itemTotalCount(204792)
      local GatherItem2 = inventory:itemTotalCount(204791)
	  local ItemPerMin1 = 0
	  ItemPerMin1 = GatherItem1 / ( valueCount * player.ExpUpdateInterval / 60 );
      setWindowName(getHwnd(),sprintf(player.Name.." Eggs: "..GatherItem1.." Food: "..GatherItem2..", "..ItemPerMin1.."/Min"))
   end
   registerTimer("setwindow", secondsToTimer(1), _window);
So this makes the variable available, but how can I calculate that?

Below is an idea I have

Code: Select all

 ItemPerMin1 = GatherItem1 / ( valueCount * player.ExpUpdateInterval / 60 );
player.ExpUpdate should work right >? doesnt it get defined in Player.lua and so the calcuations for per minute will still be the same then.

but how do I mark the valuecount up 1 per timer interval. then I can adjust the calculation to match with 30 second intervals.

Yoder

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#27 Post by lisa » Wed Sep 07, 2011 11:15 pm

tracking items per hour and such can get complicated or can be semi simple.

If you have a look in Rock5's MCR_Optimized.xml it is very in depth and hard to follow, end result is of course you get the prints when you wanted then according to your settings and lots of information. You could probably just use the variables he has in there if you are going to use this in the same WP, would be simpler.

If you want to work in a different WP or userfunction then you will need to set a start time so you can calculate the time passed.

I tend to mess up the time calculations but you get the idea.

Code: Select all

function setwindow()
	unregisterTimer("timedSetWindowName");
	local _starttime = os.time()
	local _starteggs = inventory:itemTotalCount(204792)
	local function _window()
		local _timepassed = (os.time() - _starttime)/360 -- total time in hours
		local _gatheredeggs = inventory:itemTotalCount(204792) - _starteggs -- total eggs aquired since starting
		local _eggsperhour = (_gatheredeggs/_timepassed)
		local _currenteggs = inventory:itemTotalCount(204792) -- golden eggs
		local _currentcake = inventory:itemTotalCount(204795) -- millers cake, wrong id, its the huge eggs.
		setWindowName(getHwnd(),sprintf(player.Name.." Golden Eggs per hour: ".._eggsperhour.." Time passed: ".._timepassed))
	end
	registerTimer("setwindow", secondsToTimer(30), _window);
end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Change exp Per Hour in Window title

#28 Post by rock5 » Thu Sep 08, 2011 12:01 am

This could nearly be made into a userfunction. Just deciding a default way to show the output would be problematical.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#29 Post by lisa » Thu Sep 08, 2011 12:40 am

Yeah you would basically need to define lots of different things you may need to track and then have variables to match. So a few arg's for the function.

I figured it would be easier if people did specific ones for specific WP instead.

otherwise you would be looking at something like this.

Code: Select all

function setwindow(_type)
	unregisterTimer("timedSetWindowName");
	unregisterTimer("setwindow")
	local _starttime = os.time()
	--=== track golden eggs ===--
	if _type == "goldeneggs" then 
		local _starteggs = inventory:itemTotalCount(204792)
		local function _window()
			local _timepassed = (os.time() - _starttime)/360 -- total time in hours
			local _gatheredeggs = inventory:itemTotalCount(204792) - _starteggs -- total eggs aquired since starting
			local _eggsperhour = (_gatheredeggs/_timepassed)
			local _currenteggs = inventory:itemTotalCount(204792) -- golden eggs
			local _currentcake = inventory:itemTotalCount(204795) -- millers cake, wrong id, its the huge eggs.
			setWindowName(getHwnd(),sprintf(player.Name.." Golden Eggs per hour: "
			.._eggsperhour.." Time passed: ".._timepassed))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	end
	
	
	--=== track in game gold ===--
	if _type == "gold" then
		local currentgold = RoMScript('GetPlayerMoney("copper");')
		local function _window()
			local _timepassed = (os.time() - _starttime)/360
			local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold
			local _goldperhour = (_goldreceived/_timepassed)
			setWindowName(getHwnd(),sprintf(player.Name.." Gold per hour: "
			.._goldperhour.." Time passed: ".._timepassed))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	end

end
The function could get very very long lol
doable though. You could probably add in a second arg for item ID and if the arg exists then do a different print that just does the counts for that ID.
That should cover most bases.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Yoder
Posts: 24
Joined: Tue Sep 06, 2011 10:24 am

Re: Change exp Per Hour in Window title

#30 Post by Yoder » Thu Sep 08, 2011 12:50 am

Code: Select all

   unregisterTimer("timedSetWindowName");
   local _starttime = os.time()
   local _starteggs = inventory:itemTotalCount(204792)
   local function _window()
      local _timepassed = (os.time() - _starttime)/3600 -- total time in hours
      local _gatheredeggs = inventory:itemTotalCount(204792) - _starteggs -- total eggs aquired since starting
      local _eggsperhour = (_gatheredeggs/_timepassed)
      local _currenteggs = inventory:itemTotalCount(204792) -- golden eggs
      local _currentcake = inventory:itemTotalCount(204791) -- millers cake
      setWindowName(getHwnd(),sprintf(player.Name.." Gold Eggs: ".._currenteggs..", Cakes: ".._currentcake..", ".._eggsperhour.." Eggs/Hr, Time Passed:".._timepassed.."Hrs"))
   end
   registerTimer("setwindow", secondsToTimer(1), _window);
Image

Thats a clickable image of my readout

Only a few things left XD then I could make "portable" to move from waypoint to waypoint

Issue is with the Runtime readout and the Eggs per Hour readout both max out at around 16 characters, 4 is more than enought thats 0.000 and I think thats down to the seconds

also I changed one value after checking the hours calculation and Ill explain why

Start time 1
12:31:30
1315459830

Start time 2
12:32:00
1315459920

1 minute 30 seconds or
90 seconds

1315459920 - 1315459830 = 90

90 / 60 = 1.5 /60 = 0.025

90 / 3600 = 0.025

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Change exp Per Hour in Window title

#31 Post by rock5 » Thu Sep 08, 2011 12:55 am

lisa wrote:You could probably add in a second arg for item ID and if the arg exists then do a different print that just does the counts for that ID.
Actually that's what I had in mind, an id or 2. It could get the name and count and display "itemname: num num/h" etc. You could use that for eggs without nay special option but I can see how you would need a different option to show money. I wonder if there are any other things that would need a special argument. Doesn't matter as they could get added as needed.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#32 Post by lisa » Thu Sep 08, 2011 1:25 am

unless you do it purely from ID and use the ID to get the name and then use that name in part of the print. That could work.

So could have

Code: Select all

function setwindow(ID)
if type(tonumber(ID)) == "number" then -- arg is item Id
get the item name and do other stuff.
end
if ID == "gold" then
just print about gold
end
end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#33 Post by lisa » Thu Sep 08, 2011 1:40 am

Code: Select all

local _name = GetIdName(ID) 
will probably do the trick.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#34 Post by lisa » Thu Sep 08, 2011 2:41 am

Ahh yeah I did 360 instead of 3600, fixed.

Ok this is working copy of userfunction, uses item Id or "gold" as the arg.

The name print is of course entire name and I think that is to long, not sure how to handle that, if you reduce how many letters are on window then it doesn't really tell you the name.
i.e. 5 letters, Major
Major First Aid Potion
Major Magic Potion

I reduced the numbers printed by time and items/hour using string.sub so prints maximum of 4 digits.

I feel my _itemsperhour is failing me, I am getting negative numbers when it should be 0. Either way the foundation for code is there, obviously need to add in checks to make sure the ID is correct and such. Also fix the items per hour.

Code: Select all

function setwindow(ID)
	unregisterTimer("timedSetWindowName");
	unregisterTimer("setwindow")
	
	local _starttime = os.time()
	--=== check for ID as an item ID ===--
	if type(tonumber(ID)) == "number" then -- arg is item Id
		local _name = GetIdName(ID)
		local _startitem = inventory:itemTotalCount(ID)
		local function _window()
			local _timepassed = (os.time() - _starttime)/3600 -- total time in hours
			local _printtime = string.sub(_timepassed,1,4)
			local _gathereditems = inventory:itemTotalCount(ID) - _startitem -- total items aquired since starting
			local _itemsperhour = string.sub((_gathereditems/_timepassed),1,4)
			local _currenteggs = inventory:itemTotalCount(ID) -- golden eggs
			setWindowName(getHwnd(),sprintf(player.Name.." Item name: ".._name.." per hour: "
			.._itemsperhour.." Time passed: ".._printtime))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	end
	
	
	--=== track in game gold ===--
	if ID == "gold" then
		local currentgold = RoMScript('GetPlayerMoney("copper");')
		local function _window()
			local _timepassed = (os.time() - _starttime)/3600
			local _printtime = string.sub(_timepassed,1,4)
			local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold
			local _goldperhour = string.sub((_goldreceived/_timepassed),1,4)
			setWindowName(getHwnd(),sprintf(player.Name.." Gold per hour: "
			.._goldperhour.." Time passed: ".._printtime))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	end

end
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Change exp Per Hour in Window title

#35 Post by rock5 » Thu Sep 08, 2011 2:48 am

lisa wrote:unless you do it purely from ID and use the ID to get the name and then use that name in part of the print. That could work.
Actually that's what i meant when I said "get the name", as in "GetIdName".
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#36 Post by lisa » Thu Sep 08, 2011 2:54 am

already done, ran it for a bit with just a potion, which didn't get more or less over time. The item per hour is definately wrong. The time works. Need to reduce item name, maybe max 10?
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Change exp Per Hour in Window title

#37 Post by rock5 » Thu Sep 08, 2011 2:56 am

Actually the way you are doing it limits you to ids. How about if you check for the code words first, such as "gold". If not, then if it's a number it's an id otherwise if it's a string it's a name. Then you could use names as well as ids.

How many characters fit on the display anyway?
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#38 Post by lisa » Thu Sep 08, 2011 5:21 am

Hm I'll test it on gold arg but I am pretty sure it should work as is, can't see why not.
rock5 wrote:How many characters fit on the display anyway?
I have written maybe 4 or 5 answers to this and deleted each. In the end it is hard to say because every user is different. Some may rezise all of their MM to fit 10 MM in 1 display. Some will just use 1 MM and have it max width.
setwindow(&quot;gold&quot;)
setwindow("gold")
In the end, dunno.
Going to have to limit the player name aswell, a long player name might fill up the window aswell.

Function can't be used in profile onload, works fine in WP onload, haven't tested any other spots yet.

No point worrying about windows tab, the bit usually bottom of screen, not many characters fit on it. get name but not much more.
windows tab
windows tab
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#39 Post by lisa » Thu Sep 08, 2011 6:28 am

rock5 wrote:Actually the way you are doing it limits you to ids. How about if you check for the code words first, such as "gold". If not, then if it's a number it's an id otherwise if it's a string it's a name. Then you could use names as well as ids.
Totally misread that, you mean to be able to use the item name aswell as the ID. Sorry just not thinking atm =(

K I'll work on it.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

Re: Change exp Per Hour in Window title

#40 Post by lisa » Thu Sep 08, 2011 6:52 am

Ok I figure ID is only used in inventory:itemTotalCount(ID) anyway which accepts both Item ID and item name I can just do this

Code: Select all

		--=== ID as item name or item ID ===--
		if type(tonumber(ID)) == "number" then -- arg is item Id
			local _name = string.sub(GetIdName(ID),1,10)
		else
			local _name = string.sub(ID,1,10)
		end
So it looks like this now.

Code: Select all

function setwindow(ID)
	unregisterTimer("timedSetWindowName");
	unregisterTimer("setwindow")
	
	local _starttime = os.time()
	
	--=== track in game gold ===--
	if ID == "gold" then
		local currentgold = RoMScript('GetPlayerMoney("copper");')
		local function _window()
			local _charname = string.sub(player.Name,1,7)
			local _timepassed = (os.time() - _starttime)/3600
			local _printtime = string.sub(_timepassed,1,4)
			local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold
			local _goldperhour = string.sub((_goldreceived/_timepassed),1,4)
			setWindowName(getHwnd(),sprintf(_charname.." Gold per hour: "
			.._goldperhour.." Time passed: ".._printtime))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	else
	
		--=== ID as item name or item ID ===--
		if type(tonumber(ID)) == "number" then -- arg is item Id
			local _name = string.sub(GetIdName(ID),1,10)
		else
			local _name = string.sub(ID,1,10)
		end
		local _startitem = inventory:itemTotalCount(ID)
		local function _window()
			local _charname = string.sub(player.Name,1,7)
			local _timepassed = (os.time() - _starttime)/3600 -- total time in hours
			local _printtime = string.sub(_timepassed,1,4)
			local _gathereditems = inventory:itemTotalCount(ID) - _startitem -- total items aquired since starting
			local _itemsperhour = string.sub((_gathereditems/_timepassed),1,4)
			local _currenteggs = inventory:itemTotalCount(ID) -- golden eggs
			setWindowName(getHwnd(),sprintf(_charname.." Item name: ".._name.." per hour: "
			.._itemsperhour.." Time passed: ".._printtime))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	end

end
Not sure if there is a need to try to track multiple items from a table.
Don't think the window is big enough for more then 1 item.
Remember no matter you do in life to always have a little fun while you are at it ;)

wiki here http://www.solarstrike.net/wiki/index.php?title=Manual

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 20 guests