Created
February 1, 2015 17:16
-
-
Save warmist/149a0bd53047e252ddb3 to your computer and use it in GitHub Desktop.
waypoints -sort of updated-
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- adv mode waypoint system. | |
local args={...} | |
local armies=df.global.world.armies.all | |
function printHelp() | |
print("An adventure mode travel map teleporation system.") | |
print(" -s <name> - save current position as <name> waypoint") | |
print(" -g <name> - goto waypoint <name>") | |
print(" -dg <name> - goto waypoint <name>") | |
print(" -d <name> - delete waypoint") | |
print(" -l (or no arguments) - list waypoint names") | |
listWaypoints() | |
end | |
function find_player_army() | |
for k,v in ipairs(armies) do | |
if v.unk_48[0] then | |
return v | |
end | |
end | |
end | |
function listWaypoints() | |
local wps=dfhack.persistent.get_all('!WP!/',true) | |
if wps~= nil then | |
print("Waypoints:") | |
for k,v in ipairs(wps) do | |
print(k,string.sub(v.key,6),v.ints[1],v.ints[2],v.ints[3]) | |
end | |
end | |
end | |
function delayedPort(x,y,z) | |
print("Delay port engaged!") | |
function port(state) | |
if state==SC_MAP_UNLOADED then | |
print("Delayed port activated.") | |
local party=find_player_army() | |
party.unk_pos1.x=x | |
party.unk_pos1.y=y | |
party.unk_pos1.z=z or 0 | |
dfhack.onStateChange.travel=nil | |
elseif state==SC_WORLD_UNLOADED then | |
print("Delayed port canceled!") | |
dfhack.onStateChange.travel=nil | |
end | |
end | |
dfhack.onStateChange.travel=port | |
end | |
if (dfhack.gui.getCurFocus()~="dungeonmode/WrestleTarget") and args[1]~="-dg" then | |
qerror("Invalid viewscreen. This only works in adv. mode travel screen") | |
end | |
local name | |
if args[2] and args[2]~="" then | |
name="!WP!/"..args[2] | |
end | |
local party=find_player_army() | |
if (not party) and args[1]~="-dg" then | |
qerror("not traveling") | |
end | |
if #args==0 then | |
printHelp() | |
return | |
elseif args[1]=="-s" then | |
dfhack.persistent.save({key=name,ints={party.unk_pos1.x,party.unk_pos1.y,party.unk_pos1.z}}) | |
elseif args[1]=="-dg" then | |
local e=dfhack.persistent.get(name) | |
if e then | |
delayedPort(e.ints[1],e.ints[2],e.ints[3]) | |
end | |
elseif args[1]=="-g" then | |
local e=dfhack.persistent.get(name) | |
if e then | |
party.unk_pos1.x=e.ints[1] | |
party.unk_pos1.y=e.ints[2] | |
party.unk_pos1.z=e.ints[3] or 0 | |
end | |
elseif args[1]=="-d" then | |
dfhack.persistent.delete(name) | |
elseif args[1]=="-gg" then | |
party.unk_pos1.x=args[2] | |
party.unk_pos1.y=args[3] | |
party.unk_pos1.z=args[4] or 0 | |
elseif args[1]=="-l" then | |
listWaypoints() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment