Page 1 of 2
NoobBotter's LogPlayer Userfunction
Posted: Fri Jun 19, 2015 5:53 pm
by noobbotter
I've been using some logging that I realized might work well as a userfunction so today I converted it over to a userfunction.
What it does/how to use it:
With this userfunction installed in your userfunctions folder, when your bot has finished doing what it's doing, run logPlayer() before logging in the next character and it will add some basic status information to a single log file. All characters get logged in to this single file and it overwrites old entries for the same player, with new entries at the bottom.
Here's a sample of what the log file looks like:
Code: Select all
Date/Time Name Level Max HP Gold Shells Tokens Mems Puris
06/04/15 00:22:42 BotName1 51 2,350 36,436 320 10 0 0
06/13/15 19:09:34 BotName2 91 64,685 518,850 350 3,995 0 0
06/19/15 07:09:14 BotName3 57 5,631 484,340 580 935 0 0
06/19/15 07:36:05 BotName4 57 5,761 825,573 840 965 0 1
06/19/15 08:02:21 BotName5 58 5,534 1,355,825 450 545 0 0
06/19/15 08:34:42 BotName6 58 7,270 1,006,804 340 1,670 0 0
06/19/15 09:06:42 BotName7 58 4,946 770,693 520 750 0 2
06/19/15 09:39:48 BotName8 57 5,424 808,665 270 625 0 0
06/19/15 11:04:30 BotName9 63 13,677 1,267,883 530 1,600 0 3
06/19/15 11:37:12 BotName10 52 6,075 596,617 520 1,020 0 1
06/19/15 12:06:58 BotName11 58 5,889 1,205,296 810 730 0 0
06/19/15 13:02:15 BotName12 54 3,173 420,836 580 1,285 0 0
(It actually aligns everything correctly but for some reason doesn't show up properly on this page)
The userfunction will check for existence of the log file and if it doesn't already exist, it will create it and create the headers. Then every time it is run after that it will update the entry for the current player that runs the script (or add an entry if one isn't already in the log). I use this log daily to get a quick look at how many tokens, shells, gold, and puris my bots have. I also use it if my bot script or client crashes so I can see which bot was the last one to finish his rounds, which would be the one on the bottom.
I have fixed the problems with the original file and verified it now works.
Re: NoobBotter's LogPlayer Userfunction
Posted: Sat Jun 20, 2015 3:28 am
by Testa
i get some error
Code: Select all
2015-06-20 10:25:23 - [string "..."]:14: attempt to call global 'logPlayer' (a nil value)
Testscript:
Code: Select all
<waypoints type="TRAVEL">
<onLoad>
logPlayer();
player:sleep()
</onLoad>
</waypoints>
Re: NoobBotter's LogPlayer Userfunction
Posted: Sat Jun 20, 2015 3:47 am
by rock5
userfunctions are lua files not xml so it needs to be renamed. Also the first 2 lines
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL" >
<onLoad>
should be removed. Lastly it looks like you use an undefined variable
_name. Probably you meant to use
player.Name.
Nice work by the way. It's definitely useful because it overwrites previous entries keeping things neat. I don't know it that was ever implemented in other logging userfunctions although I believe it was discussed.
Re: NoobBotter's LogPlayer Userfunction
Posted: Sat Jun 20, 2015 5:09 am
by leroy
After changing the above it errors on the "local newentry" line:
Code: Select all
onLoad error: ...cro/scripts/rom/userfunctions/userfunction_LogPlayer.lua:8: bad
argument #1 to 'match' (string expected, got nil)
And I feel so stupid but no idea what to change to make it work.
Re: NoobBotter's LogPlayer Userfunction
Posted: Sat Jun 20, 2015 5:37 am
by noobbotter
I just updated it, fixed all the problems I had in it, and verified it works now. Download version 1.1 and it should be fine.
Re: NoobBotter's LogPlayer Userfunction
Posted: Sat Jun 20, 2015 9:06 am
by Testa
Version 1.1 works great after a few tests big thx! i´ll test it more the next weeks
Re: NoobBotter's LogPlayer Userfunction
Posted: Tue Jun 23, 2015 6:08 pm
by beanybabe
could this be put in default profile? then make script to log each player with default profile.
you could then have list them all handy.
Re: NoobBotter's LogPlayer Userfunction
Posted: Tue Jun 23, 2015 9:49 pm
by lisa
rock5 wrote:
Nice work by the way. It's definitely useful because it overwrites previous entries keeping things neat. I don't know it that was ever implemented in other logging userfunctions although I believe it was discussed.
Yeah mine had the option to overwrite if you wanted to but mine probably had to many user options so people had to actually think about what they wanted logged lol
--=== _logtype ===--
--"new" overwrites existing log file with new info
--"add" add to new line at end of file (this is default if not specified)
Re: NoobBotter's LogPlayer Userfunction
Posted: Sun Jun 28, 2015 4:51 am
by beanybabe
I made this with your function it goes thru all the chars you add and makes a log. start rom and log first char on first account then run this. if rom crash start at nest character. log is in rom/logs
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
-- code to create a log file of characters monies to a file.
<onLoad>
-- relog features requires fastLogin and userfunction_LoginNextChar.lua
-- changes:
doRelog = true; change to false to log just 1 char.
function relog()
SetCharList({
-- enter account number and char numbers that you like to run this script
{account=1 , chars= {1,2,3,4,5,6,7,8}},
{account=2 , chars= {1,2,3,4,5,6,7,8}},
{account=3 , chars= {1,2,3,4,5,6,7,8}},
{account=4 , chars= {1,2,3,4,5,6,7,8}},
});
LoginNextChar();
loadProfile();
end
while 1 == 1 do
logPlayer();
if doRelog then
relog()
else
error("Bot stopped.", 0);
end
end
</onLoad>
</waypoints>
Re: NoobBotter's LogPlayer Userfunction
Posted: Tue Jun 30, 2015 4:28 pm
by beanybabe
I like the list I got from this its handy. It made me start thinking.
Can we get list of other items at same time, like a second list of certain items characters may have in inventory or special runes they may have in gear or in bag.
Another list I can think of is to list the stats on a char items like pulls and drops in bags to make it easier to find what you may need.
It takes a quite a long time to log thru several accounts It would not take that much more time to create several lists at same time. It could also be made to run to player house and check bank items. list plus stones and drillers.
I was able to load that other list into a open office spreadsheet and look at it if I used a tab-space delimiter on paste special.
Re: NoobBotter's LogPlayer Userfunction
Posted: Mon Jul 20, 2015 2:24 pm
by beanybabe
I made a change to your log player using code from the make fusion to get total of tokens in bank.
it should show bank + bag total
I also added a new column for transmuter charges
It may be better to move the bank amount to its own column in case someone needs onhand total
Rename the old one to .back if you try this one It seems to work ok. If nob likes it he can call it his.
Re: NoobBotter's LogPlayer Userfunction
Posted: Fri Aug 07, 2015 9:36 am
by beanybabe
Did anyone ever write a function or some code to read back in the log file created by this to take some action depending on values found?
Re: NoobBotter's LogPlayer Userfunction
Posted: Fri Aug 07, 2015 11:22 am
by BlubBlab
For this we have XML files but in theory you can write luacode files and than include them.
Re: NoobBotter's LogPlayer Userfunction
Posted: Fri Aug 07, 2015 11:26 am
by rock5
The easiest way is just to use the
table.save and
table.load commands.
Re: NoobBotter's LogPlayer Userfunction
Posted: Sat Aug 08, 2015 3:25 pm
by beanybabe
http://lua-users.org/wiki/SaveTableToFile found this will try to figure it out thanks.
I have been reading about tables and arrays need to learn them also.
Re: NoobBotter's LogPlayer Userfunction
Posted: Sun Aug 09, 2015 1:31 pm
by rock5
You don't need to use outside functions. Micromacro has the table save and load functions. The saved file might be hard to follow but it works.
Re: NoobBotter's LogPlayer Userfunction
Posted: Sun Aug 09, 2015 6:02 pm
by beanybabe
thanks after trying to read that page I got the idea it was more of what micromacro did and not what I needed. I think i just need to use formated reads to get the data.
I am going to try use some wp you made while back for mailing daily's and needed to find which char needed some. I added counts for dailys items and bag space also to log player I am using.
Re: NoobBotter's LogPlayer Userfunction
Posted: Tue Nov 10, 2015 5:43 pm
by beanybabe
This may needs some more fields
guild name
main class / off class
if they need to get mail or not (if possible without running to mailbox)
possible others to add
arcanium coins
eoj coins
here is what i have mine doing so far.
Date/Time Name Level Max HP Gold Shells Tokens Mems Puris charges daily space
daily = items in bag that can be turned in for dailys
space is free space in inventory.
Re: NoobBotter's LogPlayer Userfunction
Posted: Mon Feb 08, 2016 7:37 am
by beanybabe
I ran into a problem with global and local. I get error when using local on a table. I was wondering if it because the onload and waypoint are not both local to each other ? It works ok if I remove the local. I want to try this in the profile section so it auto updates the info and I need not include this in every waypoint.
Code: Select all
<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onload>
local classtable = {"WARRIOR", "SCOUT", "ROGUE", "MAGE", "PRIEST", "KNIGHT", "WARDEN", "WARDEN", "DRUID", "WARLOCK", "CHAMPION"} -- If I put local on this line I get a error
-- lots of code
</onload>
<!-- # 1 --><waypoint x="...>
...
...
<!-- # 99 --><waypoint x="...">
logPlayer(classtable[player.Class1],classtable[player.Class2]);
</waypoint>
</waypoints>
Re: NoobBotter's LogPlayer Userfunction
Posted: Mon Feb 08, 2016 10:52 pm
by lisa
local in onload will only work if used in onload, if used anywhere else, like in a waypoint then no local will not work.
Just think of the onload and every single waypoint as different files and you will be fine.