ID:264843
 
Code:
mob/Player

verb/ChangeRockIcon( I as icon )

var/obj/Rock/R = /obj/Rock // This is NOT the correct way to reference an object
R.icon = I // Set the icon of all Rocks to whatever the user inputted

obj/Rock

icon = 'someicon.dmi' // Just some default icon


Problem description:

I have forgotten something so trivial as how to reference an object so that I can modify its variables from outside its scope. I just want the ChangeRockIcon verb to change the icon of all Rock objects, but from within the /mob/Player scope. How is this done?
mob/Player
verb/ChangeRockIcon( I as icon )
for(var/obj/Rock/R in view())
R.icon = I // Set the icon of all Rocks to whatever the user inputted

obj/Rock
icon = 'someicon.dmi' // Just some default icon


changing view to whatever you need.
In response to SadKat Gaming
Remember that I want to change the icon of ALL rock objects, not just those in view. The "world" node will not suffice either since it only applies to rocks currently in the world, and not for NEW rocks to be created. The general way to change the icon var of an object is to set it within the scope of that object. But the problem statement indicates that I am looking to recall a way to do this from out of scope. So... expert advice, anyone?
In response to Lethal Dragon
Well, you could use that with world, and then use a variable for the default icon for rocks. Then edit the New() code for rocks so that whenever they are created, if the default icon var is different than the predefined icon, then use the default icon var?