- Joined
- Jun 26, 2020
- Messages
- 1,921
I'm making TPs but as they are practically the same thing when coding and to make easier to configure later I opted to use the function
So when I call this:
The result should be:
But is not working, the map doesn't even run, what did I do wrong?
Edit: I forgot import the Global Initialization, so that's why the map didn't run, but I will still appreciate feedback.
load
, the problem is I don't know how to do it correctly, this is what I do:
Lua:
do
function Teleport(enterRect, leaveRect, enterTP, leaveTP, enterText, leaveText)
load(
"local enterRect = ".. enterRect .." ---@type rect\n"..
"local leaveRect = ".. leaveRect .." ---@type rect\n"..
"local enterTP = GetRectCenter(".. enterTP ..") ---@type location\n"..
"local leaveTP = GetRectCenter(".. leaveTP ..") ---@type location\n"..
"\n"..
"-- Enter\n"..
"local t = CreateTrigger()\n"..
"TriggerRegisterEnterRectSimple(t, enterRect)\n"..
"TriggerAddAction(t, function ()\n"..
"SetUnitPositionLoc(GetEnteringUnit(), enterTP)\n"..
"DisplayTimedTextToPlayer(GetOwningPlayer(GetEnteringUnit()), 0, 0, 5., '|cffffff00[\"".. enterText .."\"]|r')\n"..
"end)\n"..
"\n"..
"-- Leave\n"..
"t = CreateTrigger()\n"..
"TriggerRegisterEnterRectSimple(t, leaveRect)\n"..
"TriggerAddAction(t, function ()\n"..
" SetUnitPositionLoc(GetEnteringUnit(), leaveTP)\n"..
" DisplayTimedTextToPlayer(GetOwningPlayer(GetEnteringUnit()), 0, 0, 5., '|cffffff00[\"".. leaveText .."\"]|r')\n"..
"end)\n"
)
end
end
Lua:
OnMapInit(function ()
Teleport("gg_rct_Jijimon_House_Outside",
"gg_rct_Jijimon_House_Inside",
"gg_rct_JijimonTP_inside",
"gg_rct_JijimonTP_outside",
"Jijimon's House",
"File City")
end)
Lua:
OnMapInit(function ()
local enterRect = gg_rct_Jijimon_House_Outside ---@type rect
local leaveRect = gg_rct_Jijimon_House_Inside ---@type rect
local enterTP = GetRectCenter(gg_rct_JijimonTP_inside) ---@type location
local leaveTP = GetRectCenter(gg_rct_JijimonTP_outside) ---@type location
-- Enter
local t = CreateTrigger()
TriggerRegisterEnterRectSimple(t, enterRect)
TriggerAddAction(t, function ()
SetUnitPositionLoc(GetEnteringUnit(), enterTP)
DisplayTimedTextToPlayer(GetOwningPlayer(GetEnteringUnit()), 0, 0, 5., "|cffffff00[Jijimon's House]|r")
end)
-- Leave
t = CreateTrigger()
TriggerRegisterEnterRectSimple(t, leaveRect)
TriggerAddAction(t, function ()
SetUnitPositionLoc(GetEnteringUnit(), leaveTP)
DisplayTimedTextToPlayer(GetOwningPlayer(GetEnteringUnit()), 0, 0, 5., "|cffffff00[File City]|r")
end)
end)
Edit: I forgot import the Global Initialization, so that's why the map didn't run, but I will still appreciate feedback.
Last edited: