Blasphemy
Well-Known Member
- Joined
- Jan 5, 2012
- Messages
- 387
- Reaction score
- 67
Well after years, i've tried lot to turn my OTC health and mana bars to retro style... so I want to share what i've done to get it:
*note for beginners like me: .otui files are very complicated, every space, tab, causes errors.
1st this is my healthinfo.otui:
2nd: healthinfo.lua side:
as you can see, i could solve the 0 max mana problem
don't forget to add
and
in it's respective place.
and at last, thanks to @margoh for his help, he guide me on how to do this in this link
You should need to add to your modules files codes that he show us in that thread
best regards
*note for beginners like me: .otui files are very complicated, every space, tab, causes errors.
1st this is my healthinfo.otui:
Code:
FullHealthBar < ProgressBar
height: 11
image-source: /images/ui/emptybar
anchors.top: parent.top
anchors.left: parent.left
margin-left: 24
margin-top: 4
margin-right: 51
HealthBar < ProgressBar
id: healthBar
image-source: /images/ui/fullhealthbar
height: 11
anchors.top: parent.top
anchors.left: parent.left
margin-left: 24
margin-top: 4
margin-right: 51
ManaBar < ProgressBar
id: manaBar
image-source: /images/ui/fullmanabar
height: 11
anchors.top: healthBar.bottom
anchors.left: parent.left
margin: 2
margin-left: 24
margin-top: 4
margin-right: 51
FullManaBar < ProgressBar
height: 11
image-source: /images/ui/emptybar
anchors.top: healthBar.bottom
anchors.left: parent.left
anchors.right: parent.right
margin: 2
margin-top: 4
margin-right: 51
margin-left: 24
ManaLabel < GameLabel
id: manaLabel
color: #AFAFAF
font: verdana-11px-antialised
text-offset: 140 0
anchors.left: parent.left
anchors.right: parent.right
anchors.top: manaBar.top
anchors.bottom: manaBar.bottom
margin-top: -2
margin-left: -20
HealthLabel < GameLabel
id: healthLabel
color: #AFAFAF
font: verdana-11px-antialised
text-offset: 140 0
anchors.left: parent.left
anchors.right: parent.right
anchors.top: healthBar.top
anchors.bottom: healthBar.bottom
margin-top: -2
margin-left: -20
HealthInfoWindow < HeadlessMiniWindow
icon:
text:
height: 45
&forceOpen: true
icon: /images/topbuttons/healthinfo
!text: tr('Health/Mana')
MiniWindowContents
margin-top: 1
FullHealthBar
HealthBar
FullManaBar
ManaBar
HealthLabel
ManaLabel
Label
height: 24
image-source: /images/ui/progress_icons
anchors.top: parent.top
anchors.left: manaBar.left
margin-left: -16
margin-top: 5
Lua:
function onHealthChange(localPlayer, health, maxHealth)
healthLabel:setText(""..health.. "")
healthBar:setTooltip(tr(healthTooltip, health, maxHealth))
healthBar:setValue(health, 0, maxHealth)
local healthPercent = ((health*100)/maxHealth)
local globalWidth = healthBar:getImageTextureWidth() -- 100%
local sizePercent = ((healthPercent*globalWidth)/100) -- x%
local percent = round(sizePercent, decimal)
healthBar:setWidth(percent)
healthBar:setImageClip(torect('0 0 ' .. tonumber(percent) .. ' 0'))
end
function onManaChange(localPlayer, mana, maxMana)
manaLabel:setText(""..mana.. "")
manaBar:setTooltip(tr(manaTooltip, mana, maxMana))
manaBar:setValue(mana, 0, maxMana)
local manaPercent = ((mana*100)/maxMana)
local globalWidth = manaBar:getImageTextureWidth() -- 100%
local sizePercent = ((manaPercent*globalWidth)/100) -- x%
local percent = round(sizePercent, decimal)
if maxMana == 0 then -- this code is important, when max mana is 0, then the mana bar will show it full you can adjust it as you need
manaBar:setWidth(90)
else
manaBar:setWidth(percent)
manaBar:setImageClip(torect('0 0 ' .. tonumber(percent) .. ' 0'))
end
end
don't forget to add
Lua:
healthLabel = nil
manaLabel = nil
Lua:
healthLabel = healthInfoWindow:recursiveGetChildById('healthLabel')
manaLabel = healthInfoWindow:recursiveGetChildById('manaLabel')
and at last, thanks to @margoh for his help, he guide me on how to do this in this link
[RIPOFF] Health/Mana bar.
Hello, it is the answear to this: OTClient - Health/Mana Bars (https://otland.net/threads/health-mana-bars.274279/) Also can be used by people who wants to use custom textured bars. At this point I am not going to explain every single step, because if you modify your ui, you don't need it. Lua...
otland.net
You should need to add to your modules files codes that he show us in that thread
best regards
Last edited: