Added EventGate
Added EventGate which is designed for logic signals to interface with events
This commit is contained in:
		
							
								
								
									
										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(); | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user