use of me.desht.pneumaticcraft.common.thirdparty.computercraft.LuaMethod in project pnc-repressurized by TeamPneumatic.
the class TileEntityElevatorBase method addLuaMethods.
@Override
protected void addLuaMethods() {
super.addLuaMethods();
luaMethods.add(new LuaConstant("getMinWorkingPressure", PneumaticValues.MIN_PRESSURE_ELEVATOR));
luaMethods.add(new LuaMethod("setHeight") {
@Override
public Object[] call(Object[] args) throws Exception {
if (args.length == 1) {
setTargetHeight(((Double) args[0]).floatValue());
if (getCoreElevator().isControlledByRedstone())
getCoreElevator().handleGUIButtonPress(0, null);
getCoreElevator().sendDescPacketFromAllElevators();
return null;
} else {
throw new IllegalArgumentException("setHeight does take one argument (height)");
}
}
});
luaMethods.add(new LuaMethod("getCurrentHeight") {
@Override
public Object[] call(Object[] args) throws Exception {
if (args.length == 0) {
return new Object[] { getCoreElevator().extension };
} else {
throw new IllegalArgumentException("getCurrentHeight method takes no arguments!");
}
}
});
luaMethods.add(new LuaMethod("getTargetHeight") {
@Override
public Object[] call(Object[] args) throws Exception {
if (args.length == 0) {
return new Object[] { getCoreElevator().targetExtension };
} else {
throw new IllegalArgumentException("getTargetHeight method takes no arguments!");
}
}
});
luaMethods.add(new LuaMethod("setExternalControl") {
@Override
public Object[] call(Object[] args) throws Exception {
if (args.length == 1) {
if ((Boolean) args[0] && getCoreElevator().isControlledByRedstone() || !(Boolean) args[0] && !getCoreElevator().isControlledByRedstone()) {
getCoreElevator().handleGUIButtonPress(0, null);
}
return null;
} else {
throw new IllegalArgumentException("setExternalControl does take one argument! (bool)");
}
}
});
}
Aggregations