add cdata size and cfunc

This commit is contained in:
Redo 2022-11-05 12:59:40 -06:00
parent 949aeaa2c8
commit 57087d728f
8 changed files with 40 additions and 24 deletions

View File

@ -13,6 +13,7 @@ datablock fxDTSBrickData(LogicGate_NOT_Data : LogicGate_Diode_Data)
logicForcePrint = "ARROW";
logicUpdate = "return function(gate) Gate.setportstate(gate, 2, 1-Gate.getportstate(gate, 1)) end";
logicCFunction = 2;
numLogicPorts = 2;
};

View File

@ -17,6 +17,7 @@ datablock fxDTSBrickData(LogicGate_Diode_Data)
logicForcePrint = "ARROW";
logicUpdate = "return function(gate) Gate.setportstate(gate, 2, Gate.getportstate(gate, 1)) end";
logicCFunction = 1;
numLogicPorts = 2;

View File

@ -20,6 +20,7 @@ datablock fxDTSBrickData(LogicGate_DiodeUp_Data)
logicForcePrint = "UPARROW";
logicUpdate = "return function(gate) Gate.setportstate(gate, 2, Gate.getportstate(gate, 1)) end";
logicCFunction = 1;
numLogicPorts = 2;
@ -47,6 +48,7 @@ datablock fxDTSBrickData(LogicGate_DiodeDown_Data : LogicGate_DiodeUp_Data)
logicForcePrint = "DOWNARROW";
logicUpdate = "return function(gate) Gate.setportstate(gate, 2, Gate.getportstate(gate, 1)) end";
logicCFunction = 1;
logicPortDir[0] = 4;
logicPortDir[1] = 5;

View File

@ -13,6 +13,7 @@ datablock fxDTSBrickData(LogicGate_NotUp_Data : LogicGate_DiodeUp_Data)
logicForcePrint = "UPARROW";
logicUpdate = "return function(gate) Gate.setportstate(gate, 2, 1-Gate.getportstate(gate, 1)) end";
logicCFunction = 2;
};
lualogic_registergatedefinition("LogicGate_NotUp_Data");
@ -28,6 +29,7 @@ datablock fxDTSBrickData(LogicGate_NotDown_Data : LogicGate_DiodeDown_Data)
logicForcePrint = "DOWNARROW";
logicUpdate = "return function(gate) Gate.setportstate(gate, 2, 1-Gate.getportstate(gate, 1)) end";
logicCFunction = 2;
};
lualogic_registergatedefinition("LogicGate_NotDown_Data");

View File

@ -98,9 +98,9 @@ textbrick2_idxToPrint = {
[0x58] = "X",
[0x59] = "Y",
[0x5A] = "Z",
[0x5B] = "squarebracketright",
[0x5B] = "squarebracketleft",
[0x5C] = "slashleft",
[0x5D] = "squarebracketleft",
[0x5D] = "squarebracketright",
[0x5E] = "caret",
[0x5F] = "underscore",

View File

@ -180,26 +180,28 @@ function LogicGate_RobotController_Data::LuaLogic_Callback(%this, %brick, %data)
} else if(%first $= "P") { // plant brick
LogicRobot_CreateBrickGroup();
%nbrick = new fxDTSBrick() {
datablock = brick1x1fData;
position = %pos;
colorId = getWord(%field, 1);
colorFxId = getWord(%field, 2);
shapeFxId = getWord(%field, 3);
isPlanted = 1;
};
%nbrick.setTransform(%pos SPC "0 0 1 0");
%err = %nbrick.plant();
if(%err != 0 && %err != 2 && %err != 3) {
%nbrick.delete();
} else {
%nbrick.setRaycasting(getWord(%field, 4));
%nbrick.setColliding (getWord(%field, 5));
%nbrick.setRendering (getWord(%field, 6));
if(!isObject(%tbrick)) {
%nbrick = new fxDTSBrick() {
datablock = brick1x1fData;
position = %pos;
colorId = getWord(%field, 1);
colorFxId = getWord(%field, 2);
shapeFxId = getWord(%field, 3);
isPlanted = 1;
};
%nbrick.setTransform(%pos SPC "0 0 1 0");
BrickGroup_12345678.add(%nbrick);
%nbrick.setTrusted(1);
%err = %nbrick.plant();
if(%err != 0 && %err != 2 && %err != 3) {
%nbrick.delete();
} else {
%nbrick.setRaycasting(getWord(%field, 4));
%nbrick.setColliding (getWord(%field, 5));
%nbrick.setRendering (getWord(%field, 6));
BrickGroup_12345678.add(%nbrick);
%nbrick.setTrusted(1);
}
}
} else if(%first $= "M") { // move
%pos = getWords(%field, 1, 3);

View File

@ -27,6 +27,12 @@ package lualogic_rom_update {
parent::setRaycasting(%brick, %val);
lualogic_rom_updatebrick(%brick);
}
function fxDtsBrickData::Logic_onAdd(%data, %brick) {
parent::onAdd(%data, %brick);
if(%data.isLogicRom) {
schedule(5000, 0, lualogic_rom_updatedata, %brick);
}
}
};
schedule(0, 0, activatePackage, lualogic_rom_update);

View File

@ -27,11 +27,13 @@ function lualogic_registergatedefinition_auto(%data){
%def = %id @ ";" @
lualogic_expandescape(%data.logicUIName) @ ";" @
lualogic_expandescape(%data.logicUIDesc) @ ";" @
lualogic_expandescape(%data.logicInit) @ ";" @
lualogic_expandescape(%data.logicInit ) @ ";" @
lualogic_expandescape(%data.logicUpdate) @ ";" @
lualogic_expandescape(%data.logicInput) @ ";" @
lualogic_expandescape(%data.logicInput ) @ ";" @
lualogic_expandescape(%data.logicGlobal) @ ";" @
%numports
%numports @ ";" @
(%data.logicCFunction || 0) @ ";" @
(%data.logicCDataSize || 0)
;
for(%i = 0; %i < %numports; %i++)