Code: Select all
if remote.interfaces["iface"] and remote.interfaces["iface"]["ifunc"] then
local ret = remote.call("iface", "ifunc", myargs)
dostuff(ret)
end
(Alternatively, that code can be rewritten so that `remote.interfaces` is only called once, but still, my point remains)
The problem: This is a relatively slow process to create this dictionary of dictionaries into Lua.
These values cannot be cached as remote interfaces can be added and removed at any time. (Alternatively we can use `xpcall` on `remote.call` without checking a functions existence, but that becomes a huge pain to handle for something that should be simple.)
It seems it would be simple for the engine to trigger events `on_remote_interface_added` and `on_remote_interface_removed` as appropriate. Included in the `event` data would be the name of the interface added or removed. The actual function names included in the interface can then be retrieved with `remote.interfaces[event.interface]` and kept in a cache. Then when I need to do a remote.call I simply check my cache for the functions existence and call it.