Added EventGate
Added EventGate which is designed for logic signals to interface with events
This commit is contained in:
parent
b0c376bd37
commit
500eff70a9
4
bricks/special/EventGate-update.lua
Normal file
4
bricks/special/EventGate-update.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
return function(gate)
|
||||||
|
gate.ports[2]:setstate(gate.ports[1].state)
|
||||||
|
gate:cb(bool_to_int[gate.ports[1].state])
|
||||||
|
end
|
67
bricks/special/EventGate.cs
Normal file
67
bricks/special/EventGate.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
registerInputEvent("fxDTSBrick", "onPowerChange", "Self fxDTSBrick", 0);
|
||||||
|
registerInputEvent("fxDTSBrick", "onPowerOn", "Self fxDTSBrick", 0);
|
||||||
|
registerInputEvent("fxDTSBrick", "onPowerOff", "Self fxDTSBrick", 0);
|
||||||
|
|
||||||
|
function fxDTSBrick::onPowerChange(%this)
|
||||||
|
{
|
||||||
|
$InputTarget_["Self"] = %this;
|
||||||
|
%this.processInputEvent("onPowerChange");
|
||||||
|
}
|
||||||
|
|
||||||
|
function fxDTSBrick::onPowerOn(%this)
|
||||||
|
{
|
||||||
|
$InputTarget_["Self"] = %this;
|
||||||
|
%this.processInputEvent("onPowerOn");
|
||||||
|
}
|
||||||
|
|
||||||
|
function fxDTSBrick::onPowerOff(%this)
|
||||||
|
{
|
||||||
|
$InputTarget_["Self"] = %this;
|
||||||
|
%this.processInputEvent("onPowerOff");
|
||||||
|
}
|
||||||
|
|
||||||
|
datablock fxDTSBrickData(LogicGate_EventGate_Data : brick1x1fData)
|
||||||
|
{
|
||||||
|
logicUpdate = "return function(gate) gate:cb(bool_to_int[gate.ports[1].state]) end";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
category = "Logic Bricks";
|
||||||
|
subCategory = "Wires - Special";
|
||||||
|
uiName = "Event Gate";
|
||||||
|
iconName = $LuaLogic::Path @ "icons/EventGate";
|
||||||
|
brickFile = $LuaLogic::Path @ "bricks/blb/1x1f_1i_1o.blb";
|
||||||
|
hasPrint = 1;
|
||||||
|
printAspectRatio = "Logic";
|
||||||
|
|
||||||
|
isLogic = true;
|
||||||
|
isLogicGate = true;
|
||||||
|
|
||||||
|
logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/special/EventGate-update.lua");
|
||||||
|
|
||||||
|
numLogicPorts = 2;
|
||||||
|
|
||||||
|
logicPortType[0] = 1;
|
||||||
|
logicPortPos[0] = "0 0 0";
|
||||||
|
logicPortDir[0] = "0";
|
||||||
|
logicPortCauseUpdate[0] = true;
|
||||||
|
logicPortUIName[0] = "Input";
|
||||||
|
logicPortUIDesc[0] = "";
|
||||||
|
|
||||||
|
logicPortType[1] = 0;
|
||||||
|
logicPortPos[1] = "0 0 0";
|
||||||
|
logicPortDir[1] = "2";
|
||||||
|
logicPortUIName[1] = "Output";
|
||||||
|
logicPortUIDesc[1] = "";
|
||||||
|
};
|
||||||
|
lualogic_registergatedefinition("LogicGate_EventGate_Data");
|
||||||
|
|
||||||
|
function LogicGate_EventGate_Data::LuaLogic_Callback(%this, %obj, %data)
|
||||||
|
{
|
||||||
|
%obj.onPowerChange();
|
||||||
|
if(%data)
|
||||||
|
%obj.onPowerOn();
|
||||||
|
else
|
||||||
|
%obj.onPowerOff();
|
||||||
|
}
|
||||||
|
|
BIN
icons/EventGate.png
Normal file
BIN
icons/EventGate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -40,3 +40,6 @@ exec($LuaLogic::Path @ "bricks/bus/8BitDFlipFlop.cs");
|
|||||||
//Memory
|
//Memory
|
||||||
exec($LuaLogic::Path @ "bricks/memory/DFlipFlop.cs");
|
exec($LuaLogic::Path @ "bricks/memory/DFlipFlop.cs");
|
||||||
exec($LuaLogic::Path @ "bricks/memory/DFlipflopGridMemory2.cs");
|
exec($LuaLogic::Path @ "bricks/memory/DFlipflopGridMemory2.cs");
|
||||||
|
|
||||||
|
//Special
|
||||||
|
exec($LuaLogic::Path @ "bricks/special/EventGate.cs");
|
Loading…
x
Reference in New Issue
Block a user