control mod behavior from console

Place to get help with not working mods / modding interface.
Post Reply
hirnwunde
Burner Inserter
Burner Inserter
Posts: 5
Joined: Fri Sep 26, 2014 7:33 am
Contact:

control mod behavior from console

Post by hirnwunde »

Hi folks,

after two days of study some mods and some try&error i got a little GUI-Menu which i call from console via a interface call.

Code: Select all

remote.call("IFaceFooUI", "show")
My interface-definitions are:

Code: Select all

gt = game.gettext
remote.addinterface("IFaceFooUI", { show = function()

	local rootFrame = game.player.gui.left.add{ type = "frame", name = "FooUIFrame", caption = gt("FooUICaption"), direction = "vertical" }
	rootFrame.add{ type = "flow", name = "FooUIFlow", direction = "horizontal" }
	
	rootFrame.FooUIFlow.add{ type = "button", name = "FooUIResourceButton", caption = gt("btnResourcesCaption") }
	rootFrame.FooUIFlow.add{ type = "button", name = "FooUIManufactButton", caption = gt("btnManufactCaption") }
	rootFrame.FooUIFlow.add{ type = "button", name = "FooUICloseButton", caption = gt("FooUICloseCaption") }
end
})
Ok ... when i type the command above, the frame with three buttons appears. Fine!
But: Is there a alternative to remote.call(...)?

Can i define a new shortcut (which is configurable in the Game-Settings-Menu (where you can set your graphics and sound, etc.)?
Can i define new console-commands like /showFooUI?

Thanks in advance and have a nice day!

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: control mod behavior from console

Post by FreeER »

hirnwunde wrote:But: Is there a alternative to remote.call(...)?
Currently, there is not (you could have them manually edit files but...). Well, you could use any of the normal events to call the function, say monitor the onputitem event for when the player tried to build a certain item (or did so ontop of a certain entity), same effect different method of invocation, but no you can't add buttons to the game or set custom commands for the console (well, technically it's a lua line interpreter so you should be able to type: anyValidVarName = function() game.remote.call("mod_interface_name", "IFaceFooUI") end and call that function instead, of course the console is reset with the game but I think that could be manually placed in the core/lualib folder for it to be done automatically...
If I recall correctly the devs wrote in the roadmap topic that they were thinking/planning on improving modding support after a couple major updates (aka, after multiplayer is mostly worked out).

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: control mod behavior from console

Post by Rseding91 »

The common way at the moment to bring up temporary GUIs is to provide two of some simple item that the player would place in the world to bring up the menu.

Onbuilt you would detect the player placed the "menu item" and then destroy it and give it back to the player and open the GUI if it wasn't already open.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Modding help”