ID:140886
 
Code:
obj
health1
if(hpbar=="grey")
icon='health bar base grey.dmi'
icon_state="1"
if(hpbar=="red")
icon='health bar base red.dmi'
icon_state="1"
if(hpbar=="blue")
icon='health bar base blue.dmi'
icon_state="1"
layer=5
New(client/C)
screen_loc="1,15"
C.screen+=src

and
atom/var
hpbar="grey"
list/editobj=list("Bars"=list("Health"=list("Grey","Red","Blue"),"Mana"=list("Grey","Red","Blue")))


mob
host
verb
Edit()
var/editing=input("What do you want to edit?")as null|anything in editobj
if(!editing)
usr<<"you dont edit anything"
if(editing=="Bars")
var/editing2=input("What do you want to edit?")as null|anything in "Bars"
if(editing2=="Health")
var/editing3=input("What color you want?")as null|anything in "Health"
if(editing3=="Grey")
hpbar="grey"
if(editing3=="Red")
hpbar="red"
if(editing3=="Blue")
hpbar="blue"

Problem description:
when i try to compile i get 12 duplicate definition and 3 instruction is not alowed here errors(all in upper code). i wanted to make host able to change hp bar color but it didn't work. please help. thank you

You can't put any executed code outside procs. So, those three if() statements (they should be if()-else if()-else if() by the way) need to go in some proc, which you call whenever you change the relevant variable.

In your second snippet, the editobj list really needs to be global. And for the input, "in "Health"" should be "in editobj["Health"]". Same with "in "Bars"".
Ripper man5 wrote:
obj
> health1
> New(src)
> if(hpbar=="grey")
> icon='health bar base grey.dmi'
> icon_state="1"
> if(hpbar=="red")
> icon='health bar base red.dmi'
> icon_state="1"
> if(hpbar=="blue")
> icon='health bar base blue.dmi'
> icon_state="1"
> layer=5
> New(client/C)
> screen_loc="1,15"
> C.screen+=src
>


I'm not 100% sure.

If you were to use that you could use this.

obj
health1
New(src)
icon=file("health bar base [hpbar].dmi")
icon_state="1"
layer=5
New(client/C)
screen_loc="1,15"
C.screen+=src


or something similar to that, not sure because the previous code there by ripperman didn't have all the tab keys in, and used spaces and all instead.
Are you forgetting that New(src) wont call unless the object is used/placed?

Also, if it weren't, it would be setting the icon to none and all, so it would still be invisible anyways, and while that is not enough, it wouldn't be placed, so if it did have an icon, you wouldn't know it.
First of all, New(src) is a really really stupid thing to do. Naming any argument or variable "usr" or "src" is just going to cause confusion at best and errors at worst.

That aside, writing two New() procs like that is pointless, because only one will be called, and you aren't calling ..() in either. So one is essentially just thrown out. They should be consolidated into one New().