Rondel
Active Member
- Joined
- Feb 1, 2022
- Messages
- 15
- Reaction score
- 38
Hey, I've tried implementing modal window but I've encountered an issue - the modal window shows, however I don't get response when I click the buttons. I'm using OTCv8 and downgraded 7.72 TFS by Nekiro. I've followed the TFS 1.X+ - ModalWindow not executing functions (https://otland.net/threads/modalwindow-not-executing-functions.280727/) thread and uncommented the Game:
layerAnswerModalWindow function in game.cpp aswell as ProtocolGame:
arseModalWindowAnswer function in protocolgame.cpp. Perhaps all of this wasn't needed and the implementation is wrong
. I tried implementing it that way:



LUA:
local action = Action()
function action.onUse(player, item, fromPos, target, toPos, isHotkey)
player:registerEvent("ModalWindowTest")
local title = "Anti-mistake prompt"
local message = "Are you sure that you want to use the teleportation scroll?"
local window = ModalWindow(1111, title, message)
window:addButton(100, "Yes")
window:addButton(101, "No")
window:setDefaultEnterButton(100)
window:getDefaultEscapeButton(101)
window:sendToPlayer(player)
return true
end
action:id(1949)
action:register()
local creatureEvent = CreatureEvent("ModalWindowTest")
function creatureEvent.onModalWindow(player, modalWindowId, buttonId, choiceId)
if modalWindowId == 1111 then
if buttonId == 100 then
print("yes")
end
end
player:unregisterEvent("ModalWindowTest")
return true
end
creatureEvent:register()