Skip to content

Commit

Permalink
feat: add example script for modal window (opentibiabr#855)
Browse files Browse the repository at this point in the history
This depends on the pull request: opentibiabr#794
  • Loading branch information
dudantas authored Feb 17, 2023
1 parent ff4235e commit 3ca8f7d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions data-otservbr-global/scripts/modal_window/#example.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
local config = {
{ name="Hunts", position = Position(1054, 1040, 7) },
{ name="Trainer", position = Position(1116, 1094, 7) },
{ name="Temple", position = Position(32369, 32241, 7) }
}

local modalTeleport = TalkAction("!teleport")

function modalTeleport.onSay(player, words, param)
local menu = ModalWindow{
title = "Teleport Modal",
message = "Locations"
}

for i, info in pairs(config) do
menu:addChoice(string.format("%s", info.name), function (player, button, choice)
if button.name ~= "Select" then
return
end

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You were teleported to " .. info.name)
player:teleportTo(info.position)
end)
end

menu:addButton("Select")
menu:addButton("Close")
menu:sendToPlayer(player)
return false
end

modalTeleport:register()

0 comments on commit 3ca8f7d

Please sign in to comment.