Page 1 of 2

tracking player name // time // WP // level and now gold

Posted: Tue Jan 11, 2011 9:35 pm
by lisa
Little userfunction I just made up, it stores character details in files in your profiles folder.

--
Ver 1.0 stores name and time stamp.
Ver 1.1 also stores Wp file and lvl.
--

It adds a new line to the end each time it's used.

function name is

Code: Select all

storecharname()
Suguested places to use would be onload of character profile and also added after code of changing character

Code: Select all

sendMacro("}LoginNextToon=true;a={")
         sendMacro("Logout();"); yrest(3*60*1000)
         
         player = CPlayer.new();
         settings.load();
         storecharname()

It allows for multi botting, add in a variable between the (). I was thinking along the lines of account name but it can be anything you want.

if nothing is between () then it creates file aalastcharWP.xml

if say XX between () then it creates file aalastcharWPXX.xml

I deliberately named it with aa so as to keep it at top of folder for easy finding.

Add the file to your rom/userfunctions folder.

Also added a gold tracker
----------
V 1.1
----------
Prints on MM window

Code: Select all

Current gold: 15062
Profit: 0
Elapsed time: 63.035 minutes.
Profit per hour: 0
and also logs data to a file in your profile folder. Might look at changing time posted to be in hours after reaching a time for easier reading.

Call the function in your WP onload to set start time, and then call the function again from your WP just after repairing/selling.

Code: Select all

 goldtracker()

Re: tracking player name and time

Posted: Wed Jan 12, 2011 3:24 am
by lisa
Just an example of the output, I ran my 1-10/10, copied output when it was lvl 7. I can see it took 34 mins for 2-7 and which WP it was on when it lvled.
I obviously replaced char name with XXX.

Code: Select all

 Character name "XXX" waypoint file "ty1.xml" date "01/12/11 17:43:44" player lvl "2"
 Character name "XXX" waypoint file "ty3.xml" date "01/12/11 17:47:19" player lvl "3"
 Character name "XXX" waypoint file "ty3.xml" date "01/12/11 17:51:36" player lvl "4"
 Character name "XXX" waypoint file "ty4.xml" date "01/12/11 18:00:12" player lvl "5"
 Character name "XXX" waypoint file "ty5.xml" date "01/12/11 18:07:52" player lvl "6"
 Character name "XXX" waypoint file "ty8.xml" date "01/12/11 18:17:15" player lvl "7"
Anyone tried it out yet??

Re: tracking player name and time

Posted: Wed Jan 12, 2011 4:27 am
by Othon1001
Thanks for your script

I'm trying probably this evening

exactly what i need :D

Re: tracking player name and time

Posted: Wed Jan 12, 2011 4:58 am
by lisa
Happy to be of help =)

Re: tracking player name // time // WP // level

Posted: Wed Jan 19, 2011 7:20 am
by jduartedj
You should Add this to the User Functions Repository.

Re: tracking player name // time // WP // level

Posted: Wed Jan 19, 2011 7:47 am
by lisa
I considered it but since it's only been downloaded twice, it didn't seem like there was enough interest to add it.

Re: tracking player name // time // WP // level

Posted: Wed Jan 19, 2011 8:25 am
by jduartedj
there is always a point and interest, believe me! Anyway no function is more important the another! please post it!

Re: tracking player name // time // WP // level

Posted: Thu Jan 20, 2011 6:15 am
by Othon1001
I'm modify your script for my owne utility

Code: Select all

if( settings == nil ) then
	include("settings.lua");
end

function storecharinfo(nameplayer,msg)

if nameplayer == nil then nameplayer = "" end

	filename = getExecutionPath() .. "/profiles/aalastcharWP" .. nameplayer .. ".xml";

	file, err = io.open(filename, "a+");
	if( not file ) then
		error(err, 0);
	end


file:write(" Character name \"" ..nameplayer.. "\" waypoint file \"" .. __WPL.FileName .. "\" date \"" .. os.date()); 
file:write("\" Message \"" .. msg .. "\"\n");

file:close();
end
for utilisation

Code: Select all

storecharinfo(player.Name,"Phirius :"..inventory:itemTotalCount(203038))

Thanks a lot for your script

Re: tracking player name // time // WP // level

Posted: Thu Jan 20, 2011 10:44 am
by lisa
nice idea to use it to track how many phirius tokens you have =)

Re: tracking player name // time // WP // level

Posted: Thu Jan 20, 2011 11:06 am
by jduartedj
Or just anything you pass in the second arg!

Re: tracking player name // time // WP // level

Posted: Wed Feb 02, 2011 5:34 am
by Othon1001
My final addon_charinfoWP.lua

Code: Select all

if( settings == nil ) then
	include("settings.lua");
end

function storecharinfo(nameplayer,msg)

if nameplayer == nil then nameplayer = "" end

	filename = getExecutionPath() .. "/logs/" .. nameplayer .. ".log";

	file, err = io.open(filename, "a+");
	if( not file ) then
		error(err, 0);
	end


file:write(nameplayer.. "," .. os.date().. "," .. msg .. "\n");

file:close();
end
Utilisation for phirius

Code: Select all

 storecharinfo(player.Name,",Phirius,"..inventory:itemTotalCount(203038)) 
Utilisation for eggs

Code: Select all

 storecharinfo(player.Name,"Eggs,"..inventory:itemTotalCount(204792)..",Cakes,"..inventory:itemTotalCount(204791))
information in logs/NAME.log (it's csv file type)

Code: Select all

NAMEPLAYER,DATE,Phirius,3600
little script in perl for extraction information from log file

Code: Select all

 
#!/usr/bin/perl -w
use strict;

my $READDIR="..//logs";

opendir(DIR,"$READDIR") or die "Can't opendir $!";
my @READHD=readdir(DIR);
close DIR;

my $totalphirius=0;
my $totaleggs=0;
my $totalcakes=0;

foreach my $File (@READHD) {
	next if ($File eq ".");
	next if ($File eq "..");
	if ($File=~m/\.log$/)	{
		open(MYFILE,$READDIR."//".$File);
		my @array=<MYFILE>;
		close (MYFILE);
		my $numline=@array;
		my $numprintline = $numline - 1 ;
		while($numprintline != $numline) {
			print "$array[$numprintline]" ;
			if ( $array[$numprintline]=~m/Phirius/ ) {
				my ($a,$b,$c,$nbr)=split(/,/,$array[$numprintline]);
				$totalphirius = $totalphirius + $nbr; 
				$numprintline++;
			} elsif ( $array[$numprintline]=~m/Egg/ ) {
				my ($a,$b,$c,$nbreggs,$d,$nbrcakes)=split(/,/,$array[$numprintline]);
				$totaleggs = $totaleggs + $nbreggs;
				$totalcakes = $totalcakes + $nbrcakes;
				$numprintline++;
			} else {
				$numprintline++;
			}
		}
	}
}

print "Total : ".$totalphirius." Phirius ".($totalphirius/30)." Charges\n";
print "Total : ".$totaleggs." Golden Eggs ".$totalcakes." Cakes\n";
ouput from this script

Code: Select all

Total : XXX Phirius XXX Charges
Total : XXX Golden Eggs XXX Cakes

Re: tracking player name // time // WP // level

Posted: Sat Feb 05, 2011 4:01 am
by lisa
Wow, I can see my little userfunction has been helpful in getting you started for something you really wanted to utilise =)

Very nice usage by the way.

Re: tracking player name // time // WP // level

Posted: Sun Feb 06, 2011 12:36 am
by lisa
Your usage actually got me thinking, I have always wanted an item tracking addon like I used to have when playing wow called altoholic.
I am thinking I could use an onload in the profile to save all bag info to a file and then use something similar with your pearl to make it searchable.

Might take some time to get it all organised though, have to plan best way to organise the info first.

Re: tracking player name // time // WP // level

Posted: Sun Feb 06, 2011 12:40 am
by rock5
Maybe you could make use of the Inventory Viewer addon that does that.

Re: tracking player name // time // WP // level

Posted: Sun Feb 06, 2011 12:46 am
by lisa
I'll check it out, thanks

That addon works pretty good, I'd like a way to check items out of RoM though, not high on my priority list atm. Might look into doing it in a few weeks.

Re: tracking player name // time // WP // level

Posted: Sat Feb 12, 2011 5:54 am
by Rom Botter
Othon1001 wrote:My final addon_charinfoWP.lua

Code: Select all

if( settings == nil ) then
	include("settings.lua");
end

function storecharinfo(nameplayer,msg)

if nameplayer == nil then nameplayer = "" end

	filename = getExecutionPath() .. "/logs/" .. nameplayer .. ".log";

	file, err = io.open(filename, "a+");
	if( not file ) then
		error(err, 0);
	end


file:write(nameplayer.. "," .. os.date().. "," .. msg .. "\n");

file:close();
end
Utilisation for phirius

Code: Select all

 storecharinfo(player.Name,",Phirius,"..inventory:itemTotalCount(203038)) 
Utilisation for eggs

Code: Select all

 storecharinfo(player.Name,"Eggs,"..inventory:itemTotalCount(204792)..",Cakes,"..inventory:itemTotalCount(204791))
information in logs/NAME.log (it's csv file type)

Code: Select all

NAMEPLAYER,DATE,Phirius,3600
little script in perl for extraction information from log file

Code: Select all

 
#!/usr/bin/perl -w
use strict;

my $READDIR="..//logs";

opendir(DIR,"$READDIR") or die "Can't opendir $!";
my @READHD=readdir(DIR);
close DIR;

my $totalphirius=0;
my $totaleggs=0;
my $totalcakes=0;

foreach my $File (@READHD) {
	next if ($File eq ".");
	next if ($File eq "..");
	if ($File=~m/\.log$/)	{
		open(MYFILE,$READDIR."//".$File);
		my @array=<MYFILE>;
		close (MYFILE);
		my $numline=@array;
		my $numprintline = $numline - 1 ;
		while($numprintline != $numline) {
			print "$array[$numprintline]" ;
			if ( $array[$numprintline]=~m/Phirius/ ) {
				my ($a,$b,$c,$nbr)=split(/,/,$array[$numprintline]);
				$totalphirius = $totalphirius + $nbr; 
				$numprintline++;
			} elsif ( $array[$numprintline]=~m/Egg/ ) {
				my ($a,$b,$c,$nbreggs,$d,$nbrcakes)=split(/,/,$array[$numprintline]);
				$totaleggs = $totaleggs + $nbreggs;
				$totalcakes = $totalcakes + $nbrcakes;
				$numprintline++;
			} else {
				$numprintline++;
			}
		}
	}
}

print "Total : ".$totalphirius." Phirius ".($totalphirius/30)." Charges\n";
print "Total : ".$totaleggs." Golden Eggs ".$totalcakes." Cakes\n";
ouput from this script

Code: Select all

Total : XXX Phirius XXX Charges
Total : XXX Golden Eggs XXX Cakes

where do i put the script to extract the data from the logs?

and this script also works when the bot is still running?? e.g i dont have to alt tab to game to check eggs and cakes, i can just run that lua script and it will extract the info for me?

Re: tracking player name // time // WP // level

Posted: Sat Feb 12, 2011 6:19 am
by swietlowka
lisa, if u are going to make something like itemviewer addon it could be great because the original file gets erased a lot (imho), one that would be outside SaveVariables.lua would mean a lot to me ;)
acctualy i would somehow like all the addons to be stored in an outside file, because of the above glitch...
reading the data outside of rom would also be nice though...

and i really would like to read thru the log file in search for certain words and items...
so id like also knwo like rom botter how exactly do i run the perl code?

Re: tracking player name // time // WP // level

Posted: Sat Feb 12, 2011 8:11 am
by lisa
the pearl code and such was created by Othon1001, I haven't tested it as yet.
Had a lot on my plate lately.

Re: tracking player name // time // WP // level

Posted: Sat Feb 12, 2011 9:20 am
by lisa
Trouble I find with inventory viewer which is the same for all addons that save data is this.
They use the RoM functions VARIABLES_LOADED and SAVE_VARIABLES and RoM isn't designed for multiple clients on the same machine. So each RoM client loads the data in savevariables.lua and save the data when called for but another client may have already saved their information after the last client loaded the information. So basically anything saved by the other client is lost.

This means that the info in savevariables.lua is basically useless to us as most of us would use more then 1 client.

I think to do this efficiently for our situation would require 1 of a couple of options.

1. rewrite the addon to save the data in a different file system using character names for different files so the data will never overwrite each other. Would take a while as would need to basically guess what the RoM functions are and create similar ones.

2. Write a whole new system for storing information similar to the userfunction that this topic is about and have the data accessible out of both RoM and MM, pretty much like what Othon1001 has done. I wouldn't save all the info that IV saves, that would take me months to write lol

3. I will no doubt come up with this option soonish and start playing around.


Option 1 sux and I'm not really interesting in going down that path.

Option 2 is the most viable and wouldn't be to difficult to do, to keep the information accurate it would need to be updated regularly, it could be setup to update on a timed interval but this would add to whats required to run each bot. If you did it onload then you would only get accurate info after first starting up bot which isn't ideal. If you used multiple machines then the info would only be accurate if you only used accounts perticular machines. You could prob set up the files to be saved in a shared folder though, that would work.

Ok getting to indepth here yet again, I've been told I over think things lol

Option 2 sounds best for now until I come up with option 3 =)

Re: tracking player name // time // WP // level

Posted: Sat Feb 12, 2011 10:39 am
by rock5
Actually I think option 1 will have the same problem. If client 1 and client 2 are running and you close client 1, it will save new info under that characters name. But when you close client 2, because it hasn't got that info, when it saves its data I think it will still erase client 1s data.

Option 2 wouldn't be hard to do. Just a matter of collecting data from inventory, equipped gear etc. into a well structured table and just saving the whole thing to a file. I believe Administrator has now added a couple of functions for writing and reading tables to files in the last version of macromicro.

Code: Select all

table.save(  tbl,filename )
tbl = table.load( sfile )
The problems I foresee are:
1. What happens if more than 1 client tries to read/write to the file at the same time.
2. It's not just a matter of reading the data, you also have to consolidate the new data with the old. Might be a bit tricky but can be done.