ID:141194
 
Code:
// ...
closearts()
var/{obj/menu/souk/I1; obj/menu/shak/I2; obj/menu/byak/I3; obj/menu/cero/I4; obj/menu/grandcero/I5; obj/menu/arm/I6; obj/menu/attack/I7; obj/menu/defense/I8; obj/menu/mask/I9; obj/menu/vaicero/I10; obj/menu/reborn/I11; obj/menu/release/I12}
for(I1)
del(I1)
for(I2)
del(I2)
for(I3)
del(I3)
for(I4)
del(I4)
for(I5)
del(I5)
for(I6)
del(I6)
for(I7)
del(I7)
for(I8)
del(I8)
for(I9)
del(I9)
for(I10)
del(I10)
for(I11)
del(I11)
for(I12)
del(I12)
src=/obj/menu/arts
src.icon_state="arts"


Problem description:
I get this runtime error when that proc is exicuted:

runtime error: Cannot modify /obj/menu/arts.icon_state.
proc name: closearts (/mob/proc/closearts)
usr: M (/mob)
src: /obj/menu/arts (/obj/menu/arts)
call stack:
/obj/menu/arts (/obj/menu/arts): closearts()
the arts (/obj/menu/arts): Click(null, "default.map1", "icon-x=15;icon-y=12;left=1;scr...")
Hi1 wrote:
Code:
> // ...


OUCH! My eye!
Why not just do it in one line total with something like for(var/obj/menu/O) del O? Or if you can't do that, restructure your objects so you can.
Also, you realize this will delete all such objects, on a global basis? This will likely be problematic, but maybe you've been aware of this already.

I get this runtime error when that proc is exicuted:

runtime error: Cannot modify /obj/menu/arts.icon_state.

If you'll excuse the profanity: as they say, "no s***, Sherlock". I mean, I know you didn't start programming yesterday, so you should know what's wrong here, beginner or not. You're trying to change a var of a type path. Not possible. When you do Var.something = value, Var must always hold an object reference (that is to say, an object instance, or in another words, an object in existence), or you'll get an error. A type path isn't an object, rather it's just an object type, a blueprint, signature or specification for a certain type of objects.
Also, you shouldn't be arbitrarily setting src. That has no place here (in most places, unless you have a specific good reason).
When you set something's value, you have to specify a specific, single object whose var you want to change...
As for how to do that in your present situation, if you explained what you tried to do, I or someone else could answer. Basically you need to find that whatever-object-you're-looking-for (the object you want to change the icon_state of), reference it in a var, then use that var on the left-hand side of the . operator.
In response to Kaioken
Kaioken wrote:
Also, you realize this will delete all such objects, on a global basis? This will likely be problematic, but maybe you've been aware of this already.

I didn't realize that, how could I delete it on just the client?

If you'll excuse the profanity: as they say, "no s***, Sherlock". I mean, I know you didn't start programming yesterday, so you should know what's wrong here, beginner or not. You're trying to change a var of a type path. Not possible. When you do Var.something = value, Var must always hold an object reference (that is to say, an object instance, or in another words, an object in existence), or you'll get an error. A type path isn't an object, rather it's just an object type, a blueprint, signature or specification for a certain type of objects.

I don't know how to fix this; I understand what you're saying, but cannot seem to fix it...

As for how to do that in your present situation, if you explained what you tried to do, I or someone else could answer. Basically you need to find that whatever-object-you're-looking-for (the object you want to change the icon_state of), reference it in a var, then use that var on the left-hand side of the . operator.

Trying to make /obj/menu/arts icon state be "inuse" when clicked, and then show the other objects if they have them. Then if /obj/menu/arts is clicked again it's state be "arts" and delete all the moves on the users screen only...here is the full code:

obj
menu
say
icon='huds.dmi'
icon_state="say"
Click()
var/tmp/text=input("Say what?","Say")
view(usr) << "[usr.name]:: [text]"
New(client/C)
screen_loc="1,1"
C.screen+=src

arts
icon='huds.dmi'
icon_state="arts"
Click()
if(icon_state=="arts")
usr.openmenu("arts")
icon_state="inuse"
else
usr.closearts()
New(client/C)
screen_loc="11,1"
C.screen+=src

souk
icon='huds.dmi'
icon_state="souk"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,4"
C.screen+=src

shak
icon='huds.dmi'
icon_state="shak"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,2"
C.screen+=src

byak
icon='huds.dmi'
icon_state="byak"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,3"
C.screen+=src

cero
icon='huds.dmi'
icon_state="cero"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,2"
C.screen+=src

grandcero
icon='huds.dmi'
icon_state="grandcero"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,3"
C.screen+=src

arm
icon='huds.dmi'
icon_state="arm"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,2"
C.screen+=src

attack
icon='huds.dmi'
icon_state="attack"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,2"
C.screen+=src

defense
icon='huds.dmi'
icon_state="defense"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,3"
C.screen+=src

mask
icon='huds.dmi'
icon_state="mask"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,2"
C.screen+=src

vaicero
icon='huds.dmi'
icon_state="vaicero"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,3"
C.screen+=src

reborn
icon='huds.dmi'
icon_state="reborn"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,2"
C.screen+=src

release
icon='huds.dmi'
icon_state="release"
Click()
alert(usr,"Kidou test")
var/obj/menu/arts/I
for(I)
I.icon_state="arts"
New(client/C)
screen_loc="11,2"
C.screen+=src

mob
var
//SHINIGAMI//
soukatsui = 1
shakkahou = 1
byakuri = 1
//HOLLOW//
cero = 0
grandcero = 0
//SADO//
arm = 0
//INOUE//
attack = 0
defense = 0
//VAIZARD//
mask = 0
vaicero = 0
//ARRANCAR//
reborn = 0
release = 0
proc
openmenu(var/mname)
switch(mname)
if("arts")
if(usr.race == "Shinigami")
if(usr.soukatsui==1)
new/obj/menu/souk(client)
if(usr.shakkahou==1)
new/obj/menu/shak(client)
if(usr.byakuri==1)
new/obj/menu/byak(client)
else
return
else if(usr.race == "Hollow")
if(usr.cero==1)
new/obj/menu/cero(client)
if(usr.grandcero==1)
new/obj/menu/grandcero(client)
else
return
else if(usr.race == "Sado")
if(usr.arm==1)
new/obj/menu/arm(client)
else
return
else if(usr.race == "Inoue")
if(usr.attack==1)
new/obj/menu/attack(client)
if(usr.defense==1)
new/obj/menu/defense(client)
else
return
else if(usr.race == "Vaizard")
if(usr.mask==1)
new/obj/menu/mask(client)
if(usr.vaicero==1)
new/obj/menu/vaicero(client)
else
return
else if(usr.race == "Arrancar")
if(usr.reborn==1)
new/obj/menu/reborn(client)
if(usr.release==1)
new/obj/menu/release(client)
closearts()
var/{obj/menu/souk/I1; obj/menu/shak/I2; obj/menu/byak/I3; obj/menu/cero/I4; obj/menu/grandcero/I5; obj/menu/arm/I6; obj/menu/attack/I7; obj/menu/defense/I8; obj/menu/mask/I9; obj/menu/vaicero/I10; obj/menu/reborn/I11; obj/menu/release/I12}
for(I1)
del(I1)
for(I2)
del(I2)
for(I3)
del(I3)
for(I4)
del(I4)
for(I5)
del(I5)
for(I6)
del(I6)
for(I7)
del(I7)
for(I8)
del(I8)
for(I9)
del(I9)
for(I10)
del(I10)
for(I11)
del(I11)
for(I12)
del(I12)
usr=usr
src=/obj/menu/arts
src.icon_state="arts"