changing what is on the MM window (setwindow)

Additional botting resources. Addons may be either for the game itself or for the RoM bot.
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Message
Author
WonderBoB
Posts: 29
Joined: Tue Feb 19, 2013 10:57 am

Re: changing what is on the MM window.

#21 Post by WonderBoB » Fri Mar 15, 2013 5:41 pm

Lisa I have added a new function to add commas to the outputs to aid in human readability, also included is a fix for the TP per hour not updating properly. Please review my additions and update the function as you see fit.

Code: Select all

--=== Developed by Lisa ===--
--=== Inspired by many  ===--
--=== version 1.6       ===--
--=== Call the function ===--
--=== in WP onload      ===--

function setwindow(ID)
	unregisterTimer("timedSetWindowName");
	unregisterTimer("setwindow")
	
	local _starttime = os.time()
	
	--number formatting by Wonder bob
	-- Usage is as follows :    comma_value(Insert your value here)  
	function comma_value(n) 
		local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
		return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
	end
	
	--=== track in game gold ===--
	if ID == "gold" then
		local startgold = RoMScript('GetPlayerMoney("copper");')
		local function _window()
			local currentgold = RoMScript('GetPlayerMoney("copper");')
			if currentgold then 
				local _charname = string.sub(player.Name,1,7)
				local _timepassed = (os.time() - _starttime)/3600
				local _printtime = string.sub(_timepassed,1,4)
				local _goldreceived = currentgold - startgold
				local _goldperhour = string.sub((_goldreceived/_timepassed),1,8)
				setWindowName(getHwnd(),sprintf(_charname.." Gold per hour: "
				..comma_value(_goldperhour).." Time passed: ".._printtime))
			end
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	elseif ID == "tp" then
		local starttp = player.TP
		local function _window()
			player:update();
			local _charname = string.sub(player.Name,1,7)
			local _timepassed = (os.time() - _starttime)/3600
			local _printtime = string.sub(_timepassed,1,4)
			local _tpreceived = player.TP - starttp
			local _tpperhour = string.sub((_tpreceived/_timepassed),1,8)
			setWindowName(getHwnd(),sprintf(_charname.." TP per hour: "
			..comma_value(_tpperhour).." Time passed: ".._printtime))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	elseif ID == "hp" then
			local function _window()
				setWindowName(getHwnd(),sprintf(player.Name.." Max HP: "..comma_value(player.MaxHP).." Actual HP: "..comma_value(player.HP)))
			end
		registerTimer("setwindow", secondsToTimer(1), _window);
	else
		local _itemname
		--=== ID as item name or item ID ===--
		if type(tonumber(ID)) == "number" then -- arg is item Id
			_itemname = string.sub(GetIdName(ID),1,10)
		else
			_itemname = 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 _currentitems = inventory:itemTotalCount(ID) 
			setWindowName(getHwnd(),sprintf(_charname..". ".._itemname..": "
			..comma_value(_currentitems).." ("..comma_value(_itemsperhour).."/h) Time(h): ".._printtime))
			--setWindowName(getHwnd(),sprintf("1234567890123456789012345678901234567890123"))
		end
		registerTimer("setwindow", secondsToTimer(36), _window);
		yrest(1000)
		_window()
	end
Life without code is like sex without a partner..

Checkout my Midnight Whispers Dailies in Merdhin Tundra
http://www.solarstrike.net/phpBB3/viewt ... 420#p48420

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

Re: changing what is on the MM window.

#22 Post by lisa » Fri Mar 15, 2013 7:29 pm

WonderBoB wrote: also included is a fix for the TP per hour not updating properly.
With the new streamlined code Rock did for updating it would now be important to update those values, wasn't an issue before. I would probably just update the values needed with memory reads though instead of updating the entire player.

Code: Select all

player.HP = memoryReadRepeat("int", getProc(), player.Address + addresses.pawnHP_offset) or player.HP

player.TP = memoryReadRepeat("int", getProc(), addresses.charClassInfoBase + (addresses.charClassInfoSize* player.Class1 ) + addresses.charClassInfoTP_offset) or player.TP
WonderBoB wrote:Lisa I have added a new function to add commas to the outputs to aid in human readability,
Can you post some screen shots of what it looks like with your changes, I actually don't even log on RoM much anymore so for me to test it would be a pain.
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

WonderBoB
Posts: 29
Joined: Tue Feb 19, 2013 10:57 am

Re: changing what is on the MM window.

#23 Post by WonderBoB » Mon Mar 18, 2013 10:47 am

Here is a SS of the Changes to the numbers Lisa as you asked.

Code: Select all

player.TP
Using this like you showed will pull the TP on MM load after that it will not update.... for some reason thus the reason why I added the

Code: Select all

player:update();
Shouldn't

Code: Select all

player:update(TP);
just update TP though?
Attachments
MM_title.jpg
Life without code is like sex without a partner..

Checkout my Midnight Whispers Dailies in Merdhin Tundra
http://www.solarstrike.net/phpBB3/viewt ... 420#p48420

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

Re: changing what is on the MM window.

#24 Post by lisa » Mon Mar 18, 2013 6:18 pm

WonderBoB wrote:Here is a SS of the Changes to the numbers Lisa as you asked.
Ahh so you added in the comma's for the values so it looks like this?
6,878,455,646
WonderBoB wrote:just update TP though?
no, there was never a seperate way to update TP, it is only updated in player:update() or by doing the memory read itself.
userfunction_setwindow.lua
V 1.8 for testing.
(3.36 KiB) Downloaded 206 times
Give it a test run and see how it goes.

I added in the comma thing, tp/hp updates and it looks like this.

Code: Select all

--=== Developed by Lisa ===--
--=== Inspired by many  ===--
--=== version 1.8       ===--
--=== Call the function ===--
--=== in WP onload      ===--

function setwindow(ID)
	unregisterTimer("timedSetWindowName");
	unregisterTimer("setwindow")
	
   -- number formatting by Wonder bob
   -- Usage is as follows :    comma_value(Insert your value here) 	
	local function comma_value(n) 
		local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
		return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
	end
	
	local _starttime = os.time()
	--=== track in game gold ===--
	if ID == "gold" then
		local startgold = RoMScript('GetPlayerMoney("copper");')
		local function _window()
			local currentgold = RoMScript('GetPlayerMoney("copper");')
			if currentgold then 
				local _charname = string.sub(player.Name,1,7)
				local _timepassed = (os.time() - _starttime)/3600
				local _printtime = string.sub(_timepassed,1,4)
				local _goldreceived = currentgold - startgold
				local _goldperhour = string.sub((_goldreceived/_timepassed),1,8)
				setWindowName(getHwnd(),sprintf(_charname.." Gold per hour: "
				..comma_value(_goldperhour).." Time passed: ".._printtime))
			end
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	elseif ID == "tp" then
		local starttp = player.TP
		local function _window()
			player.TP = memoryReadRepeat("int", getProc(), addresses.charClassInfoBase + (addresses.charClassInfoSize* player.Class1 ) + addresses.charClassInfoTP_offset) or player.TP
			local _charname = string.sub(player.Name,1,7)
			local _timepassed = (os.time() - _starttime)/3600
			local _printtime = string.sub(_timepassed,1,4)
			local _tpreceived = player.TP - starttp
			local _tpperhour = string.sub((_tpreceived/_timepassed),1,8)
			setWindowName(getHwnd(),sprintf(_charname.." TP per hour: "
			..comma_value(_tpperhour).." Time passed: ".._printtime))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	elseif ID == "hp" then
			local function _window()
				player.HP = memoryReadRepeat("int", getProc(), player.Address + addresses.pawnHP_offset) or player.HP;
				setWindowName(getHwnd(),sprintf(player.Name.." Max HP: "..comma_value(player.MaxHP).." Actual HP: "..comma_value(player.HP)))
			end
		registerTimer("setwindow", secondsToTimer(1), _window);
	else
		local _itemname
		--=== ID as item name or item ID ===--
		if type(tonumber(ID)) == "number" then -- arg is item Id
			_itemname = string.sub(GetIdName(ID),1,10)
		else
			_itemname = 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 _currentitems = inventory:itemTotalCount(ID) 
			setWindowName(getHwnd(),sprintf(_charname..". ".._itemname..": "
			..comma_value(_currentitems).." ("..comma_value(_itemsperhour).."/h) Time(h): ".._printtime))
			--setWindowName(getHwnd(),sprintf("1234567890123456789012345678901234567890123"))
		end
		registerTimer("setwindow", secondsToTimer(36), _window);
		yrest(1000)
		_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

Buster99
Posts: 69
Joined: Fri Nov 25, 2011 9:27 am

Re: changing what is on the MM window.

#25 Post by Buster99 » Sun Mar 31, 2013 10:01 am

Lisa, not to complicate things on this but I was wondering how difficult it would be to do this:

Add a gold value to an item that is collected while farming and include this in the "gold/hour" amount. i.e. - If I know that I consistently sell Activate runes for 2k per, include that in the MM window of G/H amount.

So something like:

Code: Select all

local_itemgold = inventory:itemTotalCount("Activate Rune") * 2000
local _goldreceived = currentgold + itemgold - startgold
I am not asking for this to be added to userfunction necessarily. I am really just thinking out loud if something like this would work, which I would enjoy having this number. Or maybe, if there was enough space on the MM window we could have a G/H and a G+Item/H rate. Anyways, just thoughts.

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

Re: changing what is on the MM window.

#26 Post by lisa » Sun Mar 31, 2013 10:14 am

Do you mean items you sell on AH and not to vendor?
If so it would depend on what you usually get for the items, which would vary for every server.
In order to do it we would need to set up a table that has the item ID/Name and the value you sell them for, there would be a lot of room for issues when people would need to add in their own details, would probably be a profile option or atleast something set in profile onload as you would want it different for each char or for each WP.

It is of course very possible though.
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

Buster99
Posts: 69
Joined: Fri Nov 25, 2011 9:27 am

Re: changing what is on the MM window.

#27 Post by Buster99 » Sun Mar 31, 2013 10:52 am

Thanks for fast reply.

Yes, I do mean items I sell on AH not to vendor. I know that leaves room for a lot of market variable, etc. And you are right, it would be different for each server. I may just play around with it and follow your suggestion to set it up in profile options. This seems valuable to some of us who farm items we actually sell to others or on AH to give a more true G/H value. I am not sure how to set up a table, but I know there are lots of examples that I have seen here in the forums. But a table where we can input whatever items we want with their value seems the place to start. Will be fun to try it out.

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

Re: changing what is on the MM window.

#28 Post by lisa » Sun Mar 31, 2013 8:06 pm

table will look something like this.

Code: Select all

	ghitems = {
	{Id = "200852", ahValue = "2000"}, -- activate rune
	{Id = "241271", ahValue = "1500"}, -- arrowhead eoj
	}
This is completely untested and will probably have 1000 errors ;)
Table is at the top, I don't see a need to have tables in profiles or WP.
This is purely gold that you would get from AH items, the gold collected from mobs is not included, if it works as intended it can be added into the "gold" and all be calculated together.

Usage

Code: Select all

setwindow("AH")
Attachments
userfunction_setwindow.lua
V 2.0
(4.31 KiB) Downloaded 198 times
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: changing what is on the MM window.

#29 Post by lisa » Fri Jun 14, 2013 6:47 pm

Added V 3.0 on first post, no idea how long ago I wrote it but I just noticed I haven't updated this topic for a while.
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

CanceR
Posts: 33
Joined: Sun Jul 22, 2012 9:28 am

Re: changing what is on the MM window (setwindow)

#30 Post by CanceR » Sun Nov 24, 2013 5:08 pm

Hello Lisa,
i know that everyone has an different opinion about every issue, bit can you specify what to change to get back XP/min or TP/min, because an hour is too long time to wait to update itself.
also it is possible to be done to show Xp/time and TP/time on same window, because sometimes there are different bonus levels - from guild castle towers or house maid buffs and it would be useful to track XP and TP separately.
thanks in advance.
EDIT: fixed by changing "local _timepassed = (os.time() - _starttime)/3600" to "local _timepassed = (os.time() - _starttime)/60" and added of mixture of both elseif's for TP and for XP.
now it is showing some digits after decimal point, like 2,666.333 TP/min, any idea how to make it rounded upto decimal point? (not to show digit after decimal point)

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

Re: changing what is on the MM window (setwindow)

#31 Post by lisa » Sun Nov 24, 2013 5:43 pm

it should update the values every 30 seconds but the value would be amount per hour.

Code: Select all

secondsToTimer(30)
changing that 3600 to 600 like you did would make it value per minute, yes, but updates would still be every 30 seconds.

As for what is displayed it is affected by this function near the top of file.

Code: Select all

	local function comma_value(n) 
		local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
		return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
	end
So to make it only show whole numbers you could adjust that code accordingly.
Alternatively you could adjust the value returned from that function to then be a whole number, this is probably the easiest option.

Hope I cleared things up a little.

--=== Added ===--

If you delete the ..right it will not have decimal point values anymore.

Code: Select all

	local function comma_value(n) 
		local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
		return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())
	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

kuripot
Posts: 493
Joined: Mon Nov 07, 2011 9:14 pm

Re: changing what is on the MM window (setwindow)

#32 Post by kuripot » Fri Dec 27, 2013 9:39 am

how can i setwindow the currency.. like honor points??

User avatar
Lamkefyned
Posts: 348
Joined: Thu May 23, 2013 11:38 am
Location: Spain

Re: changing what is on the MM window (setwindow)

#33 Post by Lamkefyned » Sat Feb 01, 2014 11:07 pm

How to make a counter with list objects currency?
If you think something is right just because everyone else believes,you're not thinking.

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

Re: changing what is on the MM window (setwindow)

#34 Post by lisa » Sun Feb 02, 2014 5:43 am

We are currently looking at getting the "currency list" from memory and once that is done I will update this userfunction to be able to use anything in the currency list, no point updating at this stage as I would need to redo the changes once the info is gotten from memory.
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: changing what is on the MM window (setwindow)

#35 Post by rock5 » Sun Feb 02, 2014 6:01 am

Not really. The getCurrency function will always accept the same arguments and return the same values. Oops I just realized something. At the moment the getCurrency function returns the current value and max value of the currency. There are no max values at that memory address.
  • 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: changing what is on the MM window (setwindow)

#36 Post by lisa » Sun Feb 02, 2014 6:19 am

Ok assuming we just update the getcurrency function with memory stuff then V 3.5 will work now and later, it's posted on first post this topic.
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
Lamkefyned
Posts: 348
Joined: Thu May 23, 2013 11:38 am
Location: Spain

Re: changing what is on the MM window (setwindow)

#37 Post by Lamkefyned » Sun Feb 02, 2014 6:35 am

I'll prove it right away for my project, thanks
If you think something is right just because everyone else believes,you're not thinking.

User avatar
Lamkefyned
Posts: 348
Joined: Thu May 23, 2013 11:38 am
Location: Spain

Re: changing what is on the MM window (setwindow)

#38 Post by Lamkefyned » Sun Feb 02, 2014 6:48 am

there is one error.

Code: Select all

	<!-- FUNCTION SETWINDOW MEMENTOS -->
                        setwindow(mem)
error setwindow.JPG
If you think something is right just because everyone else believes,you're not thinking.

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

Re: changing what is on the MM window (setwindow)

#39 Post by lisa » Sun Feb 02, 2014 7:00 am

Code: Select all

setwindow("mem")
Assuming you did have it correctly, make sure you have bot version 758 or later, the getcurrency was added in version 758.


It is working fine for me, it will only update every 30 seconds.
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: changing what is on the MM window (setwindow)

#40 Post by rock5 » Sun Feb 02, 2014 7:07 am

rock5 wrote:Oops I just realized something. At the moment the getCurrency function returns the current value and max value of the currency. There are no max values at that memory address.
I'm not sure how important it is to return the max values but I've figured out how I can do it. The first time it gets a currency it can use the ingame function and then remember the max value. On subsequent calls it can use the memory address.
  • 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

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests