altered callback functionality
This commit is contained in:
		| @@ -1,114 +1,4 @@ | ||||
|  | ||||
| keyboard_strToBool = keyboard_strToBool or { | ||||
| 	["0"] = false, | ||||
| 	["1"] = true, | ||||
| } | ||||
|  | ||||
| --Key codes may use only 7 bits, so values must be in range 00-7F | ||||
|  | ||||
| keyboard_keyToCode = keyboard_keyToCode or { | ||||
| 	["backspace"]     = 0x01, | ||||
| 	["tab"]           = 0x02, | ||||
| 	["return"]        = 0x03, | ||||
| 	["space"]         = 0x04, | ||||
| 	["end"]           = 0x05, | ||||
| 	["home"]          = 0x06, | ||||
| 	["left"]          = 0x07, | ||||
| 	["up"]            = 0x08, | ||||
| 	["right"]         = 0x09, | ||||
| 	["down"]          = 0x0A, | ||||
| 	["insert"]        = 0x0B, | ||||
| 	["delete"]        = 0x0C, | ||||
| 	 | ||||
| 	["0"]             = 0x10, | ||||
| 	["1"]             = 0x11, | ||||
| 	["2"]             = 0x12, | ||||
| 	["3"]             = 0x13, | ||||
| 	["4"]             = 0x14, | ||||
| 	["5"]             = 0x15, | ||||
| 	["6"]             = 0x16, | ||||
| 	["7"]             = 0x17, | ||||
| 	["8"]             = 0x18, | ||||
| 	["9"]             = 0x19, | ||||
| 	 | ||||
| 	["a"]             = 0x1A, | ||||
| 	["b"]             = 0x1B, | ||||
| 	["c"]             = 0x1C, | ||||
| 	["d"]             = 0x1D, | ||||
| 	["e"]             = 0x1E, | ||||
| 	["f"]             = 0x1F, | ||||
| 	["g"]             = 0x20, | ||||
| 	["h"]             = 0x21, | ||||
| 	["i"]             = 0x22, | ||||
| 	["j"]             = 0x23, | ||||
| 	["k"]             = 0x24, | ||||
| 	["l"]             = 0x25, | ||||
| 	["m"]             = 0x26, | ||||
| 	["n"]             = 0x27, | ||||
| 	["o"]             = 0x28, | ||||
| 	["p"]             = 0x29, | ||||
| 	["q"]             = 0x2A, | ||||
| 	["r"]             = 0x2B, | ||||
| 	["s"]             = 0x2C, | ||||
| 	["t"]             = 0x2D, | ||||
| 	["u"]             = 0x2E, | ||||
| 	["v"]             = 0x2F, | ||||
| 	["w"]             = 0x30, | ||||
| 	["x"]             = 0x31, | ||||
| 	["y"]             = 0x32, | ||||
| 	["z"]             = 0x33, | ||||
| 	 | ||||
| 	["numpad0"]       = 0x40, | ||||
| 	["numpad1"]       = 0x41, | ||||
| 	["numpad2"]       = 0x42, | ||||
| 	["numpad3"]       = 0x43, | ||||
| 	["numpad4"]       = 0x44, | ||||
| 	["numpad5"]       = 0x45, | ||||
| 	["numpad6"]       = 0x46, | ||||
| 	["numpad7"]       = 0x47, | ||||
| 	["numpad8"]       = 0x48, | ||||
| 	["numpad9"]       = 0x49, | ||||
| 	["*"]             = 0x4A, | ||||
| 	["+"]             = 0x4B, | ||||
| 	["numpadenter"]   = 0x4C, | ||||
| 	["minus"]         = 0x4D, | ||||
| 	["numpaddecimal"] = 0x4E, | ||||
| 	["/"]             = 0x4F, | ||||
| 	 | ||||
| 	["f1"]            = 0x51, | ||||
| 	["f2"]            = 0x52, | ||||
| 	["f3"]            = 0x53, | ||||
| 	["f4"]            = 0x54, | ||||
| 	["f5"]            = 0x55, | ||||
| 	["f6"]            = 0x56, | ||||
| 	["f7"]            = 0x57, | ||||
| 	["f8"]            = 0x58, | ||||
| 	["f9"]            = 0x59, | ||||
| 	["f10"]           = 0x5A, | ||||
| 	["f11"]           = 0x5B, | ||||
| 	["f12"]           = 0x5C, | ||||
| 	 | ||||
| 	["lshift"]        = 0x60, | ||||
| 	["rshift"]        = 0x61, | ||||
| 	["lcontrol"]      = 0x62, | ||||
| 	["rcontrol"]      = 0x63, | ||||
| 	["lalt"]          = 0x64, | ||||
| 	["ralt"]          = 0x65, | ||||
| 	 | ||||
| 	[";"]             = 0x70, | ||||
| 	[","]             = 0x71, | ||||
| 	["."]             = 0x72, | ||||
| 	["/"]             = 0x73, | ||||
| 	["`"]             = 0x74, | ||||
| 	["["]             = 0x75, | ||||
| 	["\\"]            = 0x76, | ||||
| 	["]"]             = 0x77, | ||||
| 	[" ="]            = 0x78, | ||||
| 	["apostrophe"]    = 0x79, | ||||
| 	 | ||||
| 	["invalid"]       = 0x7F, | ||||
| } | ||||
|  | ||||
| return function(gate) | ||||
| 	gate.queueBits = {} | ||||
| end | ||||
|  | ||||
| return function(gate) | ||||
| 	gate.queueBits = {} | ||||
| end | ||||
|   | ||||
| @@ -1,49 +1,50 @@ | ||||
|  | ||||
| datablock fxDTSBrickData(LogicGate_Keyboard_Data){ | ||||
| 	brickFile = $LuaLogic::Path @ "bricks/blb/keyboardgate.blb"; | ||||
| 	category = "Logic Bricks"; | ||||
| 	subCategory = "Inputs"; | ||||
| 	uiName = "Input Keyboard"; | ||||
| 	iconName = $LuaLogic::Path @ "icons/Input Keyboard"; | ||||
| 	orientationFix = 3; | ||||
| 	 | ||||
| 	isLogic = true; | ||||
| 	isLogicGate = true; | ||||
| 	isLogicInput = true; | ||||
| 	 | ||||
| 	logicUIName = "Input Keyboard"; | ||||
| 	logicUIDesc = ""; | ||||
| 	 | ||||
| 	logicInit   = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-init.lua"  ); | ||||
| 	logicInput  = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-input.lua" ); | ||||
| 	logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-update.lua"); | ||||
| 	 | ||||
| 	numLogicPorts = 1; | ||||
| 	 | ||||
| 	logicPortType[0] = 0; | ||||
| 	logicPortPos[0] = "2 0 0"; | ||||
| 	logicPortDir[0] = 1; | ||||
| 	logicPortUIName[0] = "R"; | ||||
|  | ||||
| }; | ||||
| lualogic_registergatedefinition("LogicGate_Keyboard_Data"); | ||||
|  | ||||
| function LogicGate_Keyboard_Data::LuaLogic_PressKey(%data, %brick, %key, %state){ | ||||
| 	%key = strReplace(%key, ";", "\\:"); | ||||
| 	lualogic_sendInput(%brick, 2, %key, %state); | ||||
| } | ||||
|  | ||||
| function serverCmdLInputKey(%client, %key, %state){ | ||||
| 	%brick = %client.Logic_InputKeyboard; | ||||
| 	if(isObject(%brick) && %client.Logic_InputActive){ | ||||
| 		%brick.getDatablock().LuaLogic_PressKey(%brick, %key, %state); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| function LogicGate_Keyboard_Data::Logic_OnInput(%data, %brick, %pos, %norm, %client){ | ||||
| 	if(isObject(%client)){ | ||||
| 		%client.Logic_InputKeyboard = %brick; | ||||
| 		%client.Logic_InputActive = true; | ||||
| 		commandToClient(%client, 'LStartInput'); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| datablock fxDTSBrickData(LogicGate_Keyboard_Data){ | ||||
| 	brickFile = $LuaLogic::Path @ "bricks/blb/keyboardgate.blb"; | ||||
| 	category = "Logic Bricks"; | ||||
| 	subCategory = "Inputs"; | ||||
| 	uiName = "Input Keyboard"; | ||||
| 	iconName = $LuaLogic::Path @ "icons/Input Keyboard"; | ||||
| 	orientationFix = 3; | ||||
| 	 | ||||
| 	isLogic = true; | ||||
| 	isLogicGate = true; | ||||
| 	isLogicInput = true; | ||||
| 	 | ||||
| 	logicUIName = "Input Keyboard"; | ||||
| 	logicUIDesc = ""; | ||||
| 	 | ||||
| 	logicInit   = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-init.lua"  ); | ||||
| 	logicInput  = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-input.lua" ); | ||||
| 	logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-update.lua"); | ||||
| 	logicGlobal = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-global.lua"); | ||||
| 	 | ||||
| 	numLogicPorts = 1; | ||||
| 	 | ||||
| 	logicPortType[0] = 0; | ||||
| 	logicPortPos[0] = "2 0 0"; | ||||
| 	logicPortDir[0] = 1; | ||||
| 	logicPortUIName[0] = "R"; | ||||
|  | ||||
| }; | ||||
| lualogic_registergatedefinition("LogicGate_Keyboard_Data"); | ||||
|  | ||||
| function LogicGate_Keyboard_Data::LuaLogic_PressKey(%data, %brick, %key, %state){ | ||||
| 	%key = strReplace(%key, ";", "\\:"); | ||||
| 	lualogic_sendInput(%brick, 2, %key, %state); | ||||
| } | ||||
|  | ||||
| function serverCmdLInputKey(%client, %key, %state){ | ||||
| 	%brick = %client.Logic_InputKeyboard; | ||||
| 	if(isObject(%brick) && %client.Logic_InputActive){ | ||||
| 		%brick.getDatablock().LuaLogic_PressKey(%brick, %key, %state); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| function LogicGate_Keyboard_Data::Logic_OnInput(%data, %brick, %pos, %norm, %client){ | ||||
| 	if(isObject(%client)){ | ||||
| 		%client.Logic_InputKeyboard = %brick; | ||||
| 		%client.Logic_InputActive = true; | ||||
| 		commandToClient(%client, 'LStartInput'); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,36 +1,34 @@ | ||||
|  | ||||
| datablock fxDTSBrickData(LogicGate_TextBrick_Data){ | ||||
| 	brickFile = $LuaLogic::Path @ "bricks/blb/TextBrick.blb"; | ||||
| 	category = "Logic Bricks"; | ||||
| 	subCategory = "Outputs"; | ||||
| 	uiName = "Text Brick"; | ||||
| 	iconName = $LuaLogic::Path @ "icons/Text Brick"; | ||||
| 	hasPrint = 1; | ||||
| 	printAspectRatio = "Logic"; | ||||
| 	orientationFix = 3; | ||||
|  | ||||
| 	isLogic = true; | ||||
| 	isLogicGate = true; | ||||
| 	isLogicInput = false; | ||||
|  | ||||
| 	logicUIName = "Text Brick"; | ||||
| 	logicUIDesc = "Resets on rise, increments based on pulse length"; | ||||
| 	 | ||||
| 	logicInit   = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text-init.lua"  ); | ||||
| 	logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text-update.lua"); | ||||
|  | ||||
| 	numLogicPorts = 1; | ||||
|  | ||||
| 	logicPortType[0] = 1; | ||||
| 	logicPortPos[0] = "0 0 -1"; | ||||
| 	logicPortDir[0] = 3; | ||||
| 	logicPortCauseUpdate[0] = true; | ||||
| 	logicPortUIName[0] = "Inc"; | ||||
| }; | ||||
| lualogic_registergatedefinition("LogicGate_TextBrick_Data"); | ||||
|  | ||||
| function LogicGate_TextBrick_Data::LuaLogic_Callback(%data, %brick, %args){ | ||||
| 	%printname = getField(%args, 0); | ||||
| 	 | ||||
| 	%brick.setPrint(lualogic_getprint(%printname)); | ||||
| } | ||||
|  | ||||
| datablock fxDTSBrickData(LogicGate_TextBrick_Data){ | ||||
| 	brickFile = $LuaLogic::Path @ "bricks/blb/TextBrick.blb"; | ||||
| 	category = "Logic Bricks"; | ||||
| 	subCategory = "Outputs"; | ||||
| 	uiName = "Text Brick"; | ||||
| 	iconName = $LuaLogic::Path @ "icons/Text Brick"; | ||||
| 	hasPrint = 1; | ||||
| 	printAspectRatio = "Logic"; | ||||
| 	orientationFix = 3; | ||||
|  | ||||
| 	isLogic = true; | ||||
| 	isLogicGate = true; | ||||
| 	isLogicInput = false; | ||||
|  | ||||
| 	logicUIName = "Text Brick"; | ||||
| 	logicUIDesc = "Resets on rise, increments based on pulse length"; | ||||
| 	 | ||||
| 	logicInit   = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text-init.lua"  ); | ||||
| 	logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/outputs/text-update.lua"); | ||||
|  | ||||
| 	numLogicPorts = 1; | ||||
|  | ||||
| 	logicPortType[0] = 1; | ||||
| 	logicPortPos[0] = "0 0 -1"; | ||||
| 	logicPortDir[0] = 3; | ||||
| 	logicPortCauseUpdate[0] = true; | ||||
| 	logicPortUIName[0] = "Inc"; | ||||
| }; | ||||
| lualogic_registergatedefinition("LogicGate_TextBrick_Data"); | ||||
|  | ||||
| function LogicGate_TextBrick_Data::LuaLogic_Callback(%data, %brick, %printname){ | ||||
| 	%brick.setPrint(lualogic_getprint(%printname)); | ||||
| } | ||||
|   | ||||
| @@ -1,13 +1,13 @@ | ||||
|  | ||||
| return function(gate) | ||||
| 	if gate.ports[1]:isrising() then | ||||
| 		gate.tickStarted = gate:gettick() | ||||
| 	elseif gate.ports[1]:isfalling() then | ||||
| 		local ticksOn = gate:gettick() - gate.tickStarted | ||||
| 		 | ||||
| 		local printid = ((ticksOn-1) % #textbrick_idxToPrint) | ||||
| 		local printname = textbrick_idxToPrint[printid] | ||||
| 		 | ||||
| 		gate:cb("1\t" .. printname) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| return function(gate) | ||||
| 	if gate.ports[1]:isrising() then | ||||
| 		gate.tickStarted = gate:gettick() | ||||
| 	elseif gate.ports[1]:isfalling() then | ||||
| 		local ticksOn = gate:gettick() - gate.tickStarted | ||||
| 		 | ||||
| 		local printid = ((ticksOn-1) % #textbrick_idxToPrint) | ||||
| 		local printname = textbrick_idxToPrint[printid] | ||||
| 		 | ||||
| 		gate:cb(printname) | ||||
| 	end | ||||
| end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Redo
					Redo