self defined GUI-element on a self defined custom entity

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
rldml
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Mar 06, 2016 2:38 am
Contact:

self defined GUI-element on a self defined custom entity

Post by rldml »

Hello there,

perhaps, this is already very simple and i just did'nt got that far into mod development right now.

It seems like a mess, if you want to create a self defined entity and tell the game to open a self defined new gui-window especially for it. It would be easier, if the Class LuaEntity would be extended with an attribute called gui (for example), which can be filled with a function to build the gui window and will be fired if the user clicks on the entity (like all the typical entities in the base game right now)

What i try to do in my mod:

- create a new entity, that looks like a constant combinator, but open another gui for reasons
- extend an existing entity gui, like the one of train stops with own gui elements

If there is an easy way to do this right now, i would be happy to get hints how to solve this :)

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

Re: self defined GUI-element on a self defined custom entity

Post by eradicator »

Code: Select all

script.on_event(defines.events.on_gui_opened,function(event)
  if event.entity.name == 'myentity' then
    local player = game.players[event.player_index]
    player.opened = make_my_gui(player,event.entity)
    end
  end)
Post Reply

Return to “Modding interface requests”