ID:161852
 
I am creating a game in which clients answer a number of questions during login which result in them being assigned a specific icon depending how they answer.

This bit works fine and I can set the newmob.icon_state ok. The problem is that I want characters to have a power in which they change into a bat and become less dense i.e. set icon_state to bat and density to 0. I want the verb for this power to first check if they are dense and if they are change them to bat, if they are already in bat form i.e. density = 0 then I want it to change them back.

I have the code working ok to change their icon_state to bat and set the density and the check on density works fine, but when I go to change them back their original icon_state isn't restored.

I realise I need to store their original icon_state somewhere (in a new variable called orig_icon) but I am not sure how or where in the code to do this bearing in mind that after login everyone has a different icon_state and I don't know how to set the new orig_icon vaiable to the player individual icon_state.

Can anyone help me? I hope what I am trying to do makes sense. If not let me know and I will try to clarify it.
If I get your problem This SHOULD work.

mob/Bat/verb/Bat()
set category = "w/e"
set name = "w/e"
if(usr.density==1)
usr.density=0
usr.old_icon_state="[usr.icon_state]"
usr.icon_state = "w/e"
else
density=1
usr.icon_state="[usr.old_icon_state]"

mob
var
old_icon_state


It compiles O k. I'm not sure if it will work completely but it should
In response to CK Productions
There are no need for the quotes and brackets. Just old_icon_state = icon_state, and icon_state = old_icon_state.
In response to CK Productions
Thank You so much this works perfectly and does exactly what I want it to. I really appreciate your help