include("Functions/settings.lua");
include("Offsets.lua");
include("Functions/Functions.lua");
include("Functions/PlayerInfo.lua");
include("Functions/TargetInfo.lua");
setStartKey(settings.hotkeys.START_BOT.key);
setStopKey(settings.hotkeys.STOP_BOT.key);
p_wp_gtype = ""; -- global type for whole file: e.g. TRAVEL
p_wp_type = ""; -- type for normal waypoints
wpKey = key.VK_NUMPAD1; -- insert a movement point
saveKey = key.VK_NUMPAD3; -- save the waypoints
local wpList = {};
print("use Numpad 1 to set a waypoint spot")
print("use Numpad 3 to save the paths to file")
window = findWindow("AION*");
theProcess = findProcess("AION*");
myProcess = openProcess(theProcess);
BaseAdress = getModuleAddress(theProcess, "game.dll");
function saveWaypoints(list)
keyboardBufferClear();
io.stdin:flush();
print("What name would you like to call the path?>")
filename = getExecutionPath() .. "/paths/" .. io.stdin:read() .. ".xml";
file, err = io.open(filename, "w");
if( not file ) then
error(err, 0);
end
local openformat = "\t%s";
local closeformat = "\n";
file:write("");
local str = sprintf("\n", p_wp_gtype); -- create first tag
file:write(str); -- write first tag
local hf_line, tag_open = "", false;
for i,v in pairs(list) do
if( v.wp_type == "WP" ) then -- Waypoint
if( tag_open ) then hf_line = hf_line .. "\t" .. closeformat; end;
hf_line = hf_line .. sprintf(openformat, i, v.X, v.Y, v.Z, p_wp_type, "");
tag_open = true;
end
end
-- If we left a tag open, close it.
if( tag_open ) then
hf_line = hf_line .. "\t" .. closeformat;
end
file:write(hf_line);
file:write("");
file:close();
wpList = {}; -- clear intenal table
end
function main()
local running = true;
while(running) do
local hf_x, hf_y, hf_wide, hf_high = windowRect(window);
attach(window);
local hf_key_pressed, hf_key;
while(true) do
hf_key_pressed = false;
if( keyPressed(wpKey) ) then -- normal waypoint key pressed
hf_key_pressed = true;
hf_key = "WP";
end;
if( keyPressed(saveKey) ) then -- save key pressed
hf_key_pressed = true;
hf_key = "SAVE";
end;
if( hf_key_pressed == false and -- key released, do the work
hf_key ) then -- and key not empty
-- SAVE Key: save waypoint file and exit
if( hf_key == "SAVE" ) then
saveWaypoints(wpList);
hf_key = " "; -- clear last pressed key
running = false;
break;
end;
local tmp = {}, hf_type;
tmp.X = CharX();
tmp.Y = CharY();
tmp.Z = CharZ();
hf_type = "";
-- waypoint or harvest point key: create a waypoint/harvest waypoint
if( hf_key == "WP") then -- normal waypoint
tmp.wp_type = "WP";
hf_type = "WP";
printf("%d: Waypoint added.\n",#wpList+1)
end
table.insert(wpList, tmp);
hf_key = nil; -- clear last pressed key
end;
yrest(10);
end -- End of: while(true)
end -- End of: while(running)
closeProcess(myProcess);
end
startMacro(main, true);