How to make a simple GUI

Place to get help with not working mods / modding interface.
Post Reply
Neel
Burner Inserter
Burner Inserter
Posts: 11
Joined: Sat Sep 10, 2016 11:26 am
Contact:

How to make a simple GUI

Post by Neel »

I have added a special entity. When the entity is clicked, I want to prompt the user with a simple prompt dialog to show a number associated with the entity and allow the user to change the number. How do I go about doing this? So just like the way to specify the number of items requested by a requester chest.

MrDoomah
Fast Inserter
Fast Inserter
Posts: 196
Joined: Mon Jun 01, 2015 1:11 pm
Contact:

Re: How to make a simple GUI

Post by MrDoomah »


User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: How to make a simple GUI

Post by DedlySpyder »

There still isn't any proper way to handle players clicking on an entity to fire an event (unless they changed recently). I think your best bet is to make a custom keyboard shortcut that checks the player's selected entity for your entity and handle the GUI from there. (although I believe some people use an on tick event to check constantly, I like to avoid on tick as much as possible)

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: How to make a simple GUI

Post by aubergine18 »

DedlySpyder wrote:There still isn't any proper way to handle players clicking on an entity to fire an event (unless they changed recently). I think your best bet is to make a custom keyboard shortcut that checks the player's selected entity for your entity and handle the GUI from there. (although I believe some people use an on tick event to check constantly, I like to avoid on tick as much as possible)
Correct.

Also, the .operable property of an entity can be set to false to prevent default entity GUI opening when its clicked: listen for built events, if it's your entity then set event.created_entity.operable = false
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Modding help”