I have constant-combinator based entities on different surfaces that should act as portals. When the player clicks at one of them the on_gui_opened event is send and caught by my code. The player is then teleported to the surface and position of the paired entity with a different character. The characters always remain on the surface they are, only the player teleports. That last bit might be important. Because if the character holds something in it's cursor then the cursor is placed on the new surface. For example a stone furnace is build or a blueprint is placed.
How can I prevent the game from placing whatever is in the characters cursor?
Note: I can't clear the cursor. One function of the mod is to place a generated blueprint in the players hand when returning to the real world.
teleporting in on_gui_open places cursor on new surface
Re: teleporting in on_gui_open places cursor on new surface
Just disable teleporting if something is in the cursor.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: teleporting in on_gui_open places cursor on new surface
Sounds like the placing is caused by the player still holding the mouse-button down. As that is a physical input there's not much you can do about it except for delaying the giving-of-the-blueprint? Maybe give them a capsule and use on_put_item to detect when they release the button.
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.
-
- Filter Inserter
- Posts: 587
- Joined: Sun Jun 09, 2019 10:40 pm
- Contact:
Re: teleporting in on_gui_open places cursor on new surface
...or clear the hand prior to teleport, and on the next tick do the giving, maybe?eradicator wrote: ↑Wed Sep 04, 2019 1:36 pmSounds like the placing is caused by the player still holding the mouse-button down. As that is a physical input there's not much you can do about it except for delaying the giving-of-the-blueprint? Maybe give them a capsule and use on_put_item to detect when they release the button.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: teleporting in on_gui_open places cursor on new surface
Physical input doesn't auto-clear the next tick. If that is indeed the problem.slippycheeze wrote: ↑Wed Sep 04, 2019 6:45 pm...or clear the hand prior to teleport, and on the next tick do the giving, maybe?eradicator wrote: ↑Wed Sep 04, 2019 1:36 pmSounds like the placing is caused by the player still holding the mouse-button down. As that is a physical input there's not much you can do about it except for delaying the giving-of-the-blueprint? Maybe give them a capsule and use on_put_item to detect when they release the button.
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: teleporting in on_gui_open places cursor on new surface
I fear that if I clear the cursor that simply means the player clicks somewhere. This could open another item if the mouse happens to be over one. For me worst case the player could be teleported every tick as long as the mouse button is pressed because it hits the teleport entity on both surfaces every time.
The thing is the physical input was already accepted on the original constant combinator and caused the on_gui_opened event. Why is it processed a second time? Why does teleporting or changing characters make the game forget that the mouse was pressed and that input has already been processed?
The thing is the physical input was already accepted on the original constant combinator and caused the on_gui_opened event. Why is it processed a second time? Why does teleporting or changing characters make the game forget that the mouse was pressed and that input has already been processed?
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: teleporting in on_gui_open places cursor on new surface
Because drag-to-build-more-than-one?
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: teleporting in on_gui_open places cursor on new surface
That kind of makes sense. And not. It's opening the gui for the constant combinator. So drag mode shouldn't be active.
- eradicator
- Smart Inserter
- Posts: 5206
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: teleporting in on_gui_open places cursor on new surface
You're putting something new into the cursor though. But that is a technical problem that you'll have to take up directly with the devs. Nothing we can do about obviously.mrvn wrote: ↑Sun Sep 08, 2019 12:40 amThat kind of makes sense. And not. It's opening the gui for the constant combinator. So drag mode shouldn't be active.
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.