Search in sources :

Example 6 with IHeatExchangerLogic

use of me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic in project pnc-repressurized by TeamPneumatic.

the class TileEntityBase method addLuaMethods.

protected void addLuaMethods() {
    if (this instanceof IHeatExchanger) {
        final IHeatExchanger exchanger = (IHeatExchanger) this;
        luaMethods.add(new LuaMethod("getTemperature") {

            @Override
            public Object[] call(Object[] args) throws Exception {
                if (args.length == 0) {
                    return new Object[] { exchanger.getHeatExchangerLogic(null).getTemperature() };
                } else if (args.length == 1) {
                    IHeatExchangerLogic logic = exchanger.getHeatExchangerLogic(getDirForString((String) args[0]));
                    return new Object[] { logic != null ? logic.getTemperature() : 0 };
                } else {
                    throw new IllegalArgumentException("getTemperature method requires 0 or 1 argument (direction: up, down, east, west, north, south!");
                }
            }
        });
    }
}
Also used : IHeatExchanger(me.desht.pneumaticcraft.api.tileentity.IHeatExchanger) LuaMethod(me.desht.pneumaticcraft.common.thirdparty.computercraft.LuaMethod) ILuaMethod(me.desht.pneumaticcraft.common.thirdparty.computercraft.ILuaMethod) TextComponentString(net.minecraft.util.text.TextComponentString) LuaException(dan200.computercraft.api.lua.LuaException) IHeatExchangerLogic(me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)

Aggregations

IHeatExchangerLogic (me.desht.pneumaticcraft.api.heat.IHeatExchangerLogic)6 IHeatExchanger (me.desht.pneumaticcraft.api.tileentity.IHeatExchanger)3 EnumFacing (net.minecraft.util.EnumFacing)3 HeatBehaviour (me.desht.pneumaticcraft.api.heat.HeatBehaviour)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TileEntity (net.minecraft.tileentity.TileEntity)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 LuaException (dan200.computercraft.api.lua.LuaException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Nonnull (javax.annotation.Nonnull)1 IPressurizable (me.desht.pneumaticcraft.api.item.IPressurizable)1 IManoMeasurable (me.desht.pneumaticcraft.api.tileentity.IManoMeasurable)1 IPneumaticMachine (me.desht.pneumaticcraft.api.tileentity.IPneumaticMachine)1 ILuaMethod (me.desht.pneumaticcraft.common.thirdparty.computercraft.ILuaMethod)1 LuaMethod (me.desht.pneumaticcraft.common.thirdparty.computercraft.LuaMethod)1 TileEntityHeatSink (me.desht.pneumaticcraft.common.tileentity.TileEntityHeatSink)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagList (net.minecraft.nbt.NBTTagList)1