add robot prototype
This commit is contained in:
parent
8edbb986c7
commit
6b880ead45
@ -188,8 +188,9 @@ function LogicGate_RobotController_Data::LuaLogic_Callback(%this, %brick, %data)
|
|||||||
};
|
};
|
||||||
|
|
||||||
%err = %nbrick.plant();
|
%err = %nbrick.plant();
|
||||||
if(%err != 0 && %err != 2) {
|
if(%err != 0 && %err != 2 && %err != 3) {
|
||||||
%nbrick.delete();
|
%nbrick.delete();
|
||||||
|
talk(%err);
|
||||||
} else {
|
} else {
|
||||||
%nbrick.setRaycasting(getWord(%field, 4));
|
%nbrick.setRaycasting(getWord(%field, 4));
|
||||||
%nbrick.setColliding (getWord(%field, 5));
|
%nbrick.setColliding (getWord(%field, 5));
|
||||||
@ -236,8 +237,7 @@ function LogicRobot_CreateBrickGroup() {
|
|||||||
function LogicGate_RobotController_Data::createRobot(%this, %obj) {
|
function LogicGate_RobotController_Data::createRobot(%this, %obj) {
|
||||||
LogicRobot_CreateBrickGroup();
|
LogicRobot_CreateBrickGroup();
|
||||||
|
|
||||||
if(isObject(%obj.luaLogicRobot))
|
if(isObject(%obj.luaLogicRobot)) return;
|
||||||
%obj.luaLogicRobot.delete();
|
|
||||||
|
|
||||||
%pos = %obj.getPosition();
|
%pos = %obj.getPosition();
|
||||||
%rpos = vectorAdd(%pos, %this.getRelativeVector(%obj, "0.25 7.75 0"));
|
%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);
|
missionCleanup.add(%robot);
|
||||||
|
|
||||||
%obj.luaLogicRobot = %robot;
|
%obj.luaLogicRobot = %robot;
|
||||||
|
|
||||||
schedule(1000, 0, lualogic_sendinput, %obj, 1, "P" @ %rpos SPC %obj.getAngleId());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function LogicGate_RobotController_Data::Logic_onRemove(%this, %obj) {
|
function LogicGate_RobotController_Data::Logic_onRemove(%this, %obj) {
|
||||||
@ -262,3 +260,9 @@ function LogicGate_RobotController_Data::Logic_onPlant(%this, %obj) {
|
|||||||
if(!isObject(%obj.luaLogicRobot))
|
if(!isObject(%obj.luaLogicRobot))
|
||||||
%this.createRobot(%obj);
|
%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());
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user