Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[StartXML
- <Defaults>
- <Button onClick="onClick" fontSize="80" fontStyle="Bold" textColor="#FFFFFF" color="#000000F0"/>
- <Text fontSize="80" fontStyle="Bold" color="#FFFFFF"/>
- <InputField fontSize="70" color="#000000F0" textColor="#FFFFFF" characterValidation="Integer"/>
- </Defaults>
- <Panel id="panelStat" position="0 0 -180" rotation="270 270 90" scale="0.2 0.2">
- <Panel id="statePanel" height="300" width="-5" position="0 370 0">
- <VerticalLayout>
- <HorizontalLayout spacing="5">
- <Button id="Immobilize" color="#FFFFFF00" active="false"><Image image="Immobilize" preserveAspect="true"></Image><Text id="ImmobilizeText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Wound" color="#FFFFFF00" active="false"><Image image="Wound" preserveAspect="true"></Image><Text id="WoundText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Muddle" color="#FFFFFF00" active="false"><Image image="Muddle" preserveAspect="true"></Image><Text id="MuddleText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Invisible" color="#FFFFFF00" active="false"><Image image="Invisible" preserveAspect="true"></Image><Text id="InvisibleText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Disarm" color="#FFFFFF00" active="false"><Image image="Disarm" preserveAspect="true"></Image><Text id="DisarmText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Strengthen" color="#FFFFFF00" active="false"><Image image="Strengthen" preserveAspect="true"></Image><Text id="StrengthenText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Stun" color="#FFFFFF00" active="false"><Image image="Stun" preserveAspect="true"></Image><Text id="StunText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Poison" color="#FFFFFF00" active="false"><Image image="Poison" preserveAspect="true"></Image><Text id="PoisonText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="Curse" color="#FFFFFF00" active="false"><Image image="Curse" preserveAspect="true"></Image><Text id="CurseText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- <Button id="inf_Curse" color="#FFFFFF00" active="false"><Image image="inf_Curse" preserveAspect="true"></Image><Text id="inf_CurseText" visibility="" position="0 200 0" height="100" width="300" text="x0"></Text></Button>
- </HorizontalLayout>
- </VerticalLayout>
- </Panel>
- </Panel>
- <Panel id="panel" position="0 -50 -20" rotation="0 0 0" scale="0.2 0.2">
- <Panel id="ressourceBar" position="0 100 0" active="true">
- <ProgressBar id="progressBar" visibility="" height="100" width="600" showPercentageText="false" color="#000000E0" percentage="100" fillImageColor="#710000"></ProgressBar>
- <Text id="hpText" visibility="" height="100" width="600" text="10/10"></Text>
- </Panel>
- <Panel id="ressourceBarS" active="true">
- <ProgressBar id="progressBarS" visibility="" height="100" width="600" showPercentageText="false" color="#000000E0" percentage="100" fillImageColor="#000071"></ProgressBar>
- <Text id="manaText" visibility="" height="100" width="600" text="10/10"></Text>
- </Panel>
- </Panel>
- StopXML--xml]]
- statNames = {Immobilize = false, Wound = false, Muddle = false, Invisible = false, Disarm = false, Strengthen = false, Stun = false, Poison = false, Curse = false, inf_Curse = false}
- function onLoad(save_state)
- local assets = UI.getCustomAssets()
- self.UI.setCustomAssets(assets)
- local script = self.getLuaScript()
- local xml = script:sub(script:find("StartXML")+8, script:find("StopXML")-1)
- self.UI.setXml(xml)
- Wait.frames(load, 10)
- end
- function load()
- for i,j in pairs(statNames) do
- if j == true then
- self.UI.setAttribute(i, "active", true)
- end
- end
- Wait.frames(function() self.UI.setAttribute("statePanel", "width", getStatsCount()*300) end, 1)
- end
- function onClick(player, value, id)
- if statNames[id] ~= nil then
- local word = self.UI.getAttribute(id .. "Text", "text")
- word = word:sub(2)
- word = tonumber(word)
- if (word <=1) then
- word = tonumber(word) - 1
- self.UI.setAttribute(id .. "Text", "text", "x" .. word)
- self.UI.setAttribute(id, "active", false)
- self.UI.setAttribute("statePanel", "width", tonumber(self.UI.getAttribute("statePanel", "width")-300))
- statNames[id] = false
- else
- word = tonumber(word) - 1
- self.UI.setAttribute(id .. "Text", "text", "x" .. word)
- end
- end
- end
- function onCollisionEnter(a)
- local newState = a.collision_object.getName()
- if statNames[newState] ~= nil then
- local word = self.UI.getAttribute(newState .. "Text", "text")
- word = word:sub(2)
- word = tonumber(word) + 1
- self.UI.setAttribute(newState .. "Text", "text", "x" .. word)
- statNames[newState] = true
- a.collision_object.destruct()
- self.UI.setAttribute(newState, "active", true)
- Wait.frames(function() self.UI.setAttribute("statePanel", "width", getStatsCount()*300) end, 1)
- end
- end
- function getStatsCount()
- local count = 0
- for i,j in pairs(statNames) do
- if self.UI.getAttribute(i, "active") == "True" or self.UI.getAttribute(i, "active") == "true" then
- count = count + 1
- end
- end
- return count
- end
Advertisement
Add Comment
Please, Sign In to add comment