Ir para conteúdo

Pesquisar na Comunidade

Mostrando resultados para as tags ''modal window''.

  • Pesquisar por Tags

    Digite tags separadas por vírgulas
  • Pesquisar por Autor

Tipo de Conteúdo


Fóruns

  • xTibia - Notícias e Suporte
    • Regras
    • Noticias
    • Soluções
    • Projetos Patrocinados
    • Tutoriais para Iniciantes
    • Imprensa
  • OTServ
    • Notícias e Debates
    • OTServlist
    • Downloads
    • Recursos
    • Suporte
    • Pedidos
    • Show-Off
    • Tutoriais
  • OFF-Topic
    • Barzinho do Éks
    • Design
    • Informática

Encontrar resultados em...

Encontrar resultados que contenham...


Data de Criação

  • Início

    FIM


Data de Atualização

  • Início

    FIM


Filtrar pelo número de...

Data de Registro

  • Início

    FIM


Grupo


Sou

Encontrado 2 registros

  1. Esse sistema/script/sei lá o que foi desenvolvido por Karain que quis trazer um 'ar' mais moderno ao tibia.. Com esse script conversar com o npc será mais uma experiência mais amigável, continua sendo customizável mas de uma forma mais fácil! Como instalar Em data/creaturescripts/creaturescrips.xml adicione <event type="modalWindow" name="Dialogue" script="dialogue.lua"/> Em data/creaturescripts/scripts/login.lua adicione isso antes do "return true" player:registerEvent("Dialogue") Crie em data/creaturescripts o arquivo dialogue.lua e adicione player_choices = {} defaultButtons = {{id = 0x00, text = "Select", enter = true, escape = false}, {id = 0x01, text = "End", enter = false, escape = true}} function Player:getChoiceText(choice_id) if player_choices and player_choices[self:getId()] then return player_choices[self:getId()][choice_id].text else return false end end function Player:createDialogueWindowWithButtons(modalWindowId, headerText, bodyText, buttonTable, choiceTable, sendToPlayer, priority) local var = ModalWindow(modalWindowId, headerText, bodyText) for i = 1, #buttonTable do var:addButton(buttonTable[i].id, buttonTable[i].text) if buttonTable[i].enter then var:setDefaultEnterButton(buttonTable[i].id) end if buttonTable[i].escape then var:setDefaultEscapeButton(buttonTable[i].id) end end player_choices[self:getId()] = choiceTable for i = 0, #choiceTable do if choiceTable[i] ~= nil and (choiceTable[i].storage == false or self:getStorageValue(choiceTable[i].storage[1]) == choiceTable[i].storage[2]) then var:addChoice(i, choiceTable[i].text) end end if not priority then var:setPriority(false) end if sendToPlayer then var:sendToPlayer(self) end end function onModalWindow(player, modalWindowId, buttonId, choiceId) -- be careful here if you have other modalwindow scripts if buttonId == 0x00 then player:say(player:getChoiceText(choiceId),TALKTYPE_SAY) elseif buttonId == 0x01 then player:say("Good Bye.",TALKTYPE_SAY) end return true end Crie em data/npc/scripts o arquivo dialogue.lua e adicione local npc_dialogue = { [1] = { message="This is the message that shows up before the choices, make sure it's long enough if you are having long choices.", choices= { [1]={text="Choice 1", storage=false, dialogue=1, script="end"}, [2]={text="Choice 2",storage=false, dialogue=2, script="script1"}, [3]={text="Choice 3",storage={1234,1}, dialogue=3, script="trade"}, [4]={text="Choice 4",storage=false, dialogue=3, script="quest"}, [5]={text="Choice 5",storage=false, dialogue=false, script="quest2"}}}, [2] = { message="Bla bla bla bla bla bla bla.", choices= { [1]={text="Choice 1",storage=false, dialogue=1, script="end"}, [2]={text="Choice 2",storage=false, dialogue=2, script="end"}, [3]={text="Choice 3",storage={1234,1}, dialogue=false, script="end"}, [4]={text="Choice 4",storage=false, dialogue=false, script="end"}, [5]={text="Choice 5",storage=false, dialogue=3, script="end"}}}, [3] = { message="Brought to you by Matt Shadowwing.", choices= { [1]={text="Choice 1",storage={1245,2}, dialogue=false, script="end"}, [2]={text="Choice 2",storage=false, dialogue=false, script="end"}, [3]={text="Choice 3",storage={1234,1}, dialogue=false, script="end"}, [4]={text="Choice 4",storage=false, dialogue=1, script="end"}, [5]={text="Choice 5",storage=false, dialogue=2, script="end"}}} } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local talkstate = {} local function greetCallback(cid) local player = Player(cid) local npc = Npc(getNpcCid()) npcHandler:setMessage(MESSAGE_GREET, npc_dialogue[1].message) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[1].message, defaultButtons, npc_dialogue[1].choices, true, false) talkstate[player:getId()] = 1 return true end local function creatureSayCallback(cid, type, msg) local player = Player(cid) local npc = Npc(getNpcCid()) if not npcHandler:isFocused(cid) then return false elseif talkstate[player:getId()] then for _, v in pairs(npc_dialogue[talkstate[player:getId()]].choices) do if msgcontains(msg, v.text) and (v.storage == false or player:getStorageValue(v.storage[1]) == v.storage[2]) then if v.script == "end" then talkstate[player:getId()] = v.dialogue npcHandler:say(npc_dialogue[v.dialogue].message, cid) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[v.dialogue].message, defaultButtons, npc_dialogue[v.dialogue].choices, true, false) elseif v.script == "trade" then -- trading script here talkstate[player:getId()] = v.dialogue npcHandler:say(npc_dialogue[v.dialogue].message, cid) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[v.dialogue].message, defaultButtons, npc_dialogue[v.dialogue].choices, true, false) elseif v.script == "quest" then -- quest script here talkstate[player:getId()] = v.dialogue npcHandler:say(npc_dialogue[v.dialogue].message, cid) player:createDialogueWindowWithButtons(1, npc:getName(), npc_dialogue[v.dialogue].message, defaultButtons, npc_dialogue[v.dialogue].choices, true, false) end end end end return true end npcHandler:setCallback(CALLBACK_GREET, greetCallback) npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Em data/npc/lib/npcsystem/npchandler.lua altere todos os TALKTYPE_PRIVATE_PN para TALKTYPE_SAY Depois é só criar seu npc.xml referenciar o lua e seja feliz.. Qualquer problema eu terei que repassar para o criador pois não sou apto a dar suporte.. Estou somente trazendo para cá!
  2. Olá. Esse conteúdo foi desenvolvido pelo membro Non Sequitur, da Otland. Decidi trazer a vocês, então vamos lá. MODAL WINDOW A forma atual que podemos implementar Modal Windows é bastante complicada, de acordo com Non Sequitur. Ter de criá-la em algum lugar, registrar um evento, adicionar botões de alguma forma estranha para fazer funcionar, sem falar que tem que ter em conta ids de janelas, botões, ids de escolha em algum arquivo diferente, etc... O que você pode fazer com isto? -- The helper lib is used by passing a table value to the ModalWindow functionlocal window = ModalWindow { title = 'Title', message = 'Please, choose the lowest number and press [Ok]'}local lowestChoicefor i = 1, 5 do local value = math.random(1, 100) -- modalWindow:addChoice() returns the choice object that will be passed to the callbacks local choice = window:addChoice(value) -- This way we can pass extra information to the callback choice.value = value if not lowestChoice or lowestChoice.value > value then lowestChoice = choice endendlowestChoice.correct = true-- Add a button with a specific callbackwindow:addButton('Ok', function(button, choice) if choice.correct then print('Player selected the correct option.') else print('Player selected the incorrect option.') end end)-- Set this button as the default enter buttonwindow:setDefaultEnterButton('Ok')-- Add a button without a specific callbackwindow:addButton('Close')window:setDefaultEscapeButton('Close')-- If a button without a specific callback is pressed, this fucntion will be calledwindow:setDefaultCallback( function(button, choice) print('Default callback, button pressed: ' .. button.text .. ' player choice: ' .. choice.text) end)window:sendToPlayer(player) Você pode usar este exemplo em uma talkaction e testar por si mesmo. Diferente do que é mostrado no código acima, você também pode usar modalWindow: addbuttons (...) e modalWindow: addChoices (...) para adicionar vários botões / opções ao mesmo tempo. INSTALANDO Em data/lib/lib.lua dofile('data/lib/modalwindow.lua') Crie o arquivo data/lib/modalwindow.lua if not modalWindows then modalWindows = { modalWindowConstructor = ModalWindow, nextFreeId = 500, windows = {} }end local MT = {}MT.__index = MT function ModalWindow(...) local args = {...} if type(args[1]) == 'table' then local self = setmetatable(args[1], MT) local id = modalWindows.nextFreeId self.id = id self.buttons = {} self.choices = {} self.players = {} self.created = false modalWindows.nextFreeId = id + 1 table.insert(modalWindows.windows, self) return self end return modalWindows.modalWindowConstructor(...)end function MT:setDefaultCallback(callback) self.defaultCallback = callbackend function MT:addButton(text, callback) local button = {text = tostring(text), callback = callback} table.insert(self.buttons, button) return buttonend function MT:addButtons(...) for _, text in ipairs({...}) do table.insert(self.buttons, {text = tostring(text)}) endend function MT:addChoice(text) local choice = {text = tostring(text)} table.insert(self.choices, choice) return choiceend function MT:addChoices(...) for _, text in ipairs({...}) do table.insert(self.choices, {text = tostring(text)}) endend function MT:setDefaultEnterButton(text) self.defaultEnterButton = textend function MT:setDefaultEscapeButton(text) self.defaultEscapeButton = textend function MT:setTitle(title) self.title = tostring(title)end function MT:setMessage(message) self.message = tostring(message)end local buttonOrder = { [4] = {3, 4, 2, 1}, [3] = {2, 3, 1}, [2] = {1, 2}, [1] = {1}}function MT:create() local modalWindow = modalWindows.modalWindowConstructor(self.id, self.title, self.message) local order = buttonOrder[math.min(#self.buttons, 4)] if order then for _, i in ipairs(order) do local button = self.buttons[i] modalWindow:addButton(i, button.text) button.id = i if button.text == self.defaultEnterButton then modalWindow:setDefaultEnterButton(i) elseif button.text == self.defaultEscapeButton then modalWindow:setDefaultEscapeButton(i) end end end for _, choice in ipairs(self.choices) do modalWindow:addChoice(_, choice.text) choice.id = _ end self.modalWindow = modalWindowend function MT:sendToPlayer(player) if not self.modalWindow then self:create() end player:registerEvent('ModalWindowHelper') self.players[player:getId()] = true return self.modalWindow:sendToPlayer(player)end Em data/creaturescripts/creaturescripts.xml <event type="modalwindow" name="ModalWindowHelper" script="modalwindowhelper.lua" /> Crie o arquivo data/creaturescripts/scripts/modalwindowhelper.lua function onModalWindow(player, modalWindowId, buttonId, choiceId) local modalWindow for _, window in ipairs(modalWindows.windows) do if window.id == modalWindowId then modalWindow = window break end end if not modalWindow then return true end local playerId = player:getId() if not modalWindow.players[playerId] then return true end modalWindow.players[playerId] = nil local choice = modalWindow.choices[choiceId] for _, button in ipairs(modalWindow.buttons) do if button.id == buttonId then local callback = button.callback or modalWindow.defaultCallback if callback then callback(button, choice) break end end end return trueend
×
×
  • Criar Novo...