writing special data into file
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
writing special data into file
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
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
-
- Posts: 13
- Joined: Mon Apr 06, 2009 6:20 am
Re: writing special data into file
Hi.
Create a file addon_writetokens.lua in the userfuntions
Copy the code in the file
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.
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
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.
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: writing special data into file
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
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
-
- Posts: 13
- Joined: Mon Apr 06, 2009 6:20 am
Re: writing special data into file
sry - but it's no good to post untested code - espatially if u worked whole day
this time i tested it and this should work.
just replace "c:\\temp" with the path you want - but all \ must be \\ dubble !!!
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
just replace "c:\\temp" with the path you want - but all \ must be \\ dubble !!!
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: writing special data into file
When i call the function with:
sendMacro("write_tokens();");
error occurs, see screenshot
sendMacro("write_tokens();");
error occurs, see screenshot
Re: writing special data into file
Don't use sendmacro. It is a local call not a ROM call.
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: writing special data into file
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 ^^
write_tokens();
it doesn't work either.
perhaps it's because its 4 in the morning that i cant find out what to do ^^
-
- Posts: 13
- Joined: Mon Apr 06, 2009 6:20 am
Re: writing special data into file
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.
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.
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: writing special data into file
this is the part in the waypoint:
when he finished all daylies following error occurs:
[string "..."]:25: attempt to call global 'write:tokens' (a nil value)
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
[string "..."]:25: attempt to call global 'write:tokens' (a nil value)
-
- Posts: 13
- Joined: Mon Apr 06, 2009 6:20 am
Re: writing special data into file
Hi.
Have you put the the Write_tokens() function in Addon_something.lua under Scripts\rom\userfunctions?
Have you put the the Write_tokens() function in Addon_something.lua under Scripts\rom\userfunctions?
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: writing special data into file
bloody....
no
i put it into RUnesofmagic/interface/addons/ingamefunctions
-.-
no
i put it into RUnesofmagic/interface/addons/ingamefunctions
-.-
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: writing special data into file
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?
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?
-
- Posts: 13
- Joined: Mon Apr 06, 2009 6:20 am
Re: writing special data into file
No - there's no load needed.Personalausweis wrote:tried it with:
do i need to "load" this file when starting the waypoints?
Can someone else test this if it works?
Maybe some speciality of my client so it works only for me ???
-
- Posts: 73
- Joined: Mon Aug 16, 2010 12:50 pm
Re: writing special data into file
finally got it.
Thanks a lot Runensammler )
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 )
Who is online
Users browsing this forum: Ahrefs [Bot] and 161 guests