• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

A choice from ModalWindow can by change/update?

siewdass

New Member
Joined
Sep 24, 2010
Messages
9
Reaction score
1
Only want to know if a choice can by update lets say if i click a EnterButton and reopen the modalwindow? witchout restarting the server.
 
Solution
Create a separate function to define the window and set a button callback to that same function and send it to player.
Use this, it makes things much easier: [TFS 1.2] Modal Window Helper Lib (https://otland.net/threads/tfs-1-2-modal-window-helper-lib.238773/)

Here's a small example of what I mean:
Lua:
function createWindow(player, choices)
    local window = ModalWindow{title = 'ABC', message = 'Select A, B, or C'}
    for _, choice in ipairs(choices) do
        window:addChoice(choice)
    end
    window:addButton('Select', function(button, choice)
        choices[choice.id] = '<UPDATED>'
        createWindow(player, choices)
    end)
    window:setDefaultEnterButton('Select')
    window:addButton('Quit')...
Yes if you close it, change the value for that choice, recreate the window with that new choice and re-send it to the player, it would look seamless except for the choice scrollbar resetting.
 
Create a separate function to define the window and set a button callback to that same function and send it to player.
Use this, it makes things much easier: [TFS 1.2] Modal Window Helper Lib (https://otland.net/threads/tfs-1-2-modal-window-helper-lib.238773/)

Here's a small example of what I mean:
Lua:
function createWindow(player, choices)
    local window = ModalWindow{title = 'ABC', message = 'Select A, B, or C'}
    for _, choice in ipairs(choices) do
        window:addChoice(choice)
    end
    window:addButton('Select', function(button, choice)
        choices[choice.id] = '<UPDATED>'
        createWindow(player, choices)
    end)
    window:setDefaultEnterButton('Select')
    window:addButton('Quit')
    window:setDefaultEscapeButton('Quit')
    window:sendToPlayer(player)
end
Video: https://void.s-ul.eu/WQ505Lpu
 
Last edited:
Solution
Thanks!! works like a charm.. but i have this error:

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/modalwindowhelper.lua:onModalWindow
data/lib.lua:158: attempt to index local 'newWindow' (a nil value)
stack traceback:
    [C]: in function '__index'
    data/lib.lua:158: in function 'callback'
    data/creaturescripts/scripts/modalwindowhelper.lua:26: in function <data/creaturescripts/scripts/modalwindowhelper.lua:1>

Why is that happening? and yea i using modal-window-helper-lib
 
Back
Top