create log file userfunction (logInfo)

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
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: create log file userfunction

#21 Post by Administrator » Sat Jul 28, 2012 11:00 am

If nothing else this topic would give people an idea of what normally happens in the development section of forum, ideas get thrown around with different solutions and possible issues until in the end we get something that works to do what we want it to do ;)
Except, in the development forum, I usually yell and throw things. Otherwise, pretty similar.

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

Re: create log file userfunction

#22 Post by lisa » Sat Jul 28, 2012 5:45 pm

Administrator wrote:Except, in the development forum, I usually yell and throw things. Otherwise, pretty similar.
lol
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

SpringSun
Posts: 4
Joined: Thu May 24, 2012 9:37 pm

Re: create log file userfunction (logInfo)

#23 Post by SpringSun » Sat Dec 22, 2012 2:01 am

thanks for this helpful waypoints

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

Re: create log file userfunction (logInfo)

#24 Post by lisa » Tue Mar 12, 2013 7:34 pm

I added this to a userfunction to get a log of errors.

Code: Select all

function logtrace()
	errorCallback()
	logInfo(player.Name,debug.traceback(),true,"crashes")
end

atError(logtrace)
basically it now does the usual code when an error occurs, which is the errorCallback() but it will also do the logInfo aswell which looks something like this. Saved in a file that is named same as the characters name in the logs/crashes folder.

Code: Select all

03/13/13 10:40:44 stack traceback:
	...s/romglobal/userfunctions/userfunction_lisafunctions.lua:558: in function '__ERROR_CALLBACK'
	C:\micromacro\lib\lib.lua:650: in function <C:\micromacro\lib\lib.lua:562>
	[C]: in function 'pcall'
	C:\micromacro\lib\lib.lua:736: in function 'startMacro'
	scripts\rom/bot.lua:1131: in main chunk
This is just the error when exiting commandline.

I have added it to the logger userfunction with an option at the top to turn on error logging, give it a try.

Code: Select all

local logerrors = false -- change to true if you want to log the errors the bot has
Attachments
userfunction_logger.lua
V 2.4
(1.5 KiB) Downloaded 208 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: create log file userfunction (logInfo)

#25 Post by lisa » Fri Mar 22, 2013 10:37 am

I get a bit sick of trying to remember where stuff is on all my accounts.

So I made up this userfunction and figured I would share it.

Code: Select all

function logloot()

	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 acn = RoMScript("GetAccountName()")
	local gold = RoMScript('GetPlayerMoney("copper");')
	logInfo(player.Name, "", true, "loot/"..acn, "new")
	logInfo(player.Name, "Gold: "..comma_value(gold), false, "loot/"..acn)
	logInfo(player.Name, "--=== Bank ===--", false, "loot/"..acn)
	logInfo(player.Name, "Slot:\tCount:\tName:", false, "loot/"..acn)
	bank:update()
	for i = 1, 300 do
		if bank.BagSlot[i].Id ~= 0 then
			logInfo(player.Name, i.."\t\t"..bank.BagSlot[i].ItemCount.."\t\t"..bank.BagSlot[i].Name, false, "loot/"..acn)
		end
	end
	logInfo(player.Name, "\n--=== Item Shop ===--", false, "loot/"..acn)
	logInfo(player.Name, "Slot:\tCount:\tName:", false, "loot/"..acn)
	inventory:update()
	for slot = 1, 60 do
		item = inventory.BagSlot[slot]
 	    if item.Available and  item.Name ~= "<EMPTY>" then
			logInfo(player.Name, slot.."\t\t"..item.ItemCount.."\t\t"..item.Name, false, "loot/"..acn)
		end
	end
	logInfo(player.Name, "\n--=== Inventory ===--", false, "loot/"..acn)
	logInfo(player.Name, "Slot:\tCount:\tName:", false, "loot/"..acn)
	for slot = 61, 240 do
		item = inventory.BagSlot[slot]
 	    if item.Available and  item.Name ~= "<EMPTY>" then
			logInfo(player.Name, slot.."\t\t"..item.ItemCount.."\t\t"..item.Name, false, "loot/"..acn)
		end
	end
end
Basically it will overwrite the file for that character each time the function is called, can either just pop it in the profile onload or do up a WP like this and it will just cycle through an account saving the item info.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints>
<onLoad>
	logloot()
	ChangeChar()
	waitForLoadingScreen()
	yrest(3000)
	loadProfile()
	loadPaths(__WPL.FileName)
</onLoad>
</waypoints>
This is an example.

Code: Select all

03/23/13 01:23:25 
--=== Bank ===--
Slot:	Count:	Name:
1		1		Suppression Heavy Boots of the Fort
2		2		Temporary Mount Use Voucher
3		2		Witchcraft Scroll Collection Box
4		21		Royal Furniture Recipe Collection Box
5		99		Simple Repair Hammer
6		99		Simple Repair Hammer
7		34		Simple Repair Hammer
8		99		Craftsman's Recipe Coupon
9		2		Craftsman's Recipe Coupon
10		60		Material Package for Magical Instruments
11		91		Horse Rental Ticket
12		5		Phirius Elixir - Type D
13		20		Phirius Elixir - Type C
14		60		Phirius Elixir - Type B
15		99		Phirius Elixir - Type A
16		61		Phirius Elixir - Type A
17		11		Phirius Potion - Type D
18		29		Phirius Potion - Type C
19		83		Phirius Potion - Type B
20		1		Phirius Special Water - Type C
21		2		Phirius Special Water - Type A
22		125		Ancient Memento
23		1		Fruit of Extra Experience
24		20		Vanquisher's Loot
25		156		Ghost Card

--=== Item Shop ===--
Slot:	Count:	Name:
9		1		Little Jumping Flower - Pet Egg (30 Days)
13		13		Golden Repair Hammer
14		1		High Quality Experience Potion
19		17		Transport Rune
20		11		Home-sweet-home
21		8		Marking Ink
23		2		Curse Scroll (Wicked Freeze)
24		4		Curse Scroll (Instant Transport)
25		4		Curse Scroll (Time Extension)
26		2		Curse Scroll (Cannon Permutation)
29		1		Purified Fusion Stone
44		2		Advanced Weapon Driller
45		1		Phoenix's Redemption
47		5		Midsummer Heat
48		5		Nebula Diffusion
49		10		Golden Brilliance
50		1		Advanced Skill Reset Stone

--=== Inventory ===--
Slot:	Count:	Name:
61		1		Recipe - Tador's Brilliant Armor
62		1		Vengeance Leather Boots of the Fort
63		1		Vengeance Leather Boots of the Fort
64		1		Vengeance Leather Boots of the Fort
65		1		Vengeance Leather Boots of the Fort
66		1		Pulverizing Light Boots of the Fort
67		1		Fusion Stone
68		1		Fusion Stone
69		1		Fusion Stone
70		1		Fusion Stone
71		1		Fusion Stone
72		1		Fusion Stone
73		24		Simple Repair Hammer
74		10		Craftsman's Recipe Coupon
75		13		Material Package for Magical Instruments
76		11		Horse Rental Ticket
77		15		Mana Potion
78		15		Healing Potion
79		30		Healing Potion
80		30		Healing Potion
81		23		Phirius Potion - Type C
82		45		Phirius Potion - Type B
83		98		Phirius Potion - Type A
84		560		Phirius Shell
85		2		Vanquisher's Loot
86		14		Ghost Card
87		215		Phirius Token Coin
88		60		Wind Element
89		4		Craft Festival Celebration Certificate
90		1		Recipe - Royal Decorative Armor
91		10		Defense III
92		1		Fusion Stone
93		1		Fusion Stone
94		1		Fusion Stone
95		1		Fusion Stone
96		1		Fusion Stone
97		1		Fusion Stone
98		1		Fusion Stone
99		3		Royal Furniture Recipe Collection Box
100		10		Golden Brilliance
101		2		Magic Hormone
102		2		Certificate: The Key to Survival
103		4		Certificate: The Key to Timing
104		6		Frog Celebration Certificate
105		5		Autumn Banquet Voucher
106		1		Colorful Firework Package
107		1		4th Anniversary Gasha
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

dr-nuker
Posts: 145
Joined: Sun Oct 09, 2011 7:33 am

Re: create log file userfunction (logInfo)

#26 Post by dr-nuker » Fri Mar 22, 2013 3:54 pm

lisa wrote:I get a bit sick of trying to remember where stuff is on all my accounts.
So I made up this userfunction and figured I would share it.
This is great!
Usually i use Inventory viewer but as soon as the game crashed (which it always does when i close it or bot or anything else) it looses the data from the session.
I do updates of the profile for rom but still miserably bad to lose data!
This will help a lot :;)

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

Re: create log file userfunction (logInfo)

#27 Post by lisa » Fri Mar 22, 2013 7:34 pm

Added in gold aswell, looks like this

Code: Select all

03/23/13 10:30:30 
Gold: 119,442
--=== Bank ===--
Slot:	Count:	Name:
I just use notepad++ and do find in files for the loot folder and I see where all the items I am searching for are. A search for "Gold:" also gives me a complete list of all the gold I have.

I also changed Rock's loginnextchar userfunction so it uses the logloot() before logging the character.

Code: Select all

function ChangeChar(char, acc, chan)
	if logloot then logloot() 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
attackspeedzero
Posts: 28
Joined: Sat Mar 02, 2013 6:24 pm

Re: create log file userfunction (logInfo)

#28 Post by attackspeedzero » Thu Mar 28, 2013 11:25 am

Thanks for this awesome script!

I ran into a lua error issue with the bank section of function logloot() ...

Fixed by changing

Code: Select all

bank:update()
for i = 1, 300 do
to

Code: Select all

bank:update()
for i = 1, bank.MaxSlots do
Last edited by attackspeedzero on Thu Mar 28, 2013 11:37 am, edited 1 time in total.

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

Re: create log file userfunction (logInfo)

#29 Post by rock5 » Thu Mar 28, 2013 11:28 am

Strange, I thought bank.MaxSlots also equals 300. Unless you changed it of course.
  • 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
attackspeedzero
Posts: 28
Joined: Sat Mar 02, 2013 6:24 pm

Re: create log file userfunction (logInfo)

#30 Post by attackspeedzero » Thu Mar 28, 2013 11:37 am

Was 200 in my bank.lua file, not sure if I have a different version than what's current.

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

Re: create log file userfunction (logInfo)

#31 Post by lisa » Thu Mar 28, 2013 5:45 pm

attackspeedzero wrote:Was 200 in my bank.lua file, not sure if I have a different version than what's current.
Hmm I forgot older clients would need to be 200, setting it to the bank.MaxSlots is a good idea.
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
Desmond
Posts: 184
Joined: Wed Jan 08, 2014 4:39 pm
Location: Ukraine

Re: create log file userfunction (logInfo)

#32 Post by Desmond » Thu Nov 06, 2014 6:50 am

create log file userfunction (logInfo) what is it? What does it do?

User avatar
BlubBlab
Posts: 948
Joined: Fri Nov 30, 2012 11:33 pm
Location: My little Pony cafe

Re: create log file userfunction (logInfo)

#33 Post by BlubBlab » Fri Nov 07, 2014 2:05 pm

It is simple for making a logfile for the bot as a txt.
When you have it many mini-game scripts will write a report when finished.
Jack-of-all-trades, but master-of-only of a few :D

My Reps:
https://github.com/BlubBlab/Micromacro-with-OpenCV (My version of MM2 with OpenCV and for MS Visual Studio)
https://github.com/BlubBlab/rom-bot (rombot with no stop WP and advanced human emulation mode and some other extensions)
https://github.com/BlubBlab/Micromacro-2-Bot-Framework ( A work in progress )
My Tools : viewtopic.php?f=10&t=6226

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests