Page 1 of 1

control mod behavior from console

Posted: Fri Sep 26, 2014 9:19 am
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!

Re: control mod behavior from console

Posted: Fri Sep 26, 2014 2:51 pm
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).

Re: control mod behavior from console

Posted: Fri Sep 26, 2014 6:02 pm
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.