I'm opening a custom gui for a constant-combinator type entity in on_gui_opened. But when the player walks out of reach the gui stays open.
How can I automatically close the gui when the player moves out of reach?
Closing entity gui when player moves away
Re: Closing entity gui when player moves away
AFAIK It cannot be done automatically with the current features
You would need to check the distance yourself and determine if it is out of range
You would need to check the distance yourself and determine if it is out of range
Re: Closing entity gui when player moves away
There's and .
The refresh rate at which the first is called is not very high, but it should do the trick.
Code: Select all
[url=https://lua-api.factorio.com/latest/events.html#on_player_changed_position]on_player_changed_position[/url]
Code: Select all
[url=https://lua-api.factorio.com/latest/events.html#on_player_changed_surface]on_player_changed_surface[/url]
The refresh rate at which the first is called is not very high, but it should do the trick.
- eradicator
- Smart Inserter
- Posts: 5207
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: Closing entity gui when player moves away
The "refresh rate" of on_changed_position are the tile boundaries. If that's "not very high"...why are you moving inside a single tile so much ;).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Re: Closing entity gui when player moves away
Well of course, that makes sense.eradicator wrote: ↑Sat Nov 02, 2019 11:39 pmThe "refresh rate" of on_changed_position are the tile boundaries. If that's "not very high"...why are you moving inside a single tile so much .