diff --git a/bricks/special/EventGate-input.lua b/bricks/special/EventGate-input.lua new file mode 100644 index 0000000..c9336b1 --- /dev/null +++ b/bricks/special/EventGate-input.lua @@ -0,0 +1,9 @@ +--[[ +2019-04-17 + Ideally the gate should ignore event set power if its input is connected to a wiregroup. + However I don't know how to do that right now so I'm going to leave it for later +]] + +return function(gate, argv) + gate.ports[2]:setstate(toboolean(argv[1])) +end diff --git a/bricks/special/EventGate.cs b/bricks/special/EventGate.cs index 0c26ffa..723f314 100644 --- a/bricks/special/EventGate.cs +++ b/bricks/special/EventGate.cs @@ -1,6 +1,7 @@ registerInputEvent("fxDTSBrick", "onPowerChange", "Self fxDTSBrick", 0); registerInputEvent("fxDTSBrick", "onPowerOn", "Self fxDTSBrick", 0); registerInputEvent("fxDTSBrick", "onPowerOff", "Self fxDTSBrick", 0); +registerOutputEvent("fxDTSBrick", "setPowerState", "bool 0"); function fxDTSBrick::onPowerChange(%this) { @@ -20,6 +21,12 @@ function fxDTSBrick::onPowerOff(%this) %this.processInputEvent("onPowerOff"); } +function fxDTSBrick::setPowerState(%this, %state, %client) +{ + if(%this.getDatablock().isLogicEventGate) + lualogic_sendinput(%this, 1, %state); +} + datablock fxDTSBrickData(LogicGate_EventGate_Data : brick1x1fData) { logicUpdate = "return function(gate) gate:cb(bool_to_int[gate.ports[1].state]) end"; @@ -36,7 +43,9 @@ datablock fxDTSBrickData(LogicGate_EventGate_Data : brick1x1fData) isLogic = true; isLogicGate = true; + isLogicEventGate = true; + logicInput = lualogic_readfile($LuaLogic::Path @ "bricks/special/EventGate-input.lua" ); logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/special/EventGate-update.lua"); numLogicPorts = 2;