ID:151212
 
OK, I want it so in under my stats section, my HP has a bar of little graphics that change, here's the code:
if(src.max_HP)
S = src.HP/src.max_HP
if(S < 0.25) stat("HP","[src.max_HP] icon='Bar4.dmi'")
else if(S < 0.5) stat("HP","[src.max_HP] icon='Bar3.dmi'")
else if(S < 0.75) stat("HP","[src.max_HP] icon='Bar2.dmi'")
else stat("HP","[src.max_HP] icon='Bar1.dmi'")

But when I run the game, instead of the bar being there, it says icon='bar1.dmi' instead of the icon, help!
On 2/18/01 10:43 pm Gilser wrote:
OK, I want it so in under my stats section, my HP has a bar of little graphics that change, here's the code:
if(src.max_HP)
S = src.HP/src.max_HP
if(S < 0.25) stat("HP","[src.max_HP] icon='Bar4.dmi'")
else if(S < 0.5) stat("HP","[src.max_HP] icon='Bar3.dmi'")
else if(S < 0.75) stat("HP","[src.max_HP] icon='Bar2.dmi'")
else stat("HP","[src.max_HP] icon='Bar1.dmi'")

But when I run the game, instead of the bar being there, it says icon='bar1.dmi' instead of the icon, help!

Yeah... what you've got there is text, instead of what you want, which is, uh, not text. Here's one option:

mob/var/obj/HP_bar
mob/New()
HP_bar = new() // We can talk about what to put in the parentheses if all this works...

if(src.max_HP)
S = src.HP/src.max_HP
if(S < 0.25) HP_bar.icon = 'Bar4.dmi'
else if(S < 0.5) HP_bar.icon = 'Bar3.dmi'
else if(S < 0.75) HP_bar.icon = 'Bar2.dmi'
else HP_bar.icon = 'Bar1.dmi'
stat("HP: [src.max_HP] ",HP_bar)

Here I give each mob a variable called HP_bar, which will become a real object when the mob comes into being. Then in Stat(), you change the icon of that object, and put the object itself into the stat panel.

I didn't bother to test this code, so let me know if there are errors.

Z
In response to Zilal
Yeah there's errors, 27 of em!!!
They are as follows:
HP bar.dm:3:error:HP_bar :unknown variable type
HP bar.dm:3:error:= :expected a constant expression
error:undefined type: //obj/HP_bar/mob
HP bar.dm:5:error:src.max_HP:bad var
HP bar.dm:5:error:if :invalid variable name: reserved word
error:undefined type: //obj/HP_bar/mob
HP bar.dm:6:error:src.HP:bad var
error:undefined type: //obj/HP_bar/mob
HP bar.dm:6:error:src.max_HP:bad var
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:7:error:'Bar4.dmi':cannot find file
HP bar.dm:8:error:< :bad variable definition
HP bar.dm:8:error:if :invalid variable name: reserved word
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:8:error:'Bar3.dmi':cannot find file
HP bar.dm:9:error:< :bad variable definition
HP bar.dm:9:error:if :invalid variable name: reserved word
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:9:error:'Bar2.dmi':cannot find file
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:10:error:'Bar1.dmi':cannot find file
HP bar.dm:10:error:= :expected a constant expression
error:undefined type: //obj/HP_bar/mob
HP bar.dm:11:error:src.max_HP:bad var
HP bar.dm:11:error:HP_bar:bad var
CharacterSaving.dm:164:error:icon:re-initialization of global var
CharacterSaving.dm:168:error:icon:re-initialization of global var
CharacterSaving.dm:172:error:icon:re-initialization of global var
CharacterSaving.dm:176:error:icon:re-initialization of global var
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
Objs.dm:71:error:'sword.dmi':cannot find file
Enemies.dm:3:error: icon: bad variable
Thanks
Gilser
In response to Gilser
On 2/18/01 11:32 pm Gilser wrote:
Yeah there's errors, 27 of em!!!
They are as follows:
HP bar.dm:3:error:HP_bar :unknown variable type
HP bar.dm:3:error:= :expected a constant expression
error:undefined type: //obj/HP_bar/mob
HP bar.dm:5:error:src.max_HP:bad var
HP bar.dm:5:error:if :invalid variable name: reserved word
error:undefined type: //obj/HP_bar/mob
HP bar.dm:6:error:src.HP:bad var
error:undefined type: //obj/HP_bar/mob
HP bar.dm:6:error:src.max_HP:bad var
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:7:error:'Bar4.dmi':cannot find file
HP bar.dm:8:error:< :bad variable definition
HP bar.dm:8:error:if :invalid variable name: reserved word
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:8:error:'Bar3.dmi':cannot find file
HP bar.dm:9:error:< :bad variable definition
HP bar.dm:9:error:if :invalid variable name: reserved word
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:9:error:'Bar2.dmi':cannot find file
BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
HP bar.dm:10:error:'Bar1.dmi':cannot find file
HP bar.dm:10:error:= :expected a constant expression
error:undefined type: //obj/HP_bar/mob
HP bar.dm:11:error:src.max_HP:bad var
HP bar.dm:11:error:HP_bar:bad var

I think this one would address some of those errors.

You still need to change the HP parts and max_HP parts to be what you use in your code. For example, 'hp' and 'maxhp' if those are what you use.

Also, close Dream Seeker before trying to compile in new icons; your .rsc is locked by the running world, so that prevents some things too.

mob/var/obj/HP_bar = new
mob/Stat()
if(src.max_HP)
S = src.HP/src.max_HP
if(S < 0.25) HP_bar.icon = 'Bar4.dmi'
else if(S < 0.5) HP_bar.icon = 'Bar3.dmi'
else if(S < 0.75) HP_bar.icon = 'Bar2.dmi'
else HP_bar.icon = 'Bar1.dmi'
stat("HP: [src.max_HP] ",HP_bar)

CharacterSaving.dm:164:error:icon:re-initialization of global var
CharacterSaving.dm:168:error:icon:re-initialization of global var
CharacterSaving.dm:172:error:icon:re-initialization of global var
CharacterSaving.dm:176:error:icon:re-initialization of global var

No idea why you're getting those, but it has nothing to do with Z's code.

BYOND Error: the file C:\Program Files\BYOND\bin\OS.rsc is locked up!
Objs.dm:71:error:'sword.dmi':cannot find file
Enemies.dm:3:error: icon: bad variable

Those other ones in there are your fault. For example, missing 'sword.dmi', and the error in Enemies.dm. =)
In response to Spuzzum
OK, I've brought it to 1 error, it is:
Mob vars.dm:297:error: bad argument definition

Here's the code and the surrounding code that the problems in:
mob/New()
//init max stats
src.max_HP = src.HP
src.max_shield = src.shield
src.max_iq = src.iq
src.max_dexterity = src.dexterity
src.max_armor = src.armor
src.max_immunity = src.immunity

if(!src.party_id) src.party_id = src //self-aligned

src.Tick() //start up the mob ticker (which runs till the mob dies)
return ..()

mob/Stat()
mob/var/obj/HP_bar = new
mob/Stat()
if(src.max_HP)
S = src.HP/src.max_HP
if(S < 0.25) HP_bar.icon = 'Bar4.dmi'
else if(S < 0.5) HP_bar.icon = 'Bar3.dmi'
else if(S < 0.75) HP_bar.icon = 'Bar2.dmi'
else HP_bar.icon = 'Bar1.dmi'
stat("HP: [src.max_HP] ",HP_bar)

if(src.max_shield)
S = src.shield/src.max_shield
if(S < 0.25) stat("shield","[src.max_shield] exhausted")
else if(S < 0.5) stat("shield","[src.max_shield] feeble")
else if(S < 0.75) stat("shield","[src.max_shield] fair")
else stat("shield","[src.max_shield] full")

As always, al help is appretiated,
Thanks
Gilser
In response to Gilser
On 2/19/01 10:31 pm Gilser wrote:
OK, I've brought it to 1 error, it is:
Mob vars.dm:297:error: bad argument definition

Here's the code and the surrounding code that the problems in:
mob/New()
//init max stats
src.max_HP = src.HP
src.max_shield = src.shield
src.max_iq = src.iq
src.max_dexterity = src.dexterity
src.max_armor = src.armor
src.max_immunity = src.immunity

if(!src.party_id) src.party_id = src //self-aligned

src.Tick() //start up the mob ticker (which runs till the mob dies)
return ..()

Nothing wrong with mob/New() there... I recoqnise Dan's handiwork, too!

mob/Stat()

Get rid of that line right there.

mob/var/obj/HP_bar = new
mob/Stat()
if(src.max_HP)
S = src.HP/src.max_HP
if(S < 0.25) HP_bar.icon = 'Bar4.dmi'
else if(S < 0.5) HP_bar.icon = 'Bar3.dmi'
else if(S < 0.75) HP_bar.icon = 'Bar2.dmi'
else HP_bar.icon = 'Bar1.dmi'
stat("HP: [src.max_HP] ",HP_bar)

if(src.max_shield)
S = src.shield/src.max_shield
if(S < 0.25) stat("shield","[src.max_shield] exhausted")
else if(S < 0.5) stat("shield","[src.max_shield] feeble")
else if(S < 0.75) stat("shield","[src.max_shield] fair")
else stat("shield","[src.max_shield] full")


Indentation's messed.

Your code should only say this (starting from where you deleted the first mob/Stat()... DON'T delete the second mob/Stat(), though);

mob/var/obj/HP_bar = new
mob/Stat()
if(src.max_HP)
S = src.HP/src.max_HP
if(S < 0.25) HP_bar.icon = 'Bar4.dmi'
else if(S < 0.5) HP_bar.icon = 'Bar3.dmi'
else if(S < 0.75) HP_bar.icon = 'Bar2.dmi'
else HP_bar.icon = 'Bar1.dmi'
stat("HP: [src.max_HP] ",HP_bar)

if(src.max_shield)
S = src.shield/src.max_shield
if(S < 0.25) stat("shield","[src.max_shield] exhausted")
else if(S < 0.5) stat("shield","[src.max_shield] feeble")
else if(S < 0.75) stat("shield","[src.max_shield] fair")
else stat("shield","[src.max_shield] full")
In response to Spuzzum
AHHHH!!!! MORE ERRORS!!! Now there's 25!!!here they are...:
loading OS.dme
CharacterSaving.dm:103:error:imput:bad proc
Mob vars.dm:286:error:= :expected a constant expression
Mob vars.dm:289:error:S:bad var
Mob vars.dm:290:error:S:bad var
Mob vars.dm:291:error:S:bad var
Mob vars.dm:292:error:S:bad var
Mob vars.dm:297:error:S:bad var
Mob vars.dm:298:error:S:bad var
Mob vars.dm:299:error:S:bad var
Mob vars.dm:300:error:S:bad var
Mob vars.dm:304:error:S:bad var
Mob vars.dm:305:error:S:bad var
Mob vars.dm:306:error:S:bad var
Mob vars.dm:307:error:S:bad var
Mob vars.dm:312:error:S:bad var
Mob vars.dm:313:error:S:bad var
Mob vars.dm:314:error:S:bad var
Mob vars.dm:315:error:S:bad var
Mob vars.dm:320:error:S:bad var
Mob vars.dm:321:error:S:bad var
Mob vars.dm:322:error:S:bad var
Mob vars.dm:323:error:S:bad var
Mob vars.dm:329:error:S:bad var
Mob vars.dm:330:error:S:bad var
Mob vars.dm:331:error:S:bad var
Mob vars.dm:332:error:S:bad var
CharacterSaving.dm:122:error:help_text:bad input type

OS.dmb - 27 errors, 0 warnings

Thanks,
Gilser