Page 1 of 1
writing special data into file
Posted: Wed Oct 27, 2010 10:29 am
by Personalausweis
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
Re: writing special data into file
Posted: Wed Oct 27, 2010 4:33 pm
by runensammler
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.
Re: writing special data into file
Posted: Thu Oct 28, 2010 5:24 am
by Personalausweis
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
Re: writing special data into file
Posted: Thu Oct 28, 2010 1:34 pm
by runensammler
sry - but it's no good to post untested code - espatially if u worked whole day
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 !!!
Re: writing special data into file
Posted: Thu Oct 28, 2010 2:23 pm
by Personalausweis
When i call the function with:
sendMacro("write_tokens();");
error occurs, see screenshot
Re: writing special data into file
Posted: Thu Oct 28, 2010 7:12 pm
by S3v3n11
Don't use sendmacro. It is a local call not a ROM call.
Re: writing special data into file
Posted: Thu Oct 28, 2010 9:17 pm
by Personalausweis
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 ^^
Re: writing special data into file
Posted: Fri Oct 29, 2010 1:05 pm
by runensammler
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.
Re: writing special data into file
Posted: Sun Oct 31, 2010 3:24 am
by Personalausweis
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)
Re: writing special data into file
Posted: Mon Nov 01, 2010 12:24 pm
by runensammler
Hi.
Have you put the the Write_tokens() function in Addon_something.lua under Scripts\rom\userfunctions?
Re: writing special data into file
Posted: Tue Nov 02, 2010 1:27 am
by Personalausweis
bloody....
no
i put it into RUnesofmagic/interface/addons/ingamefunctions
-.-
Re: writing special data into file
Posted: Tue Nov 02, 2010 5:18 am
by Personalausweis
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?
Re: writing special data into file
Posted: Tue Nov 02, 2010 6:45 am
by runensammler
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 ???
Re: writing special data into file
Posted: Tue Nov 02, 2010 6:53 am
by Personalausweis
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
![Smile :)](./images/smilies/icon_e_smile.gif)
)