writing special data into file

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

writing special data into file

#1 Post by Personalausweis » Wed Oct 27, 2010 10:29 am

Hello,

is there any posibility to write chosen data with MM into a file?

i have a daylie bot for tokens running, before he logs out and starts the next character, he shall write data like "amount of tokens" and "amount of AT charges" into a txt (or other) file.

so when i look them up in the morning i know exactly (whithout logging into all of them):
1. if they did all 10 quests
2. how many charges i have to use
3. when it is necessary to buy new charges

greetz

runensammler
Posts: 13
Joined: Mon Apr 06, 2009 6:20 am

Re: writing special data into file

#2 Post by runensammler » Wed Oct 27, 2010 4:33 pm

Hi.

Create a file addon_writetokens.lua in the userfuntions

Copy the code in the file

Code: Select all

function write_tokens()
	servername = RoMScript("GetServerName();");
	accountname = RoMScript("GetAccountName();");
	mmfolder = getExecutionPath();
	os.execute("mkdir "..mmfolder.."//logs//"..accountname.."//"..servername)
	logfile = assert(io.open(mmfolder.."/logs/"..accountname.."/"..servername.."/"..player.Name..".txt","w+"));
        Phirius = inventory:getItemCount(203038)
	logfile:write(Pirius.."\n")
        Charges = RoMScript("GetMagicBoxEnergy()");
	logfile:write(Charges.."\n");
	logfile:close();
end
Add the call for this funtion in your waypoint file just befor you end the bot.

It will create a Directory for each account and create a file for each character with ammount of tokens in the first line and number of charges in the second line. if the file exists it will be overwriten.

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: writing special data into file

#3 Post by Personalausweis » Thu Oct 28, 2010 5:24 am

wow, thanks a lot.

will test it and reply as soon as server get online again :)


€dit: works so far, as i dont get an error ^^
but where does he saves the txt file?
if i read it right it must be MM folder (where it is executed) and there he creates a folder Log
but he did not

runensammler
Posts: 13
Joined: Mon Apr 06, 2009 6:20 am

Re: writing special data into file

#4 Post by runensammler » Thu Oct 28, 2010 1:34 pm

sry - but it's no good to post untested code - espatially if u worked whole day :shock:

Code: Select all

function write_tokens()
   accountname = RoMScript("GetAccountName();");
   mmfolder = "c:\\temp"
   os.execute("mkdir "..mmfolder.."\\logs\\"..accountname);
   logfile = assert(io.open(mmfolder.."\\logs\\"..accountname.."\\"..player.Name..".txt","w+"));
        Phirius = inventory:getItemCount(203038)
   logfile:write(Phirius.."\n")
        Charges = RoMScript("GetMagicBoxEnergy()");
   logfile:write(Charges.."\n");
   logfile:close();
end
this time i tested it and this should work.

just replace "c:\\temp" with the path you want - but all \ must be \\ dubble !!!

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: writing special data into file

#5 Post by Personalausweis » Thu Oct 28, 2010 2:23 pm

When i call the function with:
sendMacro("write_tokens();");

error occurs, see screenshot
Attachments
Error.jpg

S3v3n11
Posts: 91
Joined: Thu Jul 09, 2009 7:37 am

Re: writing special data into file

#6 Post by S3v3n11 » Thu Oct 28, 2010 7:12 pm

Don't use sendmacro. It is a local call not a ROM call.

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: writing special data into file

#7 Post by Personalausweis » Thu Oct 28, 2010 9:17 pm

if i use it in the waypoint like this:

write_tokens();


it doesn't work either.
perhaps it's because its 4 in the morning that i cant find out what to do ^^

runensammler
Posts: 13
Joined: Mon Apr 06, 2009 6:20 am

Re: writing special data into file

#8 Post by runensammler » Fri Oct 29, 2010 1:05 pm

But that's the right way.

just before you end the bot you add

write_tokens();

in your waypoint file

Caution: if you are using W7 start the bot as admin to have suffitiant rights.

hope it helps.

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: writing special data into file

#9 Post by Personalausweis » Sun Oct 31, 2010 3:24 am

this is the part in the waypoint:

Code: Select all

			else
				write_tokens(); 
				sendMacro("}LoginNextToon=true;a={")
        			sendMacro("Logout();"); yrest(60*1000);
			        player = CPlayer.new();
			        settings.load();
			        settings.loadProfile("Daylie");
			        yrest (4000)
         			loadPaths("Daylie");
			end
when he finished all daylies following error occurs:

[string "..."]:25: attempt to call global 'write:tokens' (a nil value)

runensammler
Posts: 13
Joined: Mon Apr 06, 2009 6:20 am

Re: writing special data into file

#10 Post by runensammler » Mon Nov 01, 2010 12:24 pm

Hi.

Have you put the the Write_tokens() function in Addon_something.lua under Scripts\rom\userfunctions?

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: writing special data into file

#11 Post by Personalausweis » Tue Nov 02, 2010 1:27 am

bloody....

no

i put it into RUnesofmagic/interface/addons/ingamefunctions


-.-

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: writing special data into file

#12 Post by Personalausweis » Tue Nov 02, 2010 5:18 am

tried it with:

Scripts\rom\userfunctions\addon_writetokens.lua
Scripts\rom\devtools\userfunctions\addon_writetokens.lua

also the same error.

do i need to "load" this file when starting the waypoints?

runensammler
Posts: 13
Joined: Mon Apr 06, 2009 6:20 am

Re: writing special data into file

#13 Post by runensammler » Tue Nov 02, 2010 6:45 am

Personalausweis wrote:tried it with:
do i need to "load" this file when starting the waypoints?
No - there's no load needed.

Can someone else test this if it works?

Maybe some speciality of my client so it works only for me ???

Personalausweis
Posts: 73
Joined: Mon Aug 16, 2010 12:50 pm

Re: writing special data into file

#14 Post by Personalausweis » Tue Nov 02, 2010 6:53 am

finally got it.

Code: Select all

<?xml version="1.0" encoding="utf-8"?><waypoints type="TRAVEL">
<onLoad>
    include( "/userfunctions/addon_writetokens.lua");
</onLoad>
	<!-- #  1 --><waypoint x="31847" z="4592" tag ='Main'>
			local dqCount, dqPerDay = RoMScript("Daily_count()");
			if 10 > dqCount then	
				queststate = getQuestStatus("Wachstumshilfe");
				if queststate == "complete" then
					-- Complete quest
					player:target_NPC(112794);
				 	sendMacro("OnClick_QuestListButton(3,1)");
				<!--	sendMacro("CompleteQuest()"); -->
					yrest(2000); 
					-- Accept quest
					player:target_NPC(112794);
					sendMacro("OnClick_QuestListButton(1,4)");
				<!--	sendMacro("AcceptQuest()");-->
					yrest(2000); 
					--__WPL:setWaypointIndex(__WPL:findWaypointTag("Main"));	
				else
					-- Accept quest
					player:target_NPC(112794);
					sendMacro("OnClick_QuestListButton(1,4)");
				<!--	sendMacro("AcceptQuest()"); -->
					yrest(2000);
				end
			else
				write_tokens(); 
				sendMacro("}LoginNextToon=true;a={")
        			sendMacro("Logout();"); yrest(60*1000);
			        player = CPlayer.new();
			        settings.load();
			        settings.loadProfile("Daylie");
			        yrest (4000)
         			loadPaths("Daylie");
			end
	</waypoint>
	<!-- #  2 --><waypoint x="31812" z="4849">	</waypoint>
	<!-- #  3 --><waypoint x="31415" z="5720" tag = "Item">
			queststate = getQuestStatus("Wachstumshilfe")
			if queststate == "incomplete" then
				player:target_NPC("Reinigungskristall");
				yrest(3000);
				__WPL:setWaypointIndex(__WPL:findWaypointTag("Item"));
			end
	</waypoint>
	<!-- #  4 --><waypoint x="31878" z="4692">	</waypoint>
	<!-- #  5 --><waypoint x="31843" z="4593">	</waypoint>
</waypoints>


Thanks a lot Runensammler :))

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests