altered callback functionality

This commit is contained in:
Redo 2019-04-16 19:33:24 -05:00
parent 43b4db151f
commit cf23667afd
6 changed files with 103 additions and 213 deletions

View File

@ -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) return function(gate)
gate.queueBits = {} gate.queueBits = {}
end end

View File

@ -17,6 +17,7 @@ datablock fxDTSBrickData(LogicGate_Keyboard_Data){
logicInit = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-init.lua" ); logicInit = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-init.lua" );
logicInput = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-input.lua" ); logicInput = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-input.lua" );
logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-update.lua"); logicUpdate = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-update.lua");
logicGlobal = lualogic_readfile($LuaLogic::Path @ "bricks/inputs/keyboard-global.lua");
numLogicPorts = 1; numLogicPorts = 1;

View File

@ -29,8 +29,6 @@ datablock fxDTSBrickData(LogicGate_TextBrick_Data){
}; };
lualogic_registergatedefinition("LogicGate_TextBrick_Data"); lualogic_registergatedefinition("LogicGate_TextBrick_Data");
function LogicGate_TextBrick_Data::LuaLogic_Callback(%data, %brick, %args){ function LogicGate_TextBrick_Data::LuaLogic_Callback(%data, %brick, %printname){
%printname = getField(%args, 0);
%brick.setPrint(lualogic_getprint(%printname)); %brick.setPrint(lualogic_getprint(%printname));
} }

View File

@ -8,6 +8,6 @@ return function(gate)
local printid = ((ticksOn-1) % #textbrick_idxToPrint) local printid = ((ticksOn-1) % #textbrick_idxToPrint)
local printname = textbrick_idxToPrint[printid] local printname = textbrick_idxToPrint[printid]
gate:cb("1\t" .. printname) gate:cb(printname)
end end
end end

View File

@ -69,6 +69,7 @@ function LuaLogicTCP::onLine(%this, %line)
if(isObject(%client)) if(isObject(%client))
{ {
%info = getField(%line, 2); %info = getField(%line, 2);
%info = lualogic_collapseescape(%info);
%info = strReplace(%info, "\\c0", "\c0"); %info = strReplace(%info, "\\c0", "\c0");
%info = strReplace(%info, "\\c2", "\c2"); %info = strReplace(%info, "\\c2", "\c2");
%info = strReplace(%info, "\\c5", "\c5"); %info = strReplace(%info, "\\c5", "\c5");

View File

@ -268,7 +268,7 @@ function lualogic_collapseescape(%str){
%ci = getSubStr(%str, %i, 1); %ci = getSubStr(%str, %i, 1);
%co = %ci; %co = %ci;
if(%ci=="\\" && %i<%len-1){ if(%ci$="\\" && %i<%len-1){
%i++; %i++;
%ci = getSubStr(%str, %i, 1); %ci = getSubStr(%str, %i, 1);
for(%j=0; %j<$LuaLogic::EscapeCount; %j++){ for(%j=0; %j<$LuaLogic::EscapeCount; %j++){