ComputerCraftFan11, on 01 April 2012 - 08:57 PM, said:
How can I make a function or something to make the peripheral do something?
See the TileEntityName.class example? In the getMethodNames() function it has an array of strings, the example has a single function "test". Say you wanted some functions for changing the block color, in that array you could create the functions setColorRed(), setColorGreen() like this:
public String[] getMethodNames()
{
return (new String[] { "setColorRed", "setColorGreen" });
}
Then in the call method function you can respond to them:
public Object[] callMethod(IComputerAccess icomputeraccess, int i, Object aobj[])
throws Exception
{
if (i == 0)
{
// Do logic for the setColorRed() function
} else if (i == 1) {
// Do logic for the setColorGreen() function
}
return null;
}
I believe "i" is the index of the function name in the array.
Note:You do all the peripheral programming in Java, not LUA.