Package pneumaticCraft.api.universalSensor

Examples of pneumaticCraft.api.universalSensor.ISensorSetting


    protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y){
        super.drawGuiContainerBackgroundLayer(opacity, x, y);

        nameFilterField.drawTextBox();

        ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(te.getSensorSetting());
        if(sensor != null) {
            sensor.drawAdditionalInfo(fontRendererObj);
        }
    }
View Full Code Here


            } else {
                buttonList.add(new GuiButton(buttonID, buttonX, buttonY, buttonWidth, buttonHeight, buttonText));
            }
        }
        sensorInfoStat.setText(getSensorInfo());
        ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(te.getSensorSetting());
        boolean textboxEnabled = sensor != null && sensor.needsTextBox();
        nameFilterField.setVisible(textboxEnabled);
        if(!textboxEnabled) nameFilterField.setFocused(false);

    }
View Full Code Here

        return upgradeInfo;
    }

    private List<String> getSensorInfo(){
        List<String> text = new ArrayList<String>();
        ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(te.getSensorSetting());
        if(sensor != null) {
            String[] folders = te.getSensorSetting().split("/");
            text.add(EnumChatFormatting.GRAY + folders[folders.length - 1]);
            text.addAll(sensor.getDescription());
        } else {
            text.add(EnumChatFormatting.BLACK + "No sensor selected.");
        }
        return text;
    }
View Full Code Here

            }
        }

        if(!worldObj.isRemote) {
            ticksExisted++;
            ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(sensorSetting);
            if(sensor != null && getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_UNIVERSAL_SENSOR) {
                if(!isSensorActive) {
                    isSensorActive = true;
                    sendDescriptionPacket();
                }
View Full Code Here

        int range = getRange();
        return AxisAlignedBB.getBoundingBox(xCoord - range, yCoord - range, zCoord - range, xCoord + 1 + range, yCoord + 1 + range, zCoord + 1 + range);
    }

    public void onEvent(Event event){
        ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(sensorSetting);
        if(sensor != null && sensor instanceof IEventSensorSetting && getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_UNIVERSAL_SENSOR) {
            int newRedstoneStrength = ((IEventSensorSetting)sensor).emitRedstoneOnEvent(event, this, getRange(), sensorGuiText);
            if(newRedstoneStrength != 0) eventTimer = ((IEventSensorSetting)sensor).getRedstonePulseLength();
            if(invertedRedstone) newRedstoneStrength = 15 - newRedstoneStrength;
            if(eventTimer > 0 && ThirdPartyManager.computerCraftLoaded) notifyComputers(newRedstoneStrength);
View Full Code Here

        luaMethods.add(new LuaMethod("setSensor"){
            @Override
            public Object[] call(IComputerAccess computer, ILuaContext context, Object[] args) throws LuaException, InterruptedException{
                if(args.length == 1) {
                    ISensorSetting sensor = null;
                    if(args[0] instanceof String) {
                        sensor = SensorHandler.instance().getSensorForName((String)args[0]);
                    } else {
                        sensor = SensorHandler.instance().getSensorByIndex(((Double)args[0]).intValue() - 1);
                    }
                    if(sensor != null) return new Object[]{setSensorSetting(sensor)};
                    throw new IllegalArgumentException("Invalid sensor name/index: " + args[0]);
                } else if(args.length == 0) {
                    setSensorSetting("");
                    return new Object[]{true};
                } else {
                    throw new IllegalArgumentException("setSensor needs one argument(a number as index, or a sensor name).");
                }
            }
        });

        luaMethods.add(new LuaMethod("getSensor"){
            @Override
            public Object[] call(IComputerAccess computer, ILuaContext context, Object[] args) throws LuaException, InterruptedException{
                if(args.length == 0) {
                    ISensorSetting curSensor = SensorHandler.instance().getSensorFromPath(getSensorSetting());
                    return curSensor == null ? null : new Object[]{getSensorSetting().substring(getSensorSetting().lastIndexOf('/') + 1)};
                } else {
                    throw new IllegalArgumentException("getSensor doesn't take any arguments!");
                }
            }
        });

        luaMethods.add(new LuaMethod("setTextfield"){
            @Override
            public Object[] call(IComputerAccess computer, ILuaContext context, Object[] args) throws LuaException, InterruptedException{
                if(args.length == 1) {
                    setText(0, (String)args[0]);
                    return null;
                } else {
                    throw new IllegalArgumentException("setTextfield takes one argument (string)");
                }
            }
        });

        luaMethods.add(new LuaMethod("getTextfield"){
            @Override
            public Object[] call(IComputerAccess computer, ILuaContext context, Object[] args) throws LuaException, InterruptedException{
                if(args.length == 0) {
                    return new Object[]{getText(0)};
                } else {
                    throw new IllegalArgumentException("getTextfield takes no arguments");
                }
            }
        });

        luaMethods.add(new LuaMethod("isSensorEventBased"){
            @Override
            public Object[] call(IComputerAccess computer, ILuaContext context, Object[] args) throws LuaException, InterruptedException{
                if(args.length == 0) {
                    return new Object[]{SensorHandler.instance().getSensorFromPath(getSensorSetting()) instanceof IEventSensorSetting};
                } else {
                    throw new IllegalArgumentException("isSensorEventBased takes no arguments");
                }
            }
        });

        luaMethods.add(new LuaMethod("getSensorValue"){
            @Override
            public Object[] call(IComputerAccess computer, ILuaContext context, Object[] args) throws LuaException, InterruptedException{
                if(args.length == 0) {
                    ISensorSetting s = SensorHandler.instance().getSensorFromPath(getSensorSetting());
                    if(s instanceof IPollSensorSetting) {
                        requestPollPullEvent = true;
                        return new Object[]{redstoneStrength};
                    } else if(s != null) {
                        throw new IllegalArgumentException("The selected sensor is pull event based. You can't poll the value.");
View Full Code Here

TOP

Related Classes of pneumaticCraft.api.universalSensor.ISensorSetting

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.