1
Your scripts / Magic Mirror (ALTTP) warp script
« on: February 21, 2021, 08:10:27 AM »
Hi Guys,
Just thought I would share my script for my Magic Mirror item.
It allows you to transport between maps as in ALTTP.
Hopefully it should be self explanatory but if not please let me know.
PeterB
Just thought I would share my script for my Magic Mirror item.
It allows you to transport between maps as in ALTTP.
Hopefully it should be self explanatory but if not please let me know.
PeterB
Code: [Select]
-- Allows you to travel from Dark world maps to Light world maps
-- Maps need to have the same name or you need to work out how to
-- change to new map. My maps have the same world layout so you can
-- go to the same place/co-ordinates. The map id's however are slightly
-- different, i.e. dark_world/castle versus light_world/castle. Hence the
-- string.sub 11 characters to remove dark_world and add light_world
-- back in the teleport statement.
local item = ...
local game = item:get_game()
function item:on_started()
item:set_savegame_variable("possession_magic_mirror")
item:set_assignable(true)
end
function item:on_using()
local hero = game:get_hero()
local map = item:get_map()
local map_id = map:get_id()
if map:get_world() == "dark_world" then -- go from dark_world back to light_world
new_map = string.sub(map_id, 11)
-- Teleport.
sol.audio.play_sound("warp")
hero:teleport("light_world" .. new_map .. "", "_same", "fade") -- takes you to same position on light_world map
else
sol.audio.play_sound("wrong")
end
item:set_finished()
end