From 6b880ead45d24b66de4cc113722b09ce3f21244a Mon Sep 17 00:00:00 2001 From: Redo Date: Fri, 28 Oct 2022 16:34:56 -0600 Subject: [PATCH] add robot prototype --- bricks/special/robot.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bricks/special/robot.cs b/bricks/special/robot.cs index fd81135..a59e1bc 100644 --- a/bricks/special/robot.cs +++ b/bricks/special/robot.cs @@ -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()); +}