ID:627283
 
(See the best response by Lugia319.)
I'm just curious, is there a way to detect if the mob is on stand by?
I want to make a stand by animation so when the mob is inactive the animation will execute.
I've tried putting the animation as default icon_state but the problem is it will just continue the animation when you go on stand by and won't restart it after I moved.


So did you considering changing the icon state and then resetting it when you want it to start over?
Well, I did some experiment.
Like when the player moves a var (mob/var/standby_mode) is set to 0 then when the player hits the space bar which triggers the player mob to stop, it calls a proc to check if standby_mode == 1 then changes the src.icon_state to the standby animation then loops it a bit until the player moves that sets the standby_mode to zero and restore the default moving icon_state. But still it gives the same result.

I tried the flick() pro but it only made things worse coz the player icon state won't revert back immediately when you moved.

I made the player mob move in a direction given by the player continuously until the player hits the space bar.
Looks simple enough. Could you show me where you're calling this check and when you modify standby_mode?
mob
Stat()
var/keys_held = ""
for(var/k in client.keys)
if(client.keys[k])
if(keys_held)
keys_held += ", "
keys_held += "[k]"

stat("keys", keys_held)
.=..()

key_down(k)

//WASD movement, made possible with keyboard library
if(k == "w")
walk(src, NORTH)
standby_on=0
else if(k == "s")
walk(src, SOUTH)
standby_on=0
else if(k == "d")
walk(src, EAST)
standby_on=0
else if(k == "a")
walk(src, WEST)
standby_on=0
else if(k == "space")
walk(src,0)
standby_on=1 //this is the var I renamed it a bit
spawn(1)
standby_anim()
mob/proc
standby_anim()
if(src.standby_on==1)
src.icon_state="standby"
else return 0
spawn(1)
standby_anim()


That's basically my script it's a bit longer considering that I got multiple characters with multiple icon_state that needed to be checked 1 by 1 to specify how will the icon_state be changed depending on the character's default icon_state.
//standby_anim() modified to suit multiple character checking
standby_anim()
//all characters are all from the same .dmi with different icon_state
if(src.standby_on==1)
if(src.icon_state=="Nero")
src.icon_state="stndNero"
else if(src.icon_state=="Xanthine")
src.icon_state="stndXanthine"
else if(src.icon_state=="Leafie")
src.icon_state="stndLeafie"

spawn(1)
standby_anim()
Let's just focus on the base case. If it works without fancy, it should work with fancy.

At any rate, I believe you've modified a library, compromising its stability.

I never see you set the icon state to normal, only to the standby icon state. Make sure you're calling whatever returns the icon state to normal.
Oh, forgot to put it in there...
here it is:
//on standby_anim()
else
src.icon_state = src.default_icon_state//var that holds the default icon_state, defined when user creates a character.


It does restore the default icon state but the animation still pauses and continues when the mob is not moving, same thing as renaming the standby animation to the same name as the default moving icon state.
Best response
Do you have the animation set to loop indefinitely or just once?
loop indefinitely...
wait, does that affects the pausing and continuing thing?

It means that it will run the animation forever. Set it to once and you should be good.
okie, I'm gonna try it. Thanks!
It worked well, I also found a way to shorten my checking script. Now my only problem is how to make it repeat the standby animation after few seconds (randomly).
Anyway, THANK YOU VERY MUCH!!! (^_^)
Problem solved!
Why aren't you just using client.inactivity ?

This is equal to the amount of time (in 10ths of seconds) since the player's last action (such as executing a verb, moving, clicking an object, or selecting a topic link). This value is reset to 0 after each new action so you can use it to determine the time that has passed since the last one. 

Example:
mob/verb/inactivity()
usr << "You have been inactive for [client.inactivity/10] seconds."
Eh, how do I use that exactly?
mob
Stat()
if(client.inactivity>=1)
standby_anim()
..()

that's a questionable script... and looking at the inactivity's functions... I don't seem it can help me... you copied that post from the guide,eh? It appears that it shows the time of inactivity, and I don't think it'll be a use for me. It'll only slow my game coz all of the "checking" running under the Stat(). But if you could show me a good code for the client.inactivity maybe I'll consider using it. You see, I'm not familiar with that function yet.
found a way to shorten my checking, I got 4 characters to choose from and counting so I generated a shortcut for it.
standby_anim()
var/N = src.default_icon_state
if(client.inactivity>=5)//using the client.inactivity var, thanks to A.T.H.K. who told me about it
src.icon_state="stnd[N]"
else
src.icon_state="[N]"


This way I won't be checking on each and every character's icon_state.
http://www.byond.com/ forum/?post=159801&hl=inactivity#comment690525

I find it funny that the variable was NOT mentioned here.. first thing that comes to mind.

After all Lugia319 started that post.
oh, so I would use it just like how I used the key_down() proc...
So all I have to do is check if the player is inactive for a certain period of time then execute the standby animation, then randomly set a value that will serve as the gap between each standby animations. This way I could also create more standby animations and use pick() so every time standby animation executes, it would pick a random standby animation.
Great! Thanks!
Page: 1 2