Package dan200.computercraft.api.lua
Interface IDynamicLuaObject
public interface IDynamicLuaObject
An interface for representing custom objects returned by peripherals or other Lua objects.
Generally, one does not need to implement this type - it is sufficient to return an object with some methods
annotated with LuaFunction
. IDynamicLuaObject
is useful when you wish your available methods to
change at runtime.
-
Method Summary
Modifier and TypeMethodDescriptioncallMethod
(ILuaContext context, int method, IArguments arguments) Called when a user calls one of the methods that this object implements.String[]
Get the names of the methods that this object implements.
-
Method Details
-
getMethodNames
String[] getMethodNames()Get the names of the methods that this object implements. This should not change over the course of the object's lifetime.- Returns:
- The method names this object provides.
- See Also:
-
callMethod
Called when a user calls one of the methods that this object implements.- Parameters:
context
- The context of the currently running lua thread. This can be used to wait for events or otherwise yield.method
- An integer identifying which method index fromgetMethodNames()
the computer wishes to call.arguments
- The arguments for this method.- Returns:
- The result of this function. Either an immediate value (
MethodResult.of(Object...)
or an instruction to yield. - Throws:
LuaException
- If the function threw an exception.
-