ID:179096
 
I am using this object based verb to set mob/var/reg_2_card to be the source object that the verb belongs to.

set_reg_2()
if(usr.reg_2_lock == 0)
usr.reg_2_pri = src.pri
usr.reg_2_act = src.act
usr << "Register 2 set to [usr.reg_2_act]"
usr.reg_2_card = src //SET THE OBJ to A VAR
usr.reg_2_lock = 1
src.icon_state = "used"
confirm()
else
if(usr.reg_2_lock == 1)
var/check = input("Register 2 is already set, to [usr.reg_2_act]. Would you like to change it?") in list("Yes","No")
if(check == "Yes")
usr.Restorereg2()
usr.reg_2_pri = src.pri
usr.reg_2_act = src.act
usr << "Register 2 reset to [usr.reg_2_act]"
usr.reg_2_card = src
usr.reg_2_lock = 1
src.icon_state = "used"
else
if(usr.reg_2_lock == 2)
usr << "This register is locked until you repair damage to your bot."
return


Then I tired to use this mob/proc to set the object back to it's original icon state, but it doesn't seem to be working.

Restorereg2()
var/obj/O
// set_act(obj/O,a as num)
// O.act = a
for(O in usr.reg_2_card)
O.icon_state = "main"

Any suggestions??
Look up initial()
In response to Nadrew
Nadrew wrote:
Look up initial()

No offense Nadrew but that response wass simplistic and negates the possibility that you actually read my entire post.

initial would work if I was referencing the object directly i.e.
/obj/card2/icon_state = "main" or initial, whatever the correct synntax would be.

HOWEVER I am accessing the object indirectly, the VALUE of the object name stored in a veriable, hence:

Restorereg2()
var/obj/O
for(O in usr.reg_2_card)
O.icon_state = "main"

What I am trying to figure out is why referencing the object in this way is not returning the icon to the original state. It is apparently not referencing the object correctly but in what other way could I reference the icon.

The other possibility is that when I call usr.reg_2_card = src in the initial set it is not setting a usable value there,it sets 'cardXX' but not /obj/cardXX , in that case what would I do to set that var to the card or set the card to a value, I cannot access the object in question directly.

Tryely I mean no offence, it is just a little annoying to spend 6 hours trying to figure out a series of problems just to be snaged on a little one like this, so I post in the forum and get a "Duh, go look it up dummie" response, when the response really doesn't apply to the actual question.

Thankyou for the help and for putting up with my moments of frustration.

Illya
Illyena wrote:
usr.reg_2_card = src //SET THE OBJ to A VAR
...
for(O in usr.reg_2_card)
O.icon_state = "main"

Hi Illyena,

It looks like the problem is that you are assigning reg_2_card to an object, and treating it like a list down below. Instead, try this:
var/obj/O = usr.reg_2_card // or whatever type it is
O.icon_state = "main"

or shorter,
usr.reg_2_card.icon_state = "main"
In response to Tom
I knew there was something wrong with either I ws refernceing the variable or assigning it. I just couldn't put my finger on it.

Thank you