Page 1 of 1

teleporting in on_gui_open places cursor on new surface

Posted: Tue Sep 03, 2019 3:25 pm
by mrvn
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.

Re: teleporting in on_gui_open places cursor on new surface

Posted: Tue Sep 03, 2019 5:26 pm
by DaveMcW
Just disable teleporting if something is in the cursor.

Re: teleporting in on_gui_open places cursor on new surface

Posted: Tue Sep 03, 2019 6:24 pm
by mrvn
DaveMcW wrote:
Tue Sep 03, 2019 5:26 pm
Just disable teleporting if something is in the cursor.
That doesn't work. As said one function is to teleport the player back to the real world and put a blueprint into their hand. The blueprint then gets placed.

Re: teleporting in on_gui_open places cursor on new surface

Posted: Wed Sep 04, 2019 1:36 pm
by eradicator
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.

Re: teleporting in on_gui_open places cursor on new surface

Posted: Wed Sep 04, 2019 6:45 pm
by slippycheeze
eradicator wrote:
Wed Sep 04, 2019 1:36 pm
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.
...or clear the hand prior to teleport, and on the next tick do the giving, maybe?

Re: teleporting in on_gui_open places cursor on new surface

Posted: Wed Sep 04, 2019 6:54 pm
by eradicator
slippycheeze wrote:
Wed Sep 04, 2019 6:45 pm
eradicator wrote:
Wed Sep 04, 2019 1:36 pm
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.
...or clear the hand prior to teleport, and on the next tick do the giving, maybe?
Physical input doesn't auto-clear the next tick. If that is indeed the problem.

Re: teleporting in on_gui_open places cursor on new surface

Posted: Sat Sep 07, 2019 3:22 pm
by mrvn
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?

Re: teleporting in on_gui_open places cursor on new surface

Posted: Sat Sep 07, 2019 11:19 pm
by eradicator
mrvn wrote:
Sat Sep 07, 2019 3:22 pm
Why is it processed a second time?
Because drag-to-build-more-than-one?

Re: teleporting in on_gui_open places cursor on new surface

Posted: Sun Sep 08, 2019 12:40 am
by mrvn
eradicator wrote:
Sat Sep 07, 2019 11:19 pm
mrvn wrote:
Sat Sep 07, 2019 3:22 pm
Why is it processed a second time?
Because drag-to-build-more-than-one?
That kind of makes sense. And not. It's opening the gui for the constant combinator. So drag mode shouldn't be active.

Re: teleporting in on_gui_open places cursor on new surface

Posted: Sun Sep 08, 2019 1:16 am
by eradicator
mrvn wrote:
Sun Sep 08, 2019 12:40 am
eradicator wrote:
Sat Sep 07, 2019 11:19 pm
mrvn wrote:
Sat Sep 07, 2019 3:22 pm
Why is it processed a second time?
Because drag-to-build-more-than-one?
That kind of makes sense. And not. It's opening the gui for the constant combinator. So drag mode shouldn't be active.
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.