Skip to content
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

Closed
Ramiro0045 opened this issue Oct 14, 2023 · 37 comments
Closed

How do i fix the Head Icons of my Custom Healthbar? #13445

Ramiro0045 opened this issue Oct 14, 2023 · 37 comments
Labels
help wanted Extra attention is needed

Comments

@Ramiro0045
Copy link

Ramiro0045 commented Oct 14, 2023

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?
Screenshot_21
Screenshot_22

this is how my HealthBar Script in lua looks like

-- Originally Made by Misha21220
-- Edited by ItzJiggzy

-- It Only "works" in Psych Engine 0.7.X

function onCreate()
	if getPropertyFromClass('backend.ClientPrefs', 'data.zerothCustomHealthbar') and not hideHud then
		customHealthBar_Border()
		customHealthBar_Stats()
	end
end

function onCreatePost()
	if getPropertyFromClass('backend.ClientPrefs', 'data.zerothCustomHealthbar') and not hideHud then
		customHealthBar_FlxBar()
		-- customHealthBar_Icons()
	end
end

function customHealthBar_Border()
-- 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)
	
	-- if downscroll then
		-- setProperty('HealthBarBorder.y', getProperty('healthBar.y') - 66)
		-- setProperty('HealthBarBorder.flipY', true)
	-- end
end

function customHealthBar_Stats()
-- 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)
	-- if downscroll then
		-- setProperty('HealthBarStats.y', getProperty('healthBar.y') + 43)
	-- end
end

function customHealthBar_FlxBar()
local centeredFlxBar = 204 - (getProperty('healthBar.width') / 2)
-- flxBar -- Needs Fixing
	scaleObject('healthBar', 1.45, 4.3)
	-- screenCenter('healthBar', 'x')
	setProperty('healthBar.y', getProperty('healthBar.y') - 45)
	setProperty('healthBar.x', centeredFlxBar);
	-- updateHitbox('healthBar');
end

-- Dont know why i felt proud/satisfied on like this thingy, when it basically others guy code but with my textures

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:
ZerothBarBorderAlt

HealthBarStats:
ZerothBarStats

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

@Ramiro0045 Ramiro0045 added the help wanted Extra attention is needed label Oct 14, 2023
@BernardoGP4504
Copy link

Update healthBar.barCenter accordingly, the default is set to 637.5

@BernardoGP4504
Copy link

BernardoGP4504 commented Oct 17, 2023

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

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 17, 2023

they have a very similar code bcs i dont understand how to make the bar larger and thiccer
so it was a bit more of a placeholder until i was able to figure out how to make it like how i wanted in source

maybe healthbar.barCenter actually does what i wanted to do but i was never able to make it work in lua
it didnt change anything if it was setProperty('healthBar.barCenter', 1000) or setProperty('barCenter', 1000) or setProperty('healthBar.barCenter.x', 1000) or setProperty('barCenter.x', 1000), so idk

maybe it was a setPropertyFromClass or setPropertyFromGroup thing but idk

@BernardoGP4504
Copy link

BernardoGP4504 commented Oct 18, 2023

they have a very similar code bcs i dont understand how to make the bar larger and thiccer so it was a bit more of a placeholder until i was able to figure out how to make it like how i wanted in source

maybe healthbar.barCenter actually does what i wanted to do but i was never able to make it work in lua it didnt change anything if it was setProperty('healthBar.barCenter', 1000) or setProperty('barCenter', 1000) or setProperty('healthBar.barCenter.x', 1000) or setProperty('barCenter.x', 1000), so idk

maybe it was a setPropertyFromClass or setPropertyFromGroup thing but idk

It is infact setProperty('healthBar.barCenter', 637.5) or any value you might want, but the only way I did change the variable is by using it on update, which made the icons not wanna move

You might wanna try doing it in onCreatePost, but I would recommend doing it in source instead by just putting

healthBar.barCenter = 613.5;

right after creating the healthBar

@Ramiro0045
Copy link
Author

It did worked on onUpdate but it only moved the heads
but when the health gets updated, it moves the heads for one frame and goes back to the same static position

@BernardoGP4504
Copy link

It did worked on onUpdate but it only moved the heads but when the health gets updated, it moves the heads for one frame and goes back to the same static position

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.

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 18, 2023

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

@BernardoGP4504
Copy link

BernardoGP4504 commented Oct 18, 2023 via email

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 18, 2023

i mean...
i did make some workaround using graphics, but i was asking it was possible with the original flxBar

-- 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
setProperty('healthBar.barWidth', 850)
setProperty('healthBar.barOffset.x', -125)

is like their heads follow a invisible bounds that is not related to the Bar itself but somehow it is?

@BernardoGP4504
Copy link

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

@BernardoGP4504
Copy link

BernardoGP4504 commented Oct 18, 2023

healthbar.lua

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 updatePost function, put this there

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;
    }
}

@Ramiro0045
Copy link
Author

also, removing the screenCenter part was also a placeholder
idk what i was thinking when i removed that

also, in what version did you run that healthbar.lua, bcs is not really working at all
i heard somewhere that runHaxeCode and other hscript stuff was broken
im using v0.7.1h experimental

@BernardoGP4504
Copy link

I'm using 0.7.1h Release, but how did it break? Send in a screenshot

@Ramiro0045
Copy link
Author

is just not running at all, thats it
no errors or crashes, just not executing the code

@BernardoGP4504
Copy link

is just not running at all, thats it no errors or crashes, just not executing the code

Oh, I've made a typo. Change zerothCustomHealthBar to zerothCustomHealthBar in the script, inside the runHaxeCode call

@Ramiro0045
Copy link
Author

thats literally the same word

@BernardoGP4504
Copy link

thats literally the same word

Yes but the capital letters are case sensitive, in your ClientPrefs variable, It's healthbar not healthBar so fix that in the script and it'll work. Literally because of 1 letter 😐

@Ramiro0045
Copy link
Author

alright, now it actually works
even tho i wanna change some offsets
Screenshot_40

@Ramiro0045
Copy link
Author

also, plz write some comments thingy explaining the code, especially if i wanna start making my custom healthbars with runHaxeCode

@BernardoGP4504
Copy link

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

@Ramiro0045
Copy link
Author

icon-zeroth

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 19, 2023

i edited some of that offsets and a bit of the code
even tho the heads are still like not properly getting that the bar is larger

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

Screenshot_41

probably you need to use the equivalent of this

setProperty('healthBar.barWidth', 850)
setProperty('healthBar.barOffset.x', -125)

in the haxe code
(barOffset moves the starting point of the path that the heads follow and barWidth is how long that path is)

@BernardoGP4504
Copy link

i edited some of that offsets and a bit of the code even tho the heads are still like not properly getting that the bar is larger

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

Screenshot_41

probably you need to use the equivalent of this

setProperty('healthBar.barWidth', 850)
setProperty('healthBar.barOffset.x', -125)

in the haxe code (barOffset moves the starting point of the path that the heads follow and barWidth is how long that path is)

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

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 19, 2023

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

and yeah, those two things tend to break, is like they dont like the idea of scaling stuff
but without that, the head icons which is the main problem doesnt get actually solved

welp, this is kinda how the code of the healthbar been looking
even tho, we probably have to use another way to scale the bar if we cant use scale commands

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

@BernardoGP4504
Copy link

BernardoGP4504 commented Oct 19, 2023 via email

@Ramiro0045
Copy link
Author

so, the only thing we can do is wait to shadow to fix this issue about scale
and maybe in the future he makes a healthbar editor, but i doubt it since there isnt a stage editor yet and i think that is more important than a custom healthbar, but who knows

@BernardoGP4504
Copy link

Screenshot_41

probably you need to use the equivalent of this

setProperty('healthBar.barWidth', 850)
setProperty('healthBar.barOffset.x', -125)

in the haxe code (barOffset moves the starting point of the path that the heads follow and barWidth is how long that path is)

so, the only thing we can do is wait to shadow to fix this issue about scale and maybe in the future he makes a healthbar editor, but i doubt it since there isnt a stage editor yet and i think that is more important than a custom healthbar, but who knows

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 barCenter variable, so still big offset.x for them

But try moving your text up instead of moving the healthbar down, as any other high position change will break it.
healthbar.lua

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 19, 2023

if this healthbar was just shorter but the barWitdh or the barOffset stay the same value
it will 100% work
Screenshot_42

but like i said, i dont think this healthbar thingy is possible to look good without using graphics and hide the original healthbar
but thank you for explain the code, even tho i wont really use it for the healthbar thing, it could be useful for more source stuff

but i mean, it could be useful for healthbar if i decided to have the heads on the side, than on the center following the healthbar

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 19, 2023

i wanna close this issue in github unless you want to tell me something more that i should know

@BernardoGP4504
Copy link

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 game.healthBar or healthBar.

Also how did the script mess up? Did you do anything to it?

@Ramiro0045
Copy link
Author

Ramiro0045 commented Oct 19, 2023

i mean yeah, i did change a bit of the offsets
but even if the healthbar is displayed properly, the head icons will lag behind
but if the healthbar is displayed like that, the head icons will still lag behind but reach to the place they should go

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

@BernardoGP4504
Copy link

BernardoGP4504 commented Oct 19, 2023

i mean yeah, i did change a bit of the offsets but even if the healthbar is displayed properly, the head icons will lag behind but if the healthbar is displayed like that, the head icons will still lag behind but reach to the place they should go

either way, ill be sticking to my original healthbar lua that doesnt use any runHaxeCode

Well, that's something I can't really fix as it's part of the code of Psych, it always appends the icons to healthBar.barCenter and I can't change this value by the script.

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

@Ramiro0045
Copy link
Author

or just use my original lua (no runHaxeCode) script
since that actually works properly on the bar and on the icons
even if i have to hide the original bar and make graphics to simulate the bar

@BernardoGP4504
Copy link

or just use my original lua (no runHaxeCode) script since that actually works properly on the bar and on the icons even if i have to hide the original bar and make graphics to simulate the bar

Yea I've just said that.

@Ramiro0045
Copy link
Author

welp, im still gonna use my script
but i still appreciate your efforts on making this script and explaining it to me
since i wanted to like make some custom menus but i didnt understand how to actually move or change stuff, how i should write it or how to load graphics

@BernardoGP4504
Copy link

Welp that's what we could do. Anyways good luck on your mod and close the issue

@Ramiro0045
Copy link
Author

yeah, thank you for your help
ill just have to deal with that until shadow fixes it or someone smarter than both of us makes some documentation on how to properly make a healthbar with all the things that are added in Bar.hx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants