Starliks
New Member
- Joined
- Jan 6, 2013
- Messages
- 16
- Reaction score
- 0
Hello guys i want to pass the !points system to the mod beside >> would it have some function to take the modal and play for otc?
point system used :CreatureEvent - [TFS 1.1] Skill Points, modalwindow
MODS.lua
MODS.OTUI
point system used :CreatureEvent - [TFS 1.1] Skill Points, modalwindow
MODS.lua
Code:AtributosPanel = nil AtributosButton = nil local atributos = {"health", "bend", "speed", "dodge"} local cantClose = 0 local hasOpen = 0 local firstOpen = 1 canAddAtt = 1 local function hideTests() if firstOpen == 0 then if not g_game.isOnline() then if AtributosButton:isOn() then AtributosWindow:hide() AtributosButton:setOn(false) end elseif cantClose == 0 or hasOpen == 1 then AtributosWindow:show() AtributosButton:setOn(true) cantClose = 1 hasOpen = 1 end else firstOpen = 0 cantClose = 1 end scheduleEvent(function() hideTests() end, 500) end function init() canAddAtt = 1 AtributosButton = modules.client_topmenu.addRightGameToggleButton('AtributosButton', tr('Atributos (Ctrl+E)'), 'atributos.png', toggle) AtributosButton:setOn(false) ProtocolGame.registerExtendedOpcode(38, onReceivePoint) ProtocolGame.registerExtendedOpcode(40, makeStates) ProtocolGame.registerExtendedOpcode(41, onReceivePendentes) AtributosWindow = g_ui.displayUI('attrs.otui') connect(g_game, { onGameStart = online, onReceivePoint = onReceivePoint, turnButtons = turnButtons, addAtribute = addAtribute, onGameEnd = offline, onGameEnd = destroyWindows}) if not g_game.isOnline() then AtributosWindow:hide() end if AtributosButton:isOn() then AtributosWindow:hide() AtributosButton:setOn(false) else AtributosWindow:hide() AtributosButton:setOn(false) end cantClose = 0 hasOpen = 0 g_keyboard.bindKeyDown("Ctrl+E", toggle) end function turnButtons(type) if type == "off" then for i = 1, #atributos do local strAtt = "Add"..atributos[i].."" AtributosWindow:getChildById(strAtt):hide() end else for i = 1, #atributos do local strAtt = "Add"..atributos[i].."" AtributosWindow:getChildById(strAtt):show() end end end function onReceivePoint(protocol, opcode, buffer) buffer = string.explode(buffer, ",") local atributo = buffer[1] local novaQuantia = buffer[2] local novoCusto = buffer[3] local pontosPendentes = buffer[4] local strAtributo = "Value"..atributo.."" local strCusto = "Cost"..atributo.."" local QuantiaChild = AtributosWindow:getChildById(strAtributo) QuantiaChild:setText(novaQuantia) local CustoChild = AtributosWindow:getChildById(strCusto) CustoChild:setText(novoCusto) local PontosChild = AtributosWindow:getChildById("PontosPendentes") PontosChild:setText(pontosPendentes) if tonumber(pontosPendentes) > 0 then turnButtons("on") PontosChild:setColor("#32d968") else turnButtons("off") PontosChild:setColor("red") end return true end function onReceivePendentes(protocol, opcode, buffer) local pontosPendentes = tonumber(buffer) local PontosChild = AtributosWindow:getChildById("PontosPendentes") PontosChild:setText(pontosPendentes) if tonumber(pontosPendentes) > 0 then turnButtons("on") PontosChild:setColor("#32d968") else turnButtons("off") PontosChild:setColor("red") end return true end function makeStates(protocol, opcode, buffer) if buffer == nil or not buffer then return false end buffer = string.explode(buffer, ", ") local pontosPendentes = buffer[1] local PontosChild = AtributosWindow:getChildById("PontosPendentes") PontosChild:setText(pontosPendentes) if tonumber(pontosPendentes) > 0 then turnButtons("on") PontosChild:setColor("#32d968") else turnButtons("off") PontosChild:setColor("red") end for i = 1, (#buffer/2)-1 do fator = i*2 valor = buffer[fator+1] custo = buffer[fator+2] atributo = atributos[i] strAtributo = "Value"..atributo.."" strCusto = "Cost"..atributo.."" local QuantiaChild = AtributosWindow:getChildById(strAtributo) local CustoChild = AtributosWindow:getChildById(strCusto) QuantiaChild:setText(valor) CustoChild:setText(custo) end return end function destroyWindows() AtributosWindow:hide() AtributosButton:setOn(false) end function terminate() disconnect(g_game, { onGameStart = online, onGameEnd = offline, onGameEnd = destroyWindows}) AtributosButton:destroy() AtributosWindow:destroy() end function toggle() if AtributosButton:isOn() then AtributosWindow:hide() AtributosButton:setOn(false) hasOpen = 0 else AtributosWindow:show() AtributosButton:setOn(true) hasOpen = 1 end end function addAtribute(param, value, text) if canAddAtt == 0 then return false end canAddAtt = 0 scheduleEvent(function() canAddAtt = 1 end, 300) return g_game.talkChannel(param, value, text) end
MODS.OTUI
Code:MainWindow id: AtributosWindow !text: tr('Atributos') image-source: /mods/game_atributos/icons/scrollbar size: 235 195 padding: 0 @onEscape: AtributosWindow:hide() AtributosButton:setOn(false) &save: true Button id: CloseAtributos !text: tr ('X') color: red size: 30 20 anchors.top: parent.top anchors.right: parent.right image-source: margin-top: 2 margin-right: 10 @onClick: toggle() Label id: Label0 !text: tr ('Nome Pontos Custo') font: verdana-11px-rounded color: #32a3d9 anchors.top: parent.top anchors.left: parent.left margin-top: 25 margin-left: 40 Label id: Label1 !text: tr ('Health') !tooltip: tr('Aumenta sua quantidade de vida.') font: verdana-11px-rounded color: #ffe86f anchors.top: Label0.top anchors.left: parent.left margin-top: 25 margin-left: 40 icon: icons/health icon-offset: -40 -5 Label id: Valuehealth !text: tr ('?') !tooltip: tr('Aumenta sua quantidade de vida.') font: verdana-11px-rounded color: #ffe86f anchors.top: Label0.top anchors.left: Label1.left margin-top: 25 margin-left: 85 size: 30 20 Label id: Costhealth !text: tr ('?') !tooltip: tr('Aumenta sua quantidade de vida.') font: verdana-11px-rounded color: #ffe86f anchors.top: Label0.top anchors.left: Valuehealth.left margin-top: 25 margin-left: 57 size: 30 20 Button id: Addhealth !text: tr ('+') !tooltip: tr('Aumenta sua quantidade de vida.') font: verdana-11px-rounded color: #32d968 size: 30 20 anchors.top: Label1.top anchors.right: parent.right margin-top: -5 margin-right: 5 @onClick: g_game.talkChannel(1, 0, "/add health, 1") Label id: Label2 !text: tr ('Mana') !tooltip: tr('Aumenta sua quantidade de mana.') font: verdana-11px-rounded color: #ffe86f anchors.top: Label1.top anchors.left: parent.left margin-top: 35 margin-left: 40 icon: icons/mana icon-offset: -35 -5 Label id: Valuespeed !text: tr ('?') font: verdana-11px-rounded color: #ffe86f anchors.top: Label1.top anchors.left: Label2.left margin-top: 34 margin-left: 85 size: 30 20 Label id: Costspeed !text: tr ('?') font: verdana-11px-rounded color: #ffe86f anchors.top: Label1.top anchors.left: Valuespeed.left margin-top: 34 margin-left: 57 size: 30 20 Button id: Addspeed !text: tr ('+') !tooltip: tr('Aumenta sua quantidade de mana.') font: verdana-11px-rounded color: #32d968 anchors.top: Label2.top anchors.right: parent.right margin-top: -5 margin-right: 5 size: 30 20 @onClick: g_game.talkChannel(1, 0, "/add mana, 1") Label id: Label3 !text: tr ('Bend Level ') !tooltip: tr('Aumenta seu dano nas dobras.') font: verdana-11px-rounded color: #ffe86f anchors.top: Label2.top anchors.left: parent.left margin-top: 35 margin-left: 40 icon: icons/bend icon-offset: -50 -5 Label id: Valuebend !text: tr ('?') font: verdana-11px-rounded color: #ffe86f anchors.top: Label2.top anchors.left: Label3.left margin-top: 34 margin-left: 85 size: 30 20 Label id: Costbend !text: tr ('?') font: verdana-11px-rounded color: #ffe86f anchors.top: Label2.top anchors.left: Valuebend.left margin-top: 34 margin-left: 57 size: 30 20 Button id: Addbend !text: tr ('+') !tooltip: tr('Aumenta seu dano nas dobras.') font: verdana-11px-rounded color: #32d968 anchors.top: Label3.top anchors.right: parent.right margin-top: -5 margin-right: 5 size: 30 20 @onClick: g_game.talkChannel(1, 0, "/add bend, 1") Label id: Label4 !text: tr ('Dodge') !tooltip: tr('Aumenta sua velocidade de movimento e sua chance de desviar do ataque recebido.') font: verdana-11px-rounded color: #ffe86f anchors.top: Label3.top anchors.left: parent.left margin-top: 35 margin-left: 40 icon: icons/dodge icon-offset: -37 -5 Label id: Valuedodge !text: tr ('?') font: verdana-11px-rounded color: #ffe86f anchors.top: Label3.top anchors.left: Label4.left margin-top: 34 margin-left: 85 size: 30 20 Label id: Costdodge !text: tr ('?') font: verdana-11px-rounded color: #ffe86f anchors.top: Label3.top anchors.left: Valuedodge.left margin-top: 34 margin-left: 57 size: 30 20 Button id: Adddodge !text: tr ('+') !tooltip: tr('Aumenta sua velocidade de movimento e sua chance de desviar do ataque recebido.') font: verdana-11px-rounded color: #32d968 anchors.top: Label4.top anchors.right: parent.right margin-top: -5 margin-right: 5 size: 30 20 @onClick: g_game.talkChannel(1, 0, "/add dodge, 1") Label id: Label8 !text: tr ('Pontos Pendentes: ') font: verdana-11px-rounded color: #ffe86f anchors.top: Label4.top anchors.left: parent.left margin-top: 20 margin-left: 55 Label id: PontosPendentes !text: tr ('?') font: verdana-11px-rounded color: #32d968 anchors.top: Label8.top anchors.right: parent.right margin-right: 30 size: 30 20