-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do i fix the Head Icons of my Custom Healthbar? #13445
Comments
Update |
Also to make that if statement be better, do this instead: if (ClientPrefs.data.zerothCustomHealthbar)
{
healthBar = new Bar(0, FlxG.height * (!ClientPrefs.data.downScroll ? 0.89 : 0.11), 'healthBarBlank', function() return health, 0, 2);
}
else
{
healthBar = new Bar(0, FlxG.height * (!ClientPrefs.data.downScroll ? 0.89 : 0.11), 'healthBar', function() return health, 0, 2);
healthBar.screenCenter(X);
}
healthBar.leftToRight = false;
healthBar.scrollFactor.set();
healthBar.visible = !ClientPrefs.data.hideHud;
healthBar.alpha = ClientPrefs.data.healthBarAlpha;
reloadHealthBarColors();
uiGroup.add(healthBar); Since both statements, after creating the bar do the same code |
they have a very similar code bcs i dont understand how to make the bar larger and thiccer maybe healthbar.barCenter actually does what i wanted to do but i was never able to make it work in lua maybe it was a setPropertyFromClass or setPropertyFromGroup thing but idk |
It is infact You might wanna try doing it in healthBar.barCenter = 613.5; right after creating the healthBar |
It did worked on |
Ik, I've said that. I'm trying to see if I can solve this in Lua on my own. Keep testing until you can solve it or until I finish the script. |
I didnt fully read your response but i think it will move how much the heads is than the actual healthbar size like what this means exactly: healthBar = new Bar(0, FlxG.height * (!ClientPrefs.data.downScroll ? 0.89 : 0.11), 'healthBar', function() return health, 0, 2); especially in the part that says about downScroll and function() return health |
I didnt fully read your response but i think it will move how much the
heads is than the actual healthbar size
but you could tell me how the bar is generated
like what this means exactly:
healthBar = new Bar(0, FlxG.height * (!ClientPrefs.data.downScroll ? 0.89
: 0.11), 'healthBar', function() return health, 0, 2);
especially in the part that says about downScroll and function() return
health
bcs in downScroll, idk what the ? and the : means, i think it is a if else
statement but in one line but im not entirely sure
The variable that's breaking the icons is the `barCenter` thing. Don't
remove it though, as It's crucial. Also there's a better way to do that Lua
script, using `runHaxeCode`; Where as of 0.7, you can use `loadGraphic` on
each part of the healthBar.
… |
i mean... -- Originally Made by Misha21220
-- Edited by ItzJiggzy
-- It Only works in Psych Engine 0.7.X
local function to_hex(rgb)
return string.format("%x", (rgb[1] * 0x10000) + (rgb[2] * 0x100) + rgb[3])
end
function onCreatePost()
if getPropertyFromClass('backend.ClientPrefs', 'data.zerothCustomHealthbar') and not hideHud then
-- Adding New Sprites and Configuration
-- Border
makeLuaSprite('HealthBarBorder', 'ZerothBarBorderAlt')
setObjectCamera('HealthBarBorder', 'hud')
setProperty('HealthBarBorder.alpha', getPropertyFromClass('backend.ClientPrefs', 'data.healthBarAlpha'))
scaleLuaSprite('HealthBarBorder', 0.8, 0.8)
screenCenter('HealthBarBorder', 'x')
setProperty('HealthBarBorder.y', getProperty('healthBar.y') - 108)
addLuaSprite('HealthBarBorder', true)
-- Stats
makeLuaSprite('HealthBarStats', 'ZerothBarStats')
setObjectCamera('HealthBarStats', 'hud')
setProperty('HealthBarStats.alpha', getPropertyFromClass('backend.ClientPrefs', 'data.healthBarAlpha'))
scaleLuaSprite('HealthBarStats', 0.8, 0.7)
screenCenter('HealthBarStats', 'x')
setProperty('HealthBarStats.y', getProperty('healthBar.y') + 25)
addLuaSprite('HealthBarStats', true)
-- Enemy HP
makeLuaSprite('EnemyHP', 'DAD_HP_BAR', 0, 0)
makeGraphic('EnemyHP', 425, 45, 'FFFFFF')
setObjectCamera('EnemyHP', 'hud')
screenCenter('EnemyHP', 'x')
setProperty('EnemyHP.origin.x', 425)
setProperty('EnemyHP.y', getProperty('healthBar.y') - 20)
setProperty('EnemyHP.alpha', 1)
setProperty('EnemyHP.color', getColorFromHex(to_hex(getProperty("dad.healthColorArray"))))
addLuaSprite('EnemyHP', false)
-- Player HP
makeLuaSprite('PlayerHP', 'BF_HP_BAR', 0, 0)
makeGraphic('PlayerHP', 850, 45, 'FFFFFF')
setObjectCamera('PlayerHP', 'hud')
screenCenter('PlayerHP', 'x')
setProperty('PlayerHP.y', getProperty('healthBar.y') - 20)
setProperty('PlayerHP.alpha', 1)
setProperty('PlayerHP.color', getColorFromHex(to_hex(getProperty("boyfriend.healthColorArray"))))
addLuaSprite('PlayerHP', false)
-- Original flxBar
screenCenter('healthBar', 'x')
-- setProperty('healthBar.scale.x', 1.45) -- This is Invalidated if barWidth or barOffset is changed
setProperty('healthBar.barWidth', 850)
setProperty('healthBar.barOffset.x', -125)
setProperty('healthBar.alpha', 0)
end
end
function onUpdate()
setProperty('EnemyHP.scale.x', 2 - getProperty('health'))
setProperty('EnemyHP.x', getProperty('healthBar.barCenter') - 425)
end
-- Dont know why i felt proud/satisfied on like this thingy, when it basically others guy code but with my textures
-- Hopefully in the future i could make the flxbar actually like work the way i wanted to be, but for now i like it like this. This two did change the heads position but it didnt change the size of the bar is like their heads follow a invisible bounds that is not related to the Bar itself but somehow it is? |
Not only I've fixed the issue, I've made a better Lua script. Just do: function onUpdatePost()
setProperty('iconP1.offset.x', -296)
setProperty('iconP2.offset.x', -298)
end |
Here's the fix in source code. if (ClientPrefs.data.zerothCustomHealthbar)
{
healthBar = new Bar(0, FlxG.height * (!ClientPrefs.data.downScroll ? 0.89 : 0.11), 'healthBarBlank', function() return health, 0, 2);
healthBar.bg.y -= (!ClientPrefs.data.downScroll ? 142 : 108);
healthBar.bg.scale.set(0.8, 0.8);
if (!ClientPrefs.data.downScroll)
scoreTxt.y -= 20;
else
scoreTxt.y += 17;
}
else
{
healthBar = new Bar(0, FlxG.height * (!ClientPrefs.data.downScroll ? 0.89 : 0.11), 'healthBar', function() return health, 0, 2);
healthBar.screenCenter(X);
}
healthBar.leftToRight = false;
healthBar.scrollFactor.set();
healthBar.visible = !ClientPrefs.data.hideHud;
healthBar.alpha = ClientPrefs.data.healthBarAlpha;
reloadHealthBarColors();
uiGroup.add(healthBar); On the if (ClientPrefs.data.zerothCustomHealthbar)
{
iconP1.offset.x = -296;
iconP2.offset.x = -298;
for (ico in [iconP1, iconP2])
{
if (!ClientPrefs.data.downScroll)
ico.offset.y = 27;
else
ico.offset.y = -7;
}
} |
also, removing the screenCenter part was also a placeholder also, in what version did you run that healthbar.lua, bcs is not really working at all |
I'm using 0.7.1h Release, but how did it break? Send in a screenshot |
is just not running at all, thats it |
Oh, I've made a typo. Change |
thats literally the same word |
Yes but the capital letters are case sensitive, in your ClientPrefs variable, It's |
also, plz write some comments thingy explaining the code, especially if i wanna start making my custom healthbars with runHaxeCode |
Mind sending in that opponent icon, so I can give you the proper offsets |
i edited some of that offsets and a bit of the code function onCreatePost()
runHaxeCode([[
if (ClientPrefs.data.zerothCustomHealthbar) {
var statsBg:FlxSprite = new FlxSprite(-202).loadGraphic(Paths.image('ZerothBarStats'));
if (!ClientPrefs.data.downScroll)
statsBg.y = game.healthBar.bg.y - 630;
else
statsBg.y = game.healthBar.bg.y - 40;
statsBg.scale.set(0.8, 0.7);
game.healthBar.add(statsBg);
var barPosY = (!ClientPrefs.data.downScroll ? 635 : 95);
function updatePos() {
game.healthBar.leftBar.x = 339;
game.healthBar.rightBar.x = 339;
game.healthBar.leftBar.y = barPosY;
game.healthBar.rightBar.y = barPosY;
game.iconP1.offset.x = -308;
game.iconP2.offset.x = -308;
if (!ClientPrefs.data.downScroll) {
game.iconP1.offset.y = 5;
game.iconP2.offset.y = 5;
} else {
game.iconP1.offset.y = -7;
game.iconP2.offset.y = -7;
}
}
game.healthBar.leftBar.scale.set(1.43, 3.8);
game.healthBar.rightBar.scale.set(1.43, 3.8);
game.healthBar.bg.x -= 300;
game.healthBar.bg.y -= (!ClientPrefs.data.downScroll ? 132 : 108);
game.healthBar.bg.scale.set(0.8, 0.8);
game.healthBar.bg.loadGraphic(Paths.image('ZerothBarBorderAlt'));
if (!ClientPrefs.data.downScroll)
game.scoreTxt.y -= 10;
else
game.scoreTxt.y += 17;
}
]])
end
function onUpdatePost()
runHaxeFunction('updatePos')
end probably you need to use the equivalent of this
in the haxe code |
I know, however; I've tried using those variables but they simply broke themselves while I was using them. Also wdym you edited the scoreTxt offset, you didn't have to. But I'll change the script to use those instead |
i changed the offsets to be like 10 pixels lower and yeah, those two things tend to break, is like they dont like the idea of scaling stuff welp, this is kinda how the code of the healthbar been looking function onCreatePost()
runHaxeCode([[
if (ClientPrefs.data.zerothCustomHealthbar) {
var statsBg:FlxSprite = new FlxSprite(-202).loadGraphic(Paths.image('ZerothBarStats'));
if (!ClientPrefs.data.downScroll)
statsBg.y = game.healthBar.bg.y - 640; // - 630
else
statsBg.y = game.healthBar.bg.y - 40;
statsBg.scale.set(0.8, 0.7);
game.healthBar.add(statsBg);
var barPosY = (!ClientPrefs.data.downScroll ? 625 : 95); // 635 : 95
function updatePos() {
game.healthBar.leftBar.x = 339;
game.healthBar.rightBar.x = 339;
game.healthBar.leftBar.y = barPosY;
game.healthBar.rightBar.y = barPosY;
game.iconP1.offset.x = -308; // -296
game.iconP2.offset.x = -308; // -298
if (!ClientPrefs.data.downScroll) {
game.iconP1.offset.y = 15; // 5
game.iconP2.offset.y = 15; // 5
} else {
game.iconP1.offset.y = -7;
game.iconP2.offset.y = -7;
}
}
game.healthBar.leftBar.scale.set(1.43, 3.8);
game.healthBar.rightBar.scale.set(1.43, 3.8);
// game.healthBar.barWidth = 850;
// game.healthBar.barOffset.x = -125;
game.healthBar.bg.x -= 300;
game.healthBar.bg.y -= (!ClientPrefs.data.downScroll ? 142 : 108); // 132 : 108
game.healthBar.bg.scale.set(0.8, 0.8);
game.healthBar.bg.loadGraphic(Paths.image('ZerothBarBorderAlt'));
if (!ClientPrefs.data.downScroll)
game.scoreTxt.y -= 20; // 10
else
game.scoreTxt.y += 17;
}
]])
end
function onUpdatePost()
runHaxeFunction('updatePos')
end |
You should've tested the offsets correctly. Also, trying to use barWidth
here and it isn't going that well, but you were right
Em qua., 18 de out. de 2023 22:04, Ramiro0045 ***@***.***>
escreveu:
… i changed the offsets to be like 10 pixels lower
but thats bcs of my text that is on the side of the healthbar
maybe i should move those up that the entire healthbar down
—
Reply to this email directly, view it on GitHub
<#13445 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AYFVJYA7B47KGXITDB2LRTDYAB4CLAVCNFSM6AAAAAA6AJ2J2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRZG4ZDSMJUHE>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
so, the only thing we can do is wait to shadow to fix this issue about scale |
I've followed your way of using said method and it worked, but the icons didn't follow the bar correctly as they are connected to that But try moving your text up instead of moving the healthbar down, as any other high position change will break it. |
i wanna close this issue in github unless you want to tell me something more that i should know |
Overwriting the original healthbar is better as then, whenever the HUD changes anything or some script changes something in the healthbar, you don't have to use another variable instead of using Also how did the script mess up? Did you do anything to it? |
i mean yeah, i did change a bit of the offsets either way, ill be sticking to my original healthbar lua that doesnt use any runHaxeCode, aka this: -- Originally Made by Misha21220
-- Edited by ItzJiggzy
-- It Only works in Psych Engine 0.7.X
local function to_hex(rgb)
return string.format("%x", (rgb[1] * 0x10000) + (rgb[2] * 0x100) + rgb[3])
end
function onCreatePost()
if getPropertyFromClass('backend.ClientPrefs', 'data.zerothCustomHealthbar') and not hideHud then
-- Adding New Sprites and Configuration
-- Score Txt
setProperty('scoreTxt.y', getProperty('scoreTxt.y') - 5)
-- Border
makeLuaSprite('HealthBarBorder', 'ZerothBarBorderAlt')
setObjectCamera('HealthBarBorder', 'hud')
setProperty('HealthBarBorder.alpha', getPropertyFromClass('backend.ClientPrefs', 'data.healthBarAlpha'))
scaleLuaSprite('HealthBarBorder', 0.8, 0.8)
screenCenter('HealthBarBorder', 'x')
setProperty('HealthBarBorder.y', getProperty('healthBar.y') - 108)
addLuaSprite('HealthBarBorder', true)
-- Stats
makeLuaSprite('HealthBarStats', 'ZerothBarStats')
setObjectCamera('HealthBarStats', 'hud')
setProperty('HealthBarStats.alpha', getPropertyFromClass('backend.ClientPrefs', 'data.healthBarAlpha'))
scaleLuaSprite('HealthBarStats', 0.8, 0.7)
screenCenter('HealthBarStats', 'x')
setProperty('HealthBarStats.y', getProperty('healthBar.y') + 25)
addLuaSprite('HealthBarStats', true)
-- Enemy HP
makeLuaSprite('EnemyHP', 'DAD_HP_BAR', 0, 0)
makeGraphic('EnemyHP', 425, 45, 'FFFFFF')
setObjectCamera('EnemyHP', 'hud')
screenCenter('EnemyHP', 'x')
setProperty('EnemyHP.origin.x', 425)
setProperty('EnemyHP.y', getProperty('healthBar.y') - 20)
setProperty('EnemyHP.alpha', 1)
setProperty('EnemyHP.color', getColorFromHex(to_hex(getProperty("dad.healthColorArray"))))
addLuaSprite('EnemyHP', false)
-- Player HP
makeLuaSprite('PlayerHP', 'BF_HP_BAR', 0, 0)
makeGraphic('PlayerHP', 850, 45, 'FFFFFF')
setObjectCamera('PlayerHP', 'hud')
screenCenter('PlayerHP', 'x')
setProperty('PlayerHP.y', getProperty('healthBar.y') - 20)
setProperty('PlayerHP.alpha', 1)
setProperty('PlayerHP.color', getColorFromHex(to_hex(getProperty("boyfriend.healthColorArray"))))
addLuaSprite('PlayerHP', false)
-- Original flxBar
screenCenter('healthBar', 'x')
-- setProperty('healthBar.scale.x', 1.45) -- This is Invalidated if barWidth or barOffset is changed
setProperty('healthBar.y', getProperty('healthBar.y'))
setProperty('healthBar.barWidth', 850)
setProperty('healthBar.barOffset.x', -125)
setProperty('healthBar.alpha', 0)
if downscroll then
-- Score Txt
setProperty('scoreTxt.y', getProperty('healthBar.y') + 31.5)
setTextSize('scoreTxt', getTextSize('scoreTxt') - 4)
-- Border
setProperty('HealthBarBorder.y', getProperty('healthBar.y') - 87) -- -66
setProperty('HealthBarBorder.flipY', true)
-- Stats
setProperty('HealthBarStats.y', getProperty('healthBar.y') + 25) -- +43 +25
scaleLuaSprite('HealthBarStats', 0.6825, 0.48)
screenCenter('HealthBarStats', 'x')
end
-- alphaControlTest()
end
end
-- function alphaControlTest()
-- setProperty('HealthBarBorder.alpha', 0.50)
-- setProperty('HealthBarStats.alpha', 0.50)
-- setProperty('EnemyHP.alpha', 0)
-- setProperty('PlayerHP.alpha', 0)
-- end
function onUpdate()
setProperty('EnemyHP.scale.x', 2 - getProperty('health'))
setProperty('EnemyHP.x', getProperty('healthBar.barCenter') - 425)
end |
Well, that's something I can't really fix as it's part of the code of Psych, it always appends the icons to So either, use my script with the icons lagging behind or use your script with the icons being in the wrong place or fix that in your script. That's up to you |
or just use my original lua (no runHaxeCode) script |
Yea I've just said that. |
welp, im still gonna use my script |
Welp that's what we could do. Anyways good luck on your mod and close the issue |
yeah, thank you for your help |
Describe your problem here.
Basically, im trying to port my mod that was made in 0.6.3 to 0.7.1h
but the healthbar changed a lot code wise, which made it so im unable to fix the head icons
or at least use updateHitbox('healthBar'); to fix it
so, how do i fix it in psych engine 0.7.1h?
this is how my HealthBar Script in lua looks like
and also, this are the Textures that is using, even tho they are not connected to the actions of the flxBar or the Head Icons
HealthBarBorder:
HealthBarStats:
Are you modding a build from source or with Lua?
Lua
What is your build target?
Windows x64
Did you edit anything in this build? If so, mention or summarize your changes.
Yes, I edited a ClientPrefs.hx to add custom options and Playstate.hx to change the healthbarImage without affectting the original healthbar, also Achievements but that doesnt have anything to do with this issue, i didnt change anything on HealthIcon.hx or any of the maths related to the Healthbar or the Head Icons
The text was updated successfully, but these errors were encountered: