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
User avatar
lisa
Posts: 8332
Joined: Tue Nov 09, 2010 11:46 pm
Location: Australia

changing what is on the MM window (setwindow)

#1 Post by lisa » Sat Sep 10, 2011 7:39 pm

This was developed in another topic, thought it should be added here.

call it in the WP onload,
setwindow(ID)
ID can be
setwindow("Item Name")
setwindow(itemid)
setwindow("gold")

-- usage
-- "xp" "tp" "AH" "gold" "hp"
-- if not any of those then it is an item ID or item name

Code: Select all

setwindow("gold") -- tracks gold
setwindow(204792) -- Golden Egg
setwindow("Golden Egg") -- using name instead of ID
Attached pic is a screen shot of the MM window to show how it changes the look. In this example it is tracking the item "Herb of Hope"
screenie of MM bar
screenie of MM bar
If people can think of other things to track that don't have item ID's then please post and I'll look into it.
userfunction_setwindow.lua
V 1.6
Added "tp" and fixed bug in gold/hour
(2.73 KiB) Downloaded 579 times
userfunction_setwindow.lua
V 3.0
(4.98 KiB) Downloaded 468 times
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")
userfunction_setwindow.lua
V 3.5a
(6.95 KiB) Downloaded 435 times
Added
honor,
mem (ancient mementos),
eoj (energy of justice)
-- usage
-- "xp" "tp" "AH" "gold" "hp" "honor" "mem" "eoj"

Untested but should work
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.

#2 Post by rock5 » Sun Sep 11, 2011 8:12 am

If this is going to be the home of this addon, maybe you should describe what it actually does for those that haven't read the other topic.
  • 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
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: changing what is on the MM window.

#3 Post by silinky » Fri Feb 24, 2012 9:05 am

hi!

just wanted to report that setwindow('gold') is not working properly on my setup.
it shows very small numbers (in KS farming), for example i usually make about 300-350k in 15-17 minutes, but it shows numbers like 4k-8k per hour. because of this i temporarily modified the userfunction to actually show me all the gold i have, but i think this is not an optimal solution. any tips on what am i doing wrong?
(normal items are reported ok, for ex dogmeat, or anything else. only the gold is working weird)

regards :)

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

Re: changing what is on the MM window.

#4 Post by lisa » Fri Feb 24, 2012 9:47 am

Ahh looks like I forgot to update it, it is actually working but it is only showing you the first hmm I think I had it set to 6 characters originally. I changed that to 8 afterwards, so it now shows 12,345,678 as opposed to just 123,456

I'll update the first post with latest version.
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
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: changing what is on the MM window.

#5 Post by silinky » Fri Feb 24, 2012 10:49 am

thank you :)

Golbez
Posts: 66
Joined: Sat Aug 02, 2008 8:27 pm

Re: changing what is on the MM window.

#6 Post by Golbez » Mon Feb 27, 2012 9:04 am

if i wanted to make it say how meny egg i have so far. would i put this into the millers scripts?

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

Re: changing what is on the MM window.

#7 Post by lisa » Mon Feb 27, 2012 9:17 am

Code: Select all

setwindow(204792)
I use a special profile for egg so I just have that in the profile onload, you could add that to the WP onload though if you wanted.

something like this would do it.
from

Code: Select all

<onLoad>
	--== User Option ==--
to

Code: Select all

<onLoad>
setwindow(204792)
	--== User Option ==--
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
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: changing what is on the MM window.

#8 Post by silinky » Tue Mar 06, 2012 3:36 pm

hi!

i hope you don't mind, i modified your userfunction a little, added some trivial info to the gold window title, and prettified the time and gold amound to be more human readable.

here is the code in case you want to integrate the functions, or if you know better code to do this stuff:

Code: Select all

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

function setwindow(ID)
	unregisterTimer("timedSetWindowName");
	unregisterTimer("setwindow")
	
	local _starttime = os.time()
	
	local function _humantime(iseconds)
		local seconds = iseconds
		if seconds == 0 then
			--return nil;
			return "00:00";
			--return "H00:M00:S00";
		else
			hours = string.format("%02.f", math.floor(seconds/3600));
			mins = string.format("%02.f", math.floor(seconds/60 - (hours*60)));
			secs = string.format("%02.f", math.floor(seconds - hours*3600 - mins *60));
			return hours..":"..mins
			--return "H"..hours..":M"..mins..":S"..secs
		end
	end
	
	local function prettynumber(bnumber)
		local pretty = bnumber
		while true do  
			pretty, k = string.gsub(pretty, "^(-?%d+)(%d%d%d)", '%1,%2')
			if (k==0) then
				break
			end
		end
		return pretty
	end
	--=== 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 = _humantime(os.time() - _starttime)
			local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold
			local _goldperhour = string.sub((_goldreceived/_timepassed),1,8)
			local updatedgold = RoMScript('GetPlayerMoney("copper");')
			setWindowName(getHwnd(),sprintf(_charname..": Total gold: "..prettynumber(updatedgold).." Gold per hour: "
			..prettynumber(_goldperhour).." Time passed: ".._printtime))
		end
		registerTimer("setwindow", secondsToTimer(30), _window);
	elseif ID == "hp" then
			local function _window()
				setWindowName(getHwnd(),sprintf(player.Name.." Max HP: "..player.MaxHP.." Actual HP: "..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 = _humantime(os.time() - _starttime)
			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..": "
			.._currentitems.." (".._itemsperhour.."/h) Time(h): ".._printtime))
			--setWindowName(getHwnd(),sprintf("1234567890123456789012345678901234567890123"))
		end
		registerTimer("setwindow", secondsToTimer(36), _window);
		yrest(1000)
		_window()
	end

end
also, could you please make a possibility to pause this timer, because i saw that if the refreshing moment (at the end of the 30 sec cycle) coincides with a loading screen, the script throws an error at this line: local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold

so before the moment this occures i could put a pause on the timer, and resume on the next waypoint. no problem if the MM window loses this title for that moment. important is for it to keep the values to resume later.
or to auto pause while waitForLoadingScreen() is active

thanks for the script!

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

Re: changing what is on the MM window.

#9 Post by lisa » Tue Mar 06, 2012 9:50 pm

silinky wrote:also, could you please make a possibility to pause this timer, because i saw that if the refreshing moment (at the end of the 30 sec cycle) coincides with a loading screen, the script throws an error at this line: local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold
Good point, I'll have a think on it =)
Instead of a pause might make it stop doing RoMScripts if loading screen is active, it would probably be a good thing for the actual RoMScript function to not do anything while loading screen is active.
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.

#10 Post by rock5 » Wed Mar 07, 2012 12:57 am

lisa wrote:Instead of a pause might make it stop doing RoMScripts if loading screen is active, it would probably be a good thing for the actual RoMScript function to not do anything while loading screen is active.
I thought I already did that.

Yep.

Code: Select all

function RoMScript(script, default)
	-- Check for loading screen
	if memoryReadBytePtr(getProc(),addresses.loadingScreenPtr, addresses.loadingScreen_offset) ~= 0 then
		-- Cannot execute RoMScript during loading screen.
		return
	end
  • 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
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: changing what is on the MM window.

#11 Post by silinky » Wed Mar 07, 2012 2:34 am

hmmm weird, then :shock:

oh well i try to solve it somehow, thing is that i cannot leave unattended the KS script with the setwindow('gold') because at zone change randomly throws the error. and always at loading screen. i managed a workaround by making a function in the ks WP to actually change the game window info, and print it also to the micromacro windows combat log, and now it works ok.

but i like the setwindow userfunction and i miss it.

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

Re: changing what is on the MM window.

#12 Post by lisa » Wed Mar 07, 2012 5:08 am

Weird, I've run KS with the gold setting for setwindow for days on end and never had the issue.

You sure it isn't something in your WP file?
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
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: changing what is on the MM window.

#13 Post by silinky » Wed Mar 07, 2012 5:54 am

well, could be, but when i take setwindow out, it goes on without any errors.

maybe it has some conflict with some of the functions i made for it, i included speedhack and lots of other enhancement scripts there. i will try with the default one on this forum, and see if it works. if yes i will debug it to find the problem.

for now it helps if i don't use it at all, and it would also help if i could deactivate it somehow. i think i will add an extra variable/switch in the waypont, and set it to OFF before teleport, and put a condition inside the setwindow function's _window part to not do anything while the variable is set to OFF. then set it back to on in the waypoint to ON when teleport finished.

seems like a viable idea? i am a beginner in lua, so i feel i must ask these things until i get more confident

like this (cannot test until i get back from work):

Code: Select all

local function _window()
  if myswitch ~= "OFF" then
         local _charname = string.sub(player.Name,1,7)
         local _timepassed = (os.time() - _starttime)/3600
         local _printtime = _humantime(os.time() - _starttime)
         local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold
         local _goldperhour = string.sub((_goldreceived/_timepassed),1,8)
         local updatedgold = RoMScript('GetPlayerMoney("copper");')
         setWindowName(getHwnd(),sprintf(_charname..": Total gold: "..prettynumber(updatedgold).." Gold per hour: "
         ..prettynumber(_goldperhour).." Time passed: ".._printtime))
  end
end
and before i leave party i will add:
myswitch = "OFF"

after i remake the party at respawn point:
myswitch = "ON"


do you think it would work?

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

Re: changing what is on the MM window.

#14 Post by lisa » Wed Mar 07, 2012 6:51 am

would be easier just to do this

Code: Select all

local function _window()
  if myswitch == "OFF" then return end
         local _charname = string.sub(player.Name,1,7)
         local _timepassed = (os.time() - _starttime)/3600
         local _printtime = _humantime(os.time() - _starttime)
         local _goldreceived = RoMScript('GetPlayerMoney("copper");') - currentgold
         local _goldperhour = string.sub((_goldreceived/_timepassed),1,8)
         local updatedgold = RoMScript('GetPlayerMoney("copper");')
         setWindowName(getHwnd(),sprintf(_charname..": Total gold: "..prettynumber(updatedgold).." Gold per hour: "
         ..prettynumber(_goldperhour).." Time passed: ".._printtime))
end

what "if myswitch == "OFF" then return end" does is if your variable is == "OFF" then it leaves the function and doesn't do anymore code.
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
silinky
Posts: 213
Joined: Mon Nov 23, 2009 5:07 am

Re: changing what is on the MM window.

#15 Post by silinky » Wed Mar 07, 2012 7:03 am

yes, this is more elegant solution than mine. thank you :)

User avatar
gloover
Posts: 304
Joined: Wed Jul 07, 2010 4:31 am

Re: changing what is on the MM window.

#16 Post by gloover » Sun Dec 30, 2012 1:26 pm

Hey experts.

Can someone update the code for TP/hour - that would be great.

thx in advance.

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

Re: changing what is on the MM window.

#17 Post by lisa » Sun Dec 30, 2012 7:17 pm

gloover wrote:Hey experts.

Can someone update the code for TP/hour - that would be great.

thx in advance.
Done, V 1.6

Code: Select all

setwindow("tp")
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

farmforever
Posts: 13
Joined: Thu Jan 24, 2013 11:28 am

Re: changing what is on the MM window.

#18 Post by farmforever » Sun Mar 10, 2013 10:26 pm

can i change it to exp % to next lv ?

please help.

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

Re: changing what is on the MM window.

#19 Post by lisa » Sun Mar 10, 2013 11:21 pm

default bot does that, I didn't see the need to add it to the userfunction when that IS what the bot normally shows.

ohh you want specifically the % required to lvl.

So if you just leveled it would say 100% and if you were half way to leveling it would say 50%, that kind of thing?
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.

#20 Post by WonderBoB » Fri Mar 15, 2013 1:50 pm

The function setWindow(TP) currently does not update correctly, the Current code is:

Code: Select all

	elseif ID == "tp" then
		local starttp = player.TP
		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 _tpreceived = player.TP - starttp
			local _tpperhour = string.sub((_tpreceived/_timepassed),1,8)
			setWindowName(getHwnd(),sprintf(_charname.." TP per hour: "
			.._tpperhour.." Time passed: ".._printtime))
		end
With a simple update to the code as follows:

Code: Select all

	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: "
			.._tpperhour.." Time passed: ".._printtime))
		end
The counter will update and track the TP per hour properly.
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

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests