ID:171704
 
This isn't working for me can some1 help

obj/meter
icon = 'meter.dmi'
icon_state = "5"
if(Life = 4)
icon_state = "4"


I'm wanting it to when Lives go down 1 the icon of the meter will change states also.
No need for higher life levels because there are a total of 5 lives in the game, no more.
ElderKain wrote:
This isn't working for me can some1 help

> obj/meter
> icon = 'meter.dmi'
> icon_state = "5"
> if(Life = 4)
> icon_state = "4"
>

I'm wanting it to when Lives go down 1 the icon of the meter will change states also.
No need for higher life levels because there are a total of 5 lives in the game, no more.

First off, you have to have that (the if statement and the line below it) in a proc of some kind because if() can only be used at runtime. What you should do is make an update proc and call it whenever a mobs Life variable changes. That and the change we talked about in Chatters should come out to something like this.

obj/meter
proc/Update(number_of_lives) //We are going to send the mobs life variable to the proc.
icon_state="[number_of_lives]" // Set it directly to lives, so we don't have a huge mess.


Pretty simple, no? Ok, now we have to call it. There are a few ways we could do this, but I prefer to make the object a mob variable and call it from there, like so.

mob
var
lives
tmp/obj/meter/lifemeter // Define it as tmp so it doesn't save...
// and use some type-casting so that we can access...
// local procs and vars.
Login()
..()
lifemeter=new() // Create it in Login() so that only clients get it.
client.screen+=lifemeter
lifemeter.Update(lives)


Now whenever you need to update it just call lifemeter.Update(lives). Please understand that this is just an example that you can integrate into your project, if you just copy and paste it it won't work. =)