addwaypoints.lua

Post Reply
ugel
Posts: 14
Joined: Thu Jan 19, 2017 9:42 am
Has thanked: 22 times
Been thanked: 4 times

addwaypoints.lua

Post by ugel » Sun Mar 19, 2017 7:45 am

Code: Select all

-- Script for adding waypoints manually via hotkeys

function OnLoad()

	-- User Preferences
	reversePath = "True";
	theFileName = "Path 1.xml";
	_createFile = "NumPad1";
	_closeFile = "NumPad3";
	_move = "NumPad4";
	_action = "NumPad6";
	_rest = "NumPad5";
	
	-- Write the hotkeys to the window
	Write("HOTKEYS\nStart File = Numpad 1\nClose File = Numpad 3\nMove = NumPad 4\nRest = Numpad 5\nAction = Numpad 6");
	
	
	-- Register the hotkeys
	Register( "CreateFile", _createFile );
	Register( "CloseFile", _closeFile );
	Register( "WriteMove", _move );
	Register( "WriteAction", _action );
	Register( "WriteRest", _rest );
	
	-- Do not change unless continuing a previous path
	moveCounter = 0;
	actionCounter = 0;
	restCounter = 0;
end

 function WriteMove()
	if fileStarted then	
		-- add 1 to the counter for the node number
		moveCounter = moveCounter + 1;
	 
		-- check if the player is flying and set accordingly
		if Player:IsFlying() then
			amFlying = "True";
		else
			amFlying = "False";
		end
		
		-- Write out the node information
		file:write("   <Travel>\n" );
		file:write("    <Name>Move " .. moveCounter .. "</Name>\n" );
		file:write("    <X>" .. Player:GetPosition().X .."</X>\n" );
		file:write("    <Y>" .. Player:GetPosition().Y .."</Y>\n" );
		file:write("    <Z>" .. Player:GetPosition().Z .."</Z>\n" );
		file:write("    <Flying>" .. amFlying .. "</Flying>\n" );
		file:write("    <Type>Move</Type>\n" );
		file:write("    <Param>\n" );
		file:write("    </Param>\n" );
		file:write("  </Travel>\n" );
		
		Write("Move " .. moveCounter .. " added.");
	end
	
 end
 
 function WriteAction()
 	if fileStarted then	

		-- add 1 to the counter for the node number
		actionCounter = actionCounter + 1;

		-- check if the player is flying and set accordingly
		if Player:IsFlying() then
			amFlying = "True";
		else
			amFlying = "False";
		end
		
		-- Write out the node information
		file:write("   <Travel>\n" );
		file:write("    <Name>Action " .. actionCounter .. "</Name>\n" );
		file:write("    <X>" .. Player:GetPosition().X .."</X>\n" );
		file:write("    <Y>" .. Player:GetPosition().Y .."</Y>\n" );
		file:write("    <Z>" .. Player:GetPosition().Z .."</Z>\n" );
		file:write("    <Flying>" .. amFlying .. "</Flying>\n" );
		file:write("    <Type>Action</Type>\n" );
		file:write("    <Param>\n" );
		file:write("    </Param>\n" );
		file:write("  </Travel>\n" );
		
		Write("Action " .. actionCounter .. " added.");

	end
 end
 
  function WriteRest()
  	if fileStarted then	

		-- add 1 to the counter for the node number
		restCounter = restCounter + 1;

		-- check if the player is flying and set accordingly
		if Player:IsFlying() then
			amFlying = "True";
		else
			amFlying = "False";
		end
		
		-- only write a rest node if not flying
		if amFlying == "False" then
			-- Write out the node information
			file:write("   <Travel>\n" );
			file:write("    <Name>Rest " .. restCounter .. "</Name>\n" );
			file:write("    <X>" .. Player:GetPosition().X .."</X>\n" );
			file:write("    <Y>" .. Player:GetPosition().Y .."</Y>\n" );
			file:write("    <Z>" .. Player:GetPosition().Z .."</Z>\n" );
			file:write("    <Flying>" .. amFlying .. "</Flying>\n" );
			file:write("    <Type>Rest</Type>\n" );
			file:write("    <Param>\n" );
			file:write("    </Param>\n" );
			file:write("  </Travel>\n" );
			
			Write("Rest " .. restCounter .. " added.");
		end
	end
 end

function CreateFile()
	if not filestarted then
		fileStarted = true;
		
		file = io.open( theFileName, "w");
		
		file:write("<TravelList Reverse=\"" .. reversePath .. "\">\n");
		
		Write("File " .. theFileName .. " started.");
	end

end

function CloseFile()
	if fileStarted then
		file:write("</TravelList>");
		file:close();
		Write("File Closed");

	end
	Close();
end
Very OLD V.I.P from aionscript.com orjange bowe :D

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest