Thorn
Spriting since 2013
Hello guys, i have this teleporter tile made in modalwindow, but everytime a player uses it, it gives me an error in console
can anyone help mefix it? and perhaps if isn't too much add a cancel button? cos when the player steps in the tile, he see the locations, but maybe he regrets using it, and a cancel button is missing for that, altho the error is the most important thing ;C
creaturescript
movement
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/tp.lua:onModalWindow
attempt to index a number value
stack traceback:
[C]: in ?
[C]: in function 'teleportTo'
data/creaturescripts/scripts/tp.lua:24: in function <data/creaturescripts/scripts/tp.lua:1>
can anyone help mefix it? and perhaps if isn't too much add a cancel button? cos when the player steps in the tile, he see the locations, but maybe he regrets using it, and a cancel button is missing for that, altho the error is the most important thing ;C
creaturescript
Code:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
if modalWindowId == 1001 then
if buttonId == 1 or buttonId == 29 or buttonId == 0 then
local pos = 0
if (choiceId == 1) then
pos = {x=1000, y=1000, z=7}
elseif (choiceId == 2) then
pos = {x=2174, y=515, z=7}
elseif (choiceId == 3) then
pos = {x=1589, y=437, z=7}
elseif (choiceId == 4) then
pos = {x=800, y=934, z=7}
elseif (choiceId == 5) then
pos = {x=3076, y=549, z=6}
elseif (choiceId == 6) then
pos = {x=689, y=1247, z=7}
elseif (choiceId == 7) then
pos = {x=2028, y=1395, z=4}
elseif (choiceId == 8) then
pos = {x=129, y=1256, z=15}
elseif (choiceId == 9) then
pos = {x=539, y=1725, z=6}
end
player:teleportTo(pos, false)
end
end
return true
end
movement
Code:
local modaldialog = {
title = "Teleporter",
message = "A que ciudad quieres ir?",
buttons = {
{ id = 1, text = "go" },
},
buttonEnter = 1,
buttonEscape = 2,
choices = {
{ id = 1, text = "garuda" },
{ id = 2, text = "edring" },
{ id = 3, text = "liberty bay" },
{ id = 4, text = "infernum" },
{ id = 5, text = "pofulthorn" },
{ id = 6, text = "azurthis" },
{ id = 7, text = "rathleton" },
{ id = 8, text = "carlin" },
{ id = 9, text = "roshamuul" }
},
popup = true
}
function onStepIn(creature, item, position, fromPosition)
modalWindow = ModalWindow(1001, modaldialog.title, modaldialog.message)
if modalWindow:getId() == 1001 then
for _, v in ipairs(modaldialog.buttons) do
modalWindow:addButton(v.id, v.text)
end
for _, v in ipairs(modaldialog.choices) do
modalWindow:addChoice(v.id, v.text)
end
modalWindow:setDefaultEnterButton(modaldialog.buttonEnter)
modalWindow:setPriority(modaldialog.popup)
modalWindow:setDefaultEscapeButton(modaldialog.buttonEscape)
end
modalWindow:sendToPlayer(creature)
creature:registerEvent("ModalOffline")
return true
end