ID:267244
 
what I'm doing is when I create an object I store it in a mobs var like so:


mob/var/obj/fence
mob
verb
create()
var/obj/O=new /obj/fence(src.loc)
src.fence=O

then later on I try to change the icon_state...

mob/proc/change_icon_state()
src.fence.icon_state="stage2"


I get errors though, how would I go about doing this?

perhaps just giving the obj a variable and saying
for(var/obj/O in world)
if(O.changeiconstate==1)
O.icon_state="stage2"

would that be more efficient, and the only way to do it?

What are some other options?
What error are you getting?
In response to Garthor
runtime error: Cannot modify null.icon_state.
proc name: StartCombatSimulation (/mob/proc/StartCombatSimulation)
source file: agameofkings.dm,189
usr: (/mob/pc/Snow)
src: (/mob/pc/Snow)
call stack:
(/mob/pc/Snow): StartCombatSimulation(the infantry unit 1 (/mob/fire))
(/mob/pc/Snow): StartCombatSimulation(the infantry unit 1 (/mob/fire))
In response to Jon Snow
That means O is null. Put in an if(O == null) check in there. And, after you assign it, put in a debugging message telling you what O's value is.