add robot prototype

This commit is contained in:
Redo 2022-10-28 16:34:56 -06:00
parent 8edbb986c7
commit 6b880ead45

View File

@ -188,8 +188,9 @@ function LogicGate_RobotController_Data::LuaLogic_Callback(%this, %brick, %data)
};
%err = %nbrick.plant();
if(%err != 0 && %err != 2) {
if(%err != 0 && %err != 2 && %err != 3) {
%nbrick.delete();
talk(%err);
} else {
%nbrick.setRaycasting(getWord(%field, 4));
%nbrick.setColliding (getWord(%field, 5));
@ -236,8 +237,7 @@ function LogicRobot_CreateBrickGroup() {
function LogicGate_RobotController_Data::createRobot(%this, %obj) {
LogicRobot_CreateBrickGroup();
if(isObject(%obj.luaLogicRobot))
%obj.luaLogicRobot.delete();
if(isObject(%obj.luaLogicRobot)) return;
%pos = %obj.getPosition();
%rpos = vectorAdd(%pos, %this.getRelativeVector(%obj, "0.25 7.75 0"));
@ -249,8 +249,6 @@ function LogicGate_RobotController_Data::createRobot(%this, %obj) {
missionCleanup.add(%robot);
%obj.luaLogicRobot = %robot;
schedule(1000, 0, lualogic_sendinput, %obj, 1, "P" @ %rpos SPC %obj.getAngleId());
}
function LogicGate_RobotController_Data::Logic_onRemove(%this, %obj) {
@ -262,3 +260,9 @@ function LogicGate_RobotController_Data::Logic_onPlant(%this, %obj) {
if(!isObject(%obj.luaLogicRobot))
%this.createRobot(%obj);
}
function LogicGate_RobotController_Data::Logic_onAdd(%this, %obj) {
if(!isObject(%obj.luaLogicRobot)) %this.createRobot(%obj);
lualogic_sendinput(%obj, 1, "P" @ %obj.luaLogicRobot.getPosition() SPC %obj.getAngleId());
}