LuaRemote
Registry of interfaces between scripts. An interface is simply a dictionary mapping names to functions. A script or mod can then register an interface with LuaRemote, after that any script can call the registered functions, provided it knows the interface name and the desired function name. An instance of LuaRemote is available through the global object named remote
.
Will register a remote interface containing two functions. Later, it will call these functions through remote
.
remote.add_interface("human interactor",
{hello = function() game.player.print("Hi!") end,
bye = function(name) game.player.print("Bye " .. name) end})
-- Some time later, possibly in a different mod...
remote.call("human interactor", "hello")
remote.call("human interactor", "bye", "dear reader")
Add a remote interface.
Removes an interface with the given name.
This object's name.
List of all registered interfaces.
Add a remote interface.
List of all registered interfaces.
This object's name.
Removes an interface with the given name.
object_name
:: string
[Read]
This object's name.
interfaces
:: dictionary[string → dictionary[string → boolean]]
[Read]
List of all registered interfaces. For each interface name, remote.interfaces[name]
is a dictionary mapping the interface's registered functions to the value true
.
Assuming the "human interactor" interface is registered as above
game.player.print(tostring(remote.interfaces["human interactor"]["hello"])) -- prints true
game.player.print(tostring(remote.interfaces["human interactor"]["nonexistent"])) -- prints nil