Page 1 of 2
Create log file for waypoint
Posted: Fri Oct 28, 2011 1:56 am
by OneofMany
I want to make a log file for my elfdaily script.
At the end of the daily i want to put in that log file:
Charname: Level: Phirius Coins:
and that for each character in same file, after dailys on a new line.
How can i do this? preferably in a CSV format with ; as seperator. but if XML is only way, im good with that too
Re: Create log file for waypoint
Posted: Fri Oct 28, 2011 2:09 am
by OneofMany
Would this work?
Code: Select all
local filename = getExecutionPath() .. "/logs/elfs.log";
local file, err = io.open(filename, "a+");
coins = inventory:itemTotalCount("Phirius Token Coin")
if file then
file:write(" Character name: " ..player.Name.. " \tDate: " .. os.date() .. " \Phirius Coins:"..coins.."\n")
file:close();
end
Re: Create log file for waypoint
Posted: Fri Oct 28, 2011 2:15 am
by OneofMany
And i answer my question myself,
yes it does
Sorry for opening this totally useless post
Maybe somebody can use the code tho...
OneofMany
Re: Create log file for waypoint
Posted: Fri Oct 28, 2011 2:33 am
by OneofMany
and changed it to:
Code: Select all
local filename = getExecutionPath() .. "/logs/elfs.log";
local file, err = io.open(filename, "a+");
coins = inventory:itemTotalCount("Phirius Token Coin")
if file then
file:write("Karakter:\t".. player.Name .."\tDate:\t" .. os.date() .."\tLevel:\t".. player.Level .."\tPhirius Coins:\t".. coins ..
"\n")
file:close();
end
now i can just open the logfile at the end of the day to see if i got enough tokens
, even with excel for better visual
Re: Create log file for waypoint
Posted: Fri Oct 28, 2011 4:18 am
by lisa
Yep that is exactly how you do it =)
Re: Create log file for waypoint
Posted: Fri Oct 28, 2011 6:19 am
by OneofMany
Thnx to ur cot_tele waypoint with log
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 4:31 am
by D1mAnn
how to specify a location in the file where you want to write it matter?
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 4:44 am
by OneofMany
It just starts at the end of file each time, if that is what you want to know?
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 5:04 am
by D1mAnn
I want to write the value for example on line 5 column 1 pos 1
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 5:24 am
by OneofMany
remember that its just a text file, that, can be converted to excel using text to columns.
I think you want to fill in an excel form?
maybe try putting some enters and ; in the line. then you will get to youre desired position. Will only work once tho...
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 5:31 am
by D1mAnn
code from bot.lua
Code: Select all
keyboardBufferClear();
io.stdin:flush();
cprintf(cli.green, "\130\162\165\164\168\226\165 \173\174\172\165\224 \231\160\224\160 \173\160\231\168\173\160\239 \225 \170\174\226\174\224\174\163\174 \173\227\166\173\174 \174\226\175\224\160\162\171\239\226\236 \175\168\225\236\172\160")
text = io.stdin:read();
filename = getExecutionPath() .. "/waypoints/Mail.xml";
file, err = io.open(filename, "a");
file:write("\Account = "..text.."\n")
file:close();
contents of the file mail.xml
I want to make this command all the time edited the ninth line
Code: Select all
<waypoints type="TRAVEL">
<onLoad>
repeat zoneid = RoMScript("GetZoneID()") until zoneid
if zoneid == 13 then __WPL:setWaypointIndex(__WPL:findWaypointTag("day"))
end
waitForLoadingScreen(3);
player:update();
name = "name"
Account = 1;
Charcount = 1;
pass = 0;
pass2={"pass2","pass2","pass2"};
fastLoginAccNames={"Names","Names","Names","Names","Names","Names"};
sendMacro("}fastLoginLoggedIn=false;a={");
yrest(100);
sendMacro("}fastLoginAutoEnter=true;a={");
yrest(100);
sendMacro("}fastLoginAutoLogin=true;a={");
yrest(100);
sendMacro("}fastLoginRelog=true;a={");
yrest(100);
sendMacro("}fastLoginNoZoom=true;a={");
</onLoad>
</waypoints>
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 5:50 am
by OneofMany
For this ill pass
ur question needs a more pro to answer
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 7:25 am
by lisa
Ok so if I understand correctly you want to run bot.lua which will ask you a question, I didn't understand the language but I assume it was account name.
Then you want to write the file mail.xml and making line 9 to be
Account =
and then the text you type into MM after the question is asked.
I couldn't find a way to edit a perticular line when I looked about 9 months ago.
What I did was create my own .lua and have it print each line but adjust the text I wanted.
So basically I did a
Code: Select all
file:write("<waypoints type=\"TRAVEL\">")
file:write("<onLoad>")
and so on, for line 9 I would do your.
Code: Select all
file:write("\Account = "..text.."\n")
You could probably do some \n and \t and just do some long lines to reduce the number of file:write but I just found it easier to do each line so I can easily fix any issues or changes that needed making.
I did it to automake profiles, the writes looked like this.
Code: Select all
file:write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
file:write("<profile>\n\t<options>\n\n");
file:write("\t\t<option name=\"INV_AUTOSELL_ENABLE\" value=\"true\" />\n");
file:write("\t\t<option name=\"INV_AUTOSELL_FROMSLOT\" value=\"0\" />\n");
file:write("\t\t<option name=\"INV_AUTOSELL_TOSLOT\" value=\"60\" />\n");
file:write("\t\t<option name=\"INV_AUTOSELL_QUALITY\" value=\"white,green\" />\n");
file:write("\t\t<option name=\"INV_AUTOSELL_IGNORE\" value=\"potion, Rough Wooden Bow\" />\n\n");
file:write("\t\t<option name=\"HP_LOW\" value=\"85\" />\n");
file:write("\t\t<option name=\"MP_LOW_POTION\" value=\"70\" />\n");
file:write("\t\t<option name=\"HP_LOW_POTION\" value=\"70\" />\n");
file:write("\t\t<option name=\"USE_HP_POTION\" value=\"best\" />\n");
file:write("\t\t<option name=\"USE_MANA_POTION\" value=\"best\" />\n\n");
file:write("\t\t<option name=\"HP_REST\" value=\"15\" />\n");
file:write("\t\t<option name=\"MP_REST\" value=\"15\" />\n\n");
file:write("\t\t<!-- Shopping options, how many of what do you want to keep in your inventory -->\n");
file:write("\t\t<option name=\"HEALING_POTION\" value=\"99\" />\n");
file:write("\t\t<option name=\"MANA_POTION\" value=\"" .. mpuser .. "\" />\n");
file:write("\t\t<option name=\"ARROW_QUIVER\" value=\"" .. buyarrows .. "\" />\n");
file:write("\t\t<option name=\"THROWN_BAG\" value=\"0\" />\n");
file:write("\t\t<option name=\"POISON\" value=\"0\" />\n");
file:write("\t\t<!-- either false or arrow or thrown -->\n");
file:write("\t\t<option name=\"RELOAD_AMMUNITION\" value=\"" .. reloadamu .. "\" /> <!-- false|arrow|thrown -->\n\n");
file:write("\t\t<!-- Combat options -->\n");
file:write("\t\t<option name=\"COMBAT_TYPE\" value=\"\" /> <!-- leave empty or choose ranged/melee if not using class default -->\n");
file:write("\t\t<option name=\"COMBAT_RANGED_PULL\" value=\"" .. ranged .. "\" /> <!-- only important for melees -->\n");
file:write("\t\t<option name=\"COMBAT_DISTANCE\" value=\"150\" />\n");
file:write("\t\t<option name=\"MAX_FIGHT_TIME\" value=\"15\" /> <!-- Max time without damage before break -->\n");
file:write("\t\t<option name=\"DOT_PERCENT\" value=\"90\" />\n");
file:write("\t\t<option name=\"ANTI_KS\" value=\"true\" />\n");
file:write("\t\t<option name=\"MAX_TARGET_DIST\" value=\"200\" />\n\n");
file:write("\t\t<!-- Attack monsters 3 levels above or 10 below your level -->\n");
file:write("\t\t<option name=\"TARGET_LEVELDIF_ABOVE\" value=\"3\" />\n");
file:write("\t\t<option name=\"TARGET_LEVELDIF_BELOW\" value=\"10\" />\n\n");
file:write("\t\t<!-- Waypoint and movement settings -->\n");
file:write("\t\t<option name=\"WAYPOINTS\" value=\"1-10human/travel1-10\" /> <!-- leave empty to show a list -->\n");
file:write("\t\t<option name=\"RETURNPATH\" value=\"1-10human/travel1-10_return\" />\n");
file:write("\t\t<option name=\"PATH_TYPE\" value=\"waypoints\" /> <!-- waypoints | wander -->\n");
file:write("\t\t<option name=\"WANDER_RADIUS\" value=\"500\" />\n");
file:write("\t\t<option name=\"WAYPOINT_DEVIATION\" value=\"0\" />\n");
file:write("\t\t<option name=\"QUICK_TURN\" value=\"false\" />\n\n");
file:write("\t\t<!-- Loot settings -->\n");
file:write("\t\t<option name=\"LOOT\" value=\"true\" />\n");
file:write("\t\t<option name=\"LOOT_IN_COMBAT\" value=\"true\" />\n");
file:write("\t\t<option name=\"LOOT_DISTANCE\" value=\"150\" />\n");
file:write("\t\t<option name=\"LOOT_PAUSE_AFTER\" value=\"0\" /> <!-- probability in % for a short rest -->\n\n");
file:write("\t\t<!-- Harvest options -->\n");
file:write("\t\t<option name=\"HARVEST_DISTANCE\" value=\"50\" />\n");
file:write("\t\t<option name=\"HARVEST_WOOD\" value=\"true\" /> <!-- Choose which types to harvest. -->\n");
file:write("\t\t<option name=\"HARVEST_HERB\" value=\"true\" /> <!-- \"true\" = harvest, \"false\" = do not harvest -->\n");
file:write("\t\t<option name=\"HARVEST_ORE\" value=\"true\" />\n\n");
file:write("\t\t<!-- Eggpet options -->\n");
file:write("\t\t<option name=\"EGGPET_ENABLE_CRAFT\" value=\"false\" /><!-- If using same slot for assist and craft, onlt 1 can be enabled. -->\n");
file:write("\t\t<option name=\"EGGPET_CRAFT_SLOT\" value=\"1\" />\n");
file:write("\t\t<option name=\"EGGPET_ENABLE_ASSIST\" value=\"false\" />\n");
file:write("\t\t<option name=\"EGGPET_ASSIST_SLOT\" value=\"1\" />\n");
file:write("\t\t<option name=\"EGGPET_CRAFT\" value=\"mining,woodworking,herbalism\" /> <!-- 'mining', 'woodworking', 'herbalism' or combination. -->\n");
file:write("\t\t<option name=\"EGGPET_CRAFTINDEX\" value=\"\" /> <!-- The level to craft. \"\" defaults to maximum -->\n\n");
file:write("\t\t<!-- Log out and resurrect settings -->\n");
file:write("\t\t<option name=\"LOGOUT_TIME\" value=\"0\" /> <!-- in minutes, 0 = timer disabled -->\n");
file:write("\t\t<option name=\"LOGOUT_SHUTDOWN\" value=\"false\" />\n");
file:write("\t\t<option name=\"LOGOUT_WHEN_STUCK\" value=\"true\" />\n");
file:write("\t\t<option name=\"RES_AFTER_DEATH\" value=\"true\" />\n");
file:write("\t\t<option name=\"MAX_DEATHS\" value=\"10\" /> <!-- Log out after this many deaths -->\n\n");
file:write("\t\t<!-- For more options and documentation see the RoM Bot Wiki: -->\n");
file:write("\t\t<!-- http://www.solarstrike.net/wiki/index.php5?title=RoM_Bot -->\n\n");
file:write("\t</options>\n\n");
file:write("\t<friends>\n");
file:write("\t\t<!-- names of friends we help fighting or enemys we don't want to attack -->\n");
file:write("\t\t<friend name=\"MyOtherCharacter1\" />\n");
file:write("\t\t<friend name=\"MyOtherCharacter2\" />\n");
file:write("\t\t<friend name=\"Elite_Mob_Name1\" />\n");
file:write("\t\t<friend name=\"Elite_Mob_Name2\" />\n");
file:write("\t</friends>\n\n");
file:write("\t<mobs>\n");
file:write("\t\t<!-- names of mobs we want to attack -->\n");
file:write("\t\t<!-- if no names defined we will attack all mobs -->\n");
file:write("\t\t<mob name=\"\" />\n");
file:write("\t\t<mob name=\"\" />\n");
file:write("\t\t<mob name=\"\" />\n");
file:write("\t</mobs>\n\n");
file:write("\t<hotkeys>\n");
file:write("\t\t<!-- to communicate with the RoM API / define ingame dummy macro at place 1 -->\n");
file:write("\t\t<hotkey name=\"MACRO\" modifier=\"\" key=\"VK_0\" />\n");
file:write("\t</hotkeys>\n\n");
file:write("\t<skills" .. _charclass2 .. ">\n");
if _mainskill ~= nil then file:write("\t\t<skill name=\"" .. _mainskill .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskillkey .. "\" priority=\"" .. _mainskillpriority .. "\" />\n"); end
if _mainskill2 ~= nil then file:write("\t\t<skill name=\"" .. _mainskill2 .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskill2key .. "\" priority=\"" .. _mainskill2priority .. "\" />\n"); end
if _mainskill3 ~= nil then file:write("\t\t<skill name=\"" .. _mainskill3 .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskill3key .. "\" priority=\"" .. _mainskill3priority .. "\" />\n"); end
if _mainskill4 ~= nil then file:write("\t\t<skill name=\"" .. _mainskill4 .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskill4key .. "\" priority=\"" .. _mainskill4priority .. "\" />\n"); end
if _main2skill ~= nil then file:write("\t\t<skill name=\"" .. _main2skill .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skillkey .. "\" priority=\"" .. _main2skillpriority .. "\" />\n"); end
if _main2skill2 ~= nil then file:write("\t\t<skill name=\"" .. _main2skill2 .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skill2key .. "\" priority=\"" .. _main2skill2priority .. "\" />\n"); end
if _main2skill3 ~= nil then file:write("\t\t<skill name=\"" .. _main2skill3 .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skill3key .. "\" priority=\"" .. _main2skill3priority .. "\" />\n"); end
if _main2skill4 ~= nil then file:write("\t\t<skill name=\"" .. _main2skill4 .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skill4key .. "\" priority=\"" .. _main2skill4priority .. "\" />\n"); end
file:write("\t</skills" .. _charclass2 .. ">\n\n");
file:write("\t<skills" .. _charclass .. ">\n");
if _mainskill ~= nil then file:write("\t\t<skill name=\"" .. _mainskill .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskillkey .. "\" priority=\"" .. _mainskillpriority .. "\" />\n"); end
if _mainskill2 ~= nil then file:write("\t\t<skill name=\"" .. _mainskill2 .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskill2key .. "\" priority=\"" .. _mainskill2priority .. "\" />\n"); end
if _mainskill3 ~= nil then file:write("\t\t<skill name=\"" .. _mainskill3 .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskill3key .. "\" priority=\"" .. _mainskill3priority .. "\" />\n"); end
if _mainskill4 ~= nil then file:write("\t\t<skill name=\"" .. _mainskill4 .. "\" modifier=\"\" hotkey=\"VK_" .. _mainskill4key .. "\" priority=\"" .. _mainskill4priority .. "\" />\n"); end
if _main2skill ~= nil then file:write("\t\t<skill name=\"" .. _main2skill .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skillkey .. "\" priority=\"" .. _main2skillpriority .. "\" />\n"); end
if _main2skill2 ~= nil then file:write("\t\t<skill name=\"" .. _main2skill2 .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skill2key .. "\" priority=\"" .. _main2skill2priority .. "\" />\n"); end
if _main2skill3 ~= nil then file:write("\t\t<skill name=\"" .. _main2skill3 .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skill3key .. "\" priority=\"" .. _main2skill3priority .. "\" />\n"); end
if _main2skill4 ~= nil then file:write("\t\t<skill name=\"" .. _main2skill4 .. "\" modifier=\"\" hotkey=\"VK_" .. _main2skill4key .. "\" priority=\"" .. _main2skill4priority .. "\" />\n"); end
file:write("\t</skills" .. _charclass .. ">\n\n");
file:write("\t\t<onDeath><![CDATA[\n\n");
file:write("\t\t]]></onDeath>\n\n");
file:write("\t\t<onLeaveCombat><![CDATA[\n\n");
file:write("\t\t]]></onLeaveCombat>\n\n");
file:write("\t\t<onLevelup><![CDATA[\n\n");
file:write("\t\t\ttylvlskill();\n\n");
file:write("\t\t\tcheckskilllvl();\n\n");
file:write("\t\t\topenbags1To10();\n\n");
file:write("\t\t\tstorecharname();\n\n");
file:write("\t\t]]></onLevelup>\n\n");
file:write("\t\t<onSkillCast><![CDATA[\n\n");
file:write("\t\t]]></onSkillCast>\n\n");
file:write("\t\t<onHarvest><![CDATA[\n\n");
file:write("\t\t]]></onHarvest>\n\n");
file:write("\t\t<onLoad><![CDATA[\n\n");
file:write("\t\t\tcheckskilllvl();\n\n");
file:write("\t\t\tsetranged();\n\n");
file:write("\t\t\tsetactionbar();\n\n");
file:write("\t\t\tstorecharname();\n\n");
file:write("\t\t]]></onLoad>\n\n");
file:write("</profile>");
Should give you an idea of 1 way to do it, there is probably an easier way.
Re: Create log file for waypoint
Posted: Tue Nov 01, 2011 7:41 am
by lisa
ok so that was to answer your question about altering a write to a file.
Now if I was to try to do what you want I would be looking at creating another argument for rom/bot.lua
Ok so it looks for : in the argument, and then checks for path,profile,character,retpath.
So maybe add in another check and make it your account name/number.
Code: Select all
if( var == "profile" ) then
forcedProfile = val;
elseif( var == "path" ) then
forcedPath = val;
elseif( var == "retpath" ) then
forcedRetPath = val;
elseif( var == "character") then
forcedCharacter = val;
else
-- invalid option
local msg = sprintf(language[61], args[i]);
error(msg, 0 );
end
Add in a
Code: Select all
elseif( var == "account" ) then
AccountName = val;
when you start bot use
Obviously replace **** with what you wanted
then in your WP onload have
Re: Create log file for waypoint
Posted: Wed Nov 02, 2011 2:20 am
by D1mAnn
thank you, if you have to do so is another question, how to set the encoding of ANSI as UTF-8(utf82oem_russian)? by default it saves in ANSI
Re: Create log file for waypoint
Posted: Wed Nov 02, 2011 8:31 am
by Administrator
D1mAnn wrote:thank you, if you have to do so is another question, how to set the encoding of ANSI as UTF-8(utf82oem_russian)? by default it saves in ANSI
Use a better editor. Try Notepad++.
Re: Create log file for waypoint
Posted: Wed Nov 02, 2011 8:49 am
by D1mAnn
ok, see I run the Bat file it contains
Code: Select all
@echo off
START micromacro.exe scripts/rom/mail.lua
in mail.lua contains the string at the end of
Code: Select all
os.execute("START micromacro.exe scripts/rom/bot.lua update profile:DF_Pr path:mail.xml")
how to make the first window closes after the micromacro input values thx
Re: Create log file for waypoint
Posted: Wed Nov 02, 2011 9:53 am
by Administrator
use system() instead of os.execute(), maybe?
Re: Create log file for waypoint
Posted: Wed Nov 02, 2011 9:57 am
by D1mAnn
Administrator wrote:use system() instead of os.execute(), maybe?
You do not understand
I want to exit the micromacro, I do not know what command exit them
sorry for my terrible English, I use Google translator
thx for all))
Re: Create log file for waypoint
Posted: Tue Sep 11, 2012 2:31 pm
by noobbotter
I was reading through some posts today and I saw this one and it got me to thinking... If we were to write a piece of code that would record in a log file where you walk, what you battle, what NPC you talk to and the choices you make, including the wait time between talking, the items you loot, etc..., this log file could then be used as a reference file to create waypoints.
My thinking is that if I had code to record this, I could go to the start point of what quests I want to create waypoints for, start the "recorder" and then go about my business doing some quests. Suppose I do some normal, non-daily quests and gain 5 levels. Then I stop the "recorder," and then go about building a waypoint using the log file that was created. If I were able to record all that information, then creating the waypoint for those specific quests would not only be easier to do (because you have all the info in front of you), but it would also be customized because the waypoint will be a copy of my own personal style of play and look much less like a typical bot.
Then if you could create code that would automatically parse the log file to dynamically create the waypoint file, we'd be golden. All you'd have to do is go in and tweak any areas that have problems.
Thoughts?