ID:142713
 
Code:


Problem description:

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.
Sorcha wrote:
Code:
>

Problem description:

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.

icon_state=variable

or in your case as you've explained..

icon_state=orig_icon

mob
verb
bat_transform()
if(density)
density=0
usr<<"You are now a bat."
icon_state="bat" // You will want to change this
else
density=1
usr<<"You are no longer a bat"
icon_state="normal" // And this too.


Is that what you mean? And secondly, don't post on both the developer how-to and code problems with the same question, it's pointless.
In response to Scizzees
This is essentially what I have tried and as a basic verb it works fine. The problem is that each player will have a different icon so in the change back from bat part of the verb I can't just tell it to change to a specific icon (such as normal as you have here) as each characters icon will be different so I somehow need it to remeber their specific original icon and revert back to that.
In response to Bunnie
This is what I thought but somewhere I need to set the orig_icon variable so that holds the players original icon_state but i don't know where abouts in the code to do this and how to do it since aechplayer has a different icon_state. I have tried doing it at the start of the verb but it doesn't seem to work.
In response to Sorcha
Sorcha wrote:
This is what I thought but somewhere I need to set the orig_icon variable so that holds the players original icon_state but i don't know where abouts in the code to do this and how to do it since aechplayer has a different icon_state. I have tried doing it at the start of the verb but it doesn't seem to work.

orig_state = icon_state
//Apply Icon_state change here
In response to Bunnie
Thanks. I got another post to the same question on the Developer How-To forum (wasn't sure where to put it at first) and tha problem is now sorted. Thanks for the help