Page 1 of 2

How to make and customize boss hp bar?

Posted: Sat Sep 29, 2018 1:54 pm
by Rakalborn
Sorry, i am noob at luna, but i want to make hp bar for bowser in my project.Image

Re: How to make and customize boss hp bar?

Posted: Sun Oct 14, 2018 10:40 pm
by ThePieSkyHigh
I have no idea. Just here because this had no posts and it would seem nobody cares. I care, but I don't know how. If somebody told you how, we could all learn how then it would be a nice Luna feature.

Re: How to make and customize boss hp bar?

Posted: Sun Oct 14, 2018 10:57 pm
by PixelPest
ThePieSkyHigh wrote:
Sun Oct 14, 2018 10:40 pm
I have no idea. Just here because this had no posts and it would seem nobody cares. I care, but I don't know how. If somebody told you how, we could all learn how then it would be a nice Luna feature.
Please don't respond to help topics if you don't actually have an answer--it's a little pointless

Re: How to make and customize boss hp bar?

Posted: Mon Oct 15, 2018 4:00 pm
by ThePieSkyHigh
Sorry about that. It would really be nice though!

Re: How to make and customize boss hp bar?

Posted: Wed Oct 17, 2018 2:31 am
by MECHDRAGON777
I would be able to help make it, but I need to know the following info:
  • Graphics in .png format.
  • Location in either X,Y of the setup, or the general area.
  • Event to start the fight.
...but if I do it, I would need to suggest make the boss in question start with an event to trigger the showing of it.

Re: How to make and customize boss hp bar?

Posted: Mon Nov 05, 2018 11:28 am
by ThePieSkyHigh
WAIT!

I had an idea!

If you make custom graphics, you should make the same amount as bowser's health depending on what your hitting him with. (e.g. 3 plants can kill him)

Later, make the graphics replace a BGO, and with an event make it disappear and make the next health bar appear. (the one with less life drawn in it!)

Idk if I explained well, I don't think I did. Maybe it could work with custom graphic for lakatu, that floats around and kinda follows you so the bar won't stay in one place like a BGO..

Re: How to make and customize boss hp bar?

Posted: Mon Nov 05, 2018 12:10 pm
by Hoeloe
That's an extremely convoluted and inefficient way to do it. Drawing the bar with LunaLua is a substantially easier and more effective method.

Re: How to make and customize boss hp bar?

Posted: Mon Nov 05, 2018 12:22 pm
by ThePieSkyHigh
It's pretty simple if you ask me.

Added in 37 seconds:
without the lakatu, mind you.

Re: How to make and customize boss hp bar?

Posted: Mon Nov 05, 2018 12:53 pm
by Hoeloe
It's far, far simpler to just use Lua. Really it is.

Re: How to make and customize boss hp bar?

Posted: Mon Nov 05, 2018 1:20 pm
by ThePieSkyHigh
Oh. Well in that case can you script it?

Re: How to make and customize boss hp bar?

Posted: Mon Nov 05, 2018 1:33 pm
by Emral
ThePieSkyHigh wrote:
Mon Nov 05, 2018 1:20 pm
Oh. Well in that case can you script it?
Mechdragon already offered up his help in scripting it further up in this topic.

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 2:27 am
by MECHDRAGON777
Image
I think I should at least post some of my work (Quick Mach-up) to show a basis. (This is just a basic Health Bar using two graphics, and about 18 lines of code. I did not account for the death of Bowser in the code, but I am assuming this is similar to what you are asking for?

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 9:31 am
by ThePieSkyHigh
Looks really good!

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 9:36 am
by Hoeloe
MECHDRAGON777 wrote:
Wed Nov 07, 2018 2:27 am
I think I should at least post some of my work (Quick Mach-up) to show a basis. (This is just a basic Health Bar using two graphics, and about 18 lines of code. I did not account for the death of Bowser in the code, but I am assuming this is similar to what you are asking for?
Worth remembering that imagic exists and has a built-in function for drawing bars like that. Really this kind of health bar is ridiculously easy to make, only requiring 3 lines of code or so.

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 10:30 am
by MECHDRAGON777
Image
Although I should look into imagic a bit more than I already have, I can see my if-then statement on line 9 and 11 is not needed to just leave line 10, and the debug text on line 17 is also not needed. I also can replace the table "Bowser" with just "86" and also remove all spaces making it 6 lines less of code. I am sure the graphics would still be loaded with imagic and last time I looked into imagic, it takes around the same amount of code as glDraw. Then again, you are the expert here. (I also agree about Health being easy to display.)

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 10:39 am
by Hoeloe
MECHDRAGON777 wrote:
Wed Nov 07, 2018 10:30 am
Although I should look into imagic a bit more than I already have, I can see my if-then statement on line 9 and 11 is not needed to just leave line 10, and the debug text on line 17 is also not needed. I also can replace the table "Bowser" with just "86" and also remove all spaces making it 6 lines less of code. I am sure the graphics would still be loaded with imagic and last time I looked into imagic, it takes around the same amount of code as glDraw. Then again, you are the expert here. (I also agree about Health being easy to display.)
You should be using ipairs instead of pairs too.

And drawing health the way you've done it is grossly inefficient. The imagic method uses the imagic.Bar function, which just does pretty much all of it for you. All you have to do is feed in a number between 0 and 1, and it'll draw the bar correctly. Yes you have to feed in images if you want textures, but if you just want flat colours then you don't.

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 10:43 am
by PixelPest
MECHDRAGON777 wrote:
Wed Nov 07, 2018 10:30 am
Image
Although I should look into imagic a bit more than I already have, I can see my if-then statement on line 9 and 11 is not needed to just leave line 10, and the debug text on line 17 is also not needed. I also can replace the table "Bowser" with just "86" and also remove all spaces making it 6 lines less of code. I am sure the graphics would still be loaded with imagic and last time I looked into imagic, it takes around the same amount of code as glDraw. Then again, you are the expert here. (I also agree about Health being easy to display.)
This code in itself is really not good. Mix of global and properly-scoped variables, inconsistent variable naming, no reason to have 86 in a table (as you can just do NPC.get(id)). Also again definitely need to look into imagic. However you don't load images with imagic, just use imagic.Bar

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 12:10 pm
by Emral
Use this thing which we refuse to provide any documentation to in this topic!

imagic.bar{named arguments}

Available args:
x: x-coordinate
y: y-coordinate
width: width
height: height
percent: filled portion of bar (between 0 and 1, optional)
texture: the texture (optional)
align: alignment relative to pivot coordinate (default: ALIGN_TOPLEFT)
baralign: how the bar itself should be aligned, determines how the bar fills (default: ALIGN_BOTTOMLEFT)
bgwidth: width of the bar background (default: 2 pixels more than the bar itself)
bgheight: height of the bar background (default: 2 pixels more than the bar itself)
scene: whether you're drawing the bar to scene or screen coords (defaults to false)
color: color tint. if no texture is supplied, this defaults to green (else white)
bgtexture: texture for bar background (optional)
priority: render priority (optional)
outline: whether to draw an outline or not (defaults to false)
outlinecolor: color tint for outline, defaults to white

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 1:08 pm
by MECHDRAGON777
I was also unable to find documentation on the Wiki for lua. Thanks Enjl.

Re: How to make and customize boss hp bar?

Posted: Wed Nov 07, 2018 5:06 pm
by Hoeloe
Enjl wrote:
Wed Nov 07, 2018 12:10 pm
Use this thing which we refuse to provide any documentation to in this topic!
Apologies I keep forgetting imagic doesn't have documentation available outside its source file.