Page 2 of 2

Re: create log file userfunction

Posted: Sat Jul 28, 2012 11:00 am
by Administrator
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.

Re: create log file userfunction

Posted: Sat Jul 28, 2012 5:45 pm
by lisa
Administrator wrote:Except, in the development forum, I usually yell and throw things. Otherwise, pretty similar.
lol

Re: create log file userfunction (logInfo)

Posted: Sat Dec 22, 2012 2:01 am
by SpringSun
thanks for this helpful waypoints

Re: create log file userfunction (logInfo)

Posted: Tue Mar 12, 2013 7:34 pm
by lisa
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

Re: create log file userfunction (logInfo)

Posted: Fri Mar 22, 2013 10:37 am
by lisa
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

Re: create log file userfunction (logInfo)

Posted: Fri Mar 22, 2013 3:54 pm
by dr-nuker
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 :;)

Re: create log file userfunction (logInfo)

Posted: Fri Mar 22, 2013 7:34 pm
by lisa
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

Re: create log file userfunction (logInfo)

Posted: Thu Mar 28, 2013 11:25 am
by attackspeedzero
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

Re: create log file userfunction (logInfo)

Posted: Thu Mar 28, 2013 11:28 am
by rock5
Strange, I thought bank.MaxSlots also equals 300. Unless you changed it of course.

Re: create log file userfunction (logInfo)

Posted: Thu Mar 28, 2013 11:37 am
by attackspeedzero
Was 200 in my bank.lua file, not sure if I have a different version than what's current.

Re: create log file userfunction (logInfo)

Posted: Thu Mar 28, 2013 5:45 pm
by lisa
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.

Re: create log file userfunction (logInfo)

Posted: Thu Nov 06, 2014 6:50 am
by Desmond
create log file userfunction (logInfo) what is it? What does it do?

Re: create log file userfunction (logInfo)

Posted: Fri Nov 07, 2014 2:05 pm
by BlubBlab
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.