teleporting in on_gui_open places cursor on new surface

Place to get help with not working mods / modding interface.
Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

teleporting in on_gui_open places cursor on new surface

Post 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.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: teleporting in on_gui_open places cursor on new surface

Post by DaveMcW »

Just disable teleporting if something is in the cursor.

mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: teleporting in on_gui_open places cursor on new surface

Post 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.

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

Re: teleporting in on_gui_open places cursor on new surface

Post 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.
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.

slippycheeze
Filter Inserter
Filter Inserter
Posts: 587
Joined: Sun Jun 09, 2019 10:40 pm
Contact:

Re: teleporting in on_gui_open places cursor on new surface

Post 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?

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

Re: teleporting in on_gui_open places cursor on new surface

Post 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.
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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: teleporting in on_gui_open places cursor on new surface

Post 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?

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

Re: teleporting in on_gui_open places cursor on new surface

Post 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?
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.

mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: teleporting in on_gui_open places cursor on new surface

Post 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.

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

Re: teleporting in on_gui_open places cursor on new surface

Post 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.
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.

Post Reply

Return to “Modding help”