NoobBotter's LogPlayer Userfunction

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
noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

NoobBotter's LogPlayer Userfunction

#1 Post by noobbotter » Fri Jun 19, 2015 5:53 pm

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.
Attachments
userfunction_LogPlayer.lua
LogPlayer version 1.1
(2.02 KiB) Downloaded 223 times
Last edited by noobbotter on Sat Jun 20, 2015 5:36 am, edited 1 time in total.

Testa
Posts: 28
Joined: Wed Apr 29, 2015 1:59 am

Re: NoobBotter's LogPlayer Userfunction

#2 Post by Testa » Sat Jun 20, 2015 3:28 am

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>
Sorry about the bad english

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

Re: NoobBotter's LogPlayer Userfunction

#3 Post by rock5 » Sat Jun 20, 2015 3:47 am

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.
  • 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

leroy
Posts: 19
Joined: Thu Sep 19, 2013 11:57 am

Re: NoobBotter's LogPlayer Userfunction

#4 Post by leroy » Sat Jun 20, 2015 5:09 am

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.

noobbotter
Posts: 527
Joined: Fri Aug 31, 2012 1:15 pm

Re: NoobBotter's LogPlayer Userfunction

#5 Post by noobbotter » Sat Jun 20, 2015 5:37 am

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.

Testa
Posts: 28
Joined: Wed Apr 29, 2015 1:59 am

Re: NoobBotter's LogPlayer Userfunction

#6 Post by Testa » Sat Jun 20, 2015 9:06 am

Version 1.1 works great after a few tests big thx! i´ll test it more the next weeks
Sorry about the bad english

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#7 Post by beanybabe » Tue Jun 23, 2015 6:08 pm

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.

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

Re: NoobBotter's LogPlayer Userfunction

#8 Post by lisa » Tue Jun 23, 2015 9:49 pm

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)
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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#9 Post by beanybabe » Sun Jun 28, 2015 4:51 am

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>

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#10 Post by beanybabe » Tue Jun 30, 2015 4:28 pm

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.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#11 Post by beanybabe » Mon Jul 20, 2015 2:24 pm

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.
Attachments
userfunction_LogPlayer.lua
(2.44 KiB) Downloaded 196 times

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#12 Post by beanybabe » Fri Aug 07, 2015 9:36 am

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?

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

Re: NoobBotter's LogPlayer Userfunction

#13 Post by BlubBlab » Fri Aug 07, 2015 11:22 am

For this we have XML files but in theory you can write luacode files and than include them.
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

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

Re: NoobBotter's LogPlayer Userfunction

#14 Post by rock5 » Fri Aug 07, 2015 11:26 am

The easiest way is just to use the table.save and table.load commands.
  • 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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#15 Post by beanybabe » Sat Aug 08, 2015 3:25 pm

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.

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

Re: NoobBotter's LogPlayer Userfunction

#16 Post by rock5 » Sun Aug 09, 2015 1:31 pm

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.
  • 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
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#17 Post by beanybabe » Sun Aug 09, 2015 6:02 pm

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.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#18 Post by beanybabe » Tue Nov 10, 2015 5:43 pm

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.

User avatar
beanybabe
Posts: 647
Joined: Wed Mar 06, 2013 1:27 am

Re: NoobBotter's LogPlayer Userfunction

#19 Post by beanybabe » Mon Feb 08, 2016 7:37 am

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>

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

Re: NoobBotter's LogPlayer Userfunction

#20 Post by lisa » Mon Feb 08, 2016 10:52 pm

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.
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

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests