Hi I'm new to modding Factorio, and I was wondering if there was a way to detect if the player was standing on top of rails.
I know it's possible to detect the surface beneath the player, but I didn't see any event relating to entities.
Thanks!
Detecting if player is standing on rails
Re: Detecting if player is standing on rails
No, there is no event when player walks above other entities
Re: Detecting if player is standing on rails
Idea1:
- Make type of prototype from CombatRobot that is always alive and always follows player on the surface.
- Make it being damaged when on rails and set notification on damage on.
Idea2:
Check with surface filter around the player location every tick, but might be a bit resource intensive.
- Make type of prototype from CombatRobot that is always alive and always follows player on the surface.
- Make it being damaged when on rails and set notification on damage on.
Idea2:
Check with surface filter around the player location every tick, but might be a bit resource intensive.
Re: Detecting if player is standing on rails
If you really only want to react to players standing on top of rails, it would be sufficient to look for rails at the player's position once per second (every 60 ticks: Store the position. On the next tick, if old position and current position differ, look for rails. However, if you want to react even if the player is just crossing (i.e., entering and immediately leaving) rails, you'd have to run the above on every tick.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!