ID:160038
 
i wanto to change the mob icon when is on a area this is the code that i use.... im new im using the examples to lear step by step

// simple2.dm: Introducing procs

/*
The following code defines two new variables for all area
objects. One is called "look" and the other is called
"sound". These are used to display some text and to play
a sound when a player enters the area.
*/


area
var
look
sound
player
area/area3/area3



Entered()
//Put the cursor on "Entered" and press F1 to learn
//more about this procedure. You can also press F1
//on the << operator to learn about that.
if(player in area3)
icon_state = "nadar"
else
icon_state = ""


usr << look
usr << sound(sound,1)

area1
look = "I smell a dirty rat"
sound = 'jazzy.mid'

area2
look = "Holy cow there is a big rat!"
sound = 'cavern.mid'

area3
look = "U swim into the sea!"


Still i cant change the icon state of the mob



Put your code in <DM> tags. Judging by that, though, it looks like you have inconsistent indentation around your if() and else in Entered().
Still i cant change the mob icon state
AntiAnti wrote:
i wanto to change the mob icon when is on a area this is the code that i use.... im new im using the examples to lear step by step

// simple2.dm: Introducing procs
>
> /*
> The following code defines two new variables for all area
> objects. One is called "look" and the other is called
> "sound". These are used to display some text and to play
> a sound when a player enters the area.
> */

>
> area
> var
> look
> sound
> player
> area/area3/area3
>
>
>
> Entered()
> //Put the cursor on "Entered" and press F1 to learn
> //more about this procedure. You can also press F1
> //on the << operator to learn about that.
> if(player in area3)
> icon_state = "nadar"
> else
> icon_state = ""
>
>
> usr << look
> usr << sound(sound,1)
>
> area1
> look = "I smell a dirty rat"
> sound = 'jazzy.mid'
>
> area2
> look = "Holy poop there is a {freakin'} rat!"
> sound = 'cavern.mid'
>
> area3
> look = "U swim into the sea!"
>
>

Still i cant change the icon state of the mob

stom.Entered is one of several areas where use of usr is not correct. The atom/movable that Entered the area is passed in an argument that you can use to change their icon state.

It also seems you're unaware of implicit use of src -- when you leave off the container object and use statements such as icon_state = "nadar", you've implicitly assigned this operation to src as though you've typed src.icon_state = "nadar". In this case, src is the area, and not the atom whose icon_state you're looking to change.

Also, please refrain from colourful language in forum posts, even if it is part of your code.
First things first, never put usr in a proc. It is only even OK in verbs and the mouse procs (Click(), MouseOver(), etc.).

Second, use Entered()'s arg

area/Entered(atom/movable/A)


Lastly, your code makes no sense! Might I suggest the DM guide

player: This will be null. It is a variable that you are never setting!

area3: This will not do anything, since it is also not being set.

area
Entered(atom/A)
if(ismob(A)) //if A is a mob...
var/mob/M = A //type cast! Look this up
if(istype(src,/area/area3)) //if the area is an area3
M.icon_state = "nadar" //change the player's state to this
else //if it isn't an area3
M.icon_state = "" //change the player's state to this


M << look //output the look var to M
M << sound(sound,1) //play the sound var to M


</dm>
In response to Jeff8500
it work great like this THANKS
 area
var
look
sound



Entered(atom/A)
//Put the cursor on "Entered" and press F1 to learn
//more about this procedure. You can also press F1
//on the << operator to learn about that.
if(ismob(A))
var/mob/M = A
if(istype(src,/area/area3))
usr.icon_state = "nadar"
else
usr.icon_state = ""


hw i can put a delay when the mob is over that area?
In response to AntiAnti
Ugh, you've been told NOT to use usr in procs. Doesn't look like you understand the code you're using, so look into that. You need to keep using the argument A (or the equivalent M var, though you could get rid of it as you don't have to typecast here) which refers to whatever Entered the area.

And what do you mean by 'putting a delay'?
In response to Kaioken
I think he means a sleep delay before the coding actually takes effect. Not sure though.