Last active
December 15, 2015 02:59
-
-
Save warmist/5191204 to your computer and use it in GitHub Desktop.
Gui teleportation thingy... Needs a way to add waypoints... maybe...
This file contains 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
--traveling mk2 | |
--if map is loaded then | |
local dialog = require("gui.dialogs") | |
function showWaypointDialog(onSelect,onCancel) | |
local choices={} | |
local wps=dfhack.persistent.get_all('!WP!/',true) | |
if wps~=nil then | |
for k,v in ipairs(wps) do | |
table.insert(choices,{text=string.sub(v.key,6),x=v.ints[1],y=v.ints[2]}) | |
end | |
dialog.showListPrompt("Waypoint choice", "Choose a waypoint", nil, choices,onSelect,onCancel,nil,true) | |
else | |
dialog.showMessage("Error", "No waypoints found") | |
end | |
end | |
function delayedPort(id,choice) | |
local x=choice.x | |
local y=choice.y | |
local party=df.global.world.world_data.travel[0] | |
if (not party or not party.flags[0]) then --not traveling, delay the teleport | |
print("Delay port engaged!") | |
function port(state) | |
if state==SC_MAP_UNLOADED then | |
dfhack.timeout(10,"frames",function() | |
local party=df.global.world.world_data.travel[0] | |
if( party and party.flags[0]) then | |
party.pos.x=x | |
party.pos.y=y | |
end | |
end) | |
print("Delayed port activated.") | |
dfhack.onStateChange.travel=nil | |
elseif state==SC_WORLD_UNLOADED then | |
print("Delayed port canceled!") | |
dfhack.onStateChange.travel=nil | |
end | |
end | |
dfhack.onStateChange.travel=port | |
else | |
party.pos.x=x --traveling, instant portal. | |
party.pos.y=y | |
end | |
end | |
showWaypointDialog(delayedPort) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment