[SOLVED]How to detect if a player is moving?

Place to get help with not working mods / modding interface.
Post Reply
Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

[SOLVED]How to detect if a player is moving?

Post by Villfuk02 »

I'd like to detect if a player is running. Is there any way to do so?
Last edited by Villfuk02 on Tue May 01, 2018 2:02 pm, edited 1 time in total.

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2633
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: How to detect if a player is moving?

Post by steinio »

Villfuk02 wrote:I'd like to detect if a player is running. Is there any way to do so?
http://lua-api.factorio.com/latest/even ... d_position
Image

Transport Belt Repair Man

View unread Posts

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: How to detect if a player is moving?

Post by Villfuk02 »

Tis looks usable. Not exactly what i was looking for, but with few lines of code, i can divide by moving speed (affected by exoskeletons, etc..)and ignore other means of transportation. THANKS!

User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2633
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: How to detect if a player is moving?

Post by steinio »

Villfuk02 wrote:Tis looks usable. Not exactly what i was looking for, but with few lines of code, i can divide by moving speed (affected by exoskeletons, etc..)and ignore other means of transportation. THANKS!
Yes i just wondered because your topic states moving and your text states running.
There is no LuaPlayer.speed or i didn't find it.
Image

Transport Belt Repair Man

View unread Posts

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: How to detect if a player is moving?

Post by Villfuk02 »

I just meant if he is normally walking/running (default by using WASD)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13218
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: How to detect if a player is moving?

Post by Rseding91 »

If you want to get ahold of me I'm almost always on Discord.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to detect if a player is moving?

Post by eradicator »

Depending on what level of precision you need, either .walking_state (linked by Rsed) or defines.events.on_player_changed_position.

Villfuk02
Long Handed Inserter
Long Handed Inserter
Posts: 77
Joined: Mon Apr 30, 2018 7:23 am
Contact:

Re: How to detect if a player is moving?

Post by Villfuk02 »

Thanks! that's exactly what i searched for

Post Reply

Return to “Modding help”