add robot prototype
This commit is contained in:
		| @@ -160,24 +160,26 @@ function LogicGate_RobotController_Data::LuaLogic_Callback(%this, %brick, %data) | |||||||
| 		%field = getField(%data, %i); | 		%field = getField(%data, %i); | ||||||
| 		%first = getWord(%field, 0); | 		%first = getWord(%field, 0); | ||||||
| 		 | 		 | ||||||
| 		if(%first $= "R" || %first $= "D") { // remove / detect brick | 		if(%first $= "D") { // remove / detect brick | ||||||
| 			if(isObject(%tbrick)) { | 			if(isObject(%tbrick)) { | ||||||
| 				if(%first $= "D") { | 				%field = "B" @ 1 SPC | ||||||
| 					%field = "B" @ 1 SPC | 					%tbrick.getColorId() SPC | ||||||
| 						%tbrick.getColorId() SPC | 					%tbrick.getColorFxID() SPC | ||||||
| 						%tbrick.getColorFxID() SPC | 					%tbrick.getShapeFxId() SPC | ||||||
| 						%tbrick.getShapeFxId() SPC | 					%tbrick.isRaycasting() SPC | ||||||
| 						%tbrick.isRaycasting() SPC | 					%tbrick.isColliding() SPC | ||||||
| 						%tbrick.isColliding() SPC | 					%tbrick.isRendering(); | ||||||
| 						%tbrick.isRendering(); | 				%output = %output @ %field @ "\t"; | ||||||
| 					%output = %output @ %field @ "\t"; |  | ||||||
| 				} else if(%first $= "R") { |  | ||||||
| 					%tbrick.schedule(0, delete); |  | ||||||
| 				} |  | ||||||
| 			} else { | 			} else { | ||||||
| 				%output = %output @ "B 0 0 0 0 0 0 0\t"; | 				%output = %output @ "B 0 0 0 0 0 0 0\t"; | ||||||
| 			} | 			} | ||||||
|  | 		} else if(%first $= "R") { | ||||||
|  | 			if(isObject(%tbrick)) { | ||||||
|  | 				%tbrick.schedule(0, delete); | ||||||
|  | 			} | ||||||
| 		} else if(%first $= "P") { // plant brick | 		} else if(%first $= "P") { // plant brick | ||||||
|  | 			LogicRobot_CreateBrickGroup(); | ||||||
|  | 			 | ||||||
| 			%nbrick = new fxDTSBrick() { | 			%nbrick = new fxDTSBrick() { | ||||||
| 				datablock = brick1x1fData; | 				datablock = brick1x1fData; | ||||||
| 				position = %pos; | 				position = %pos; | ||||||
| @@ -186,17 +188,17 @@ function LogicGate_RobotController_Data::LuaLogic_Callback(%this, %brick, %data) | |||||||
| 				shapeFxId = getWord(%field, 3); | 				shapeFxId = getWord(%field, 3); | ||||||
| 				isPlanted = 1; | 				isPlanted = 1; | ||||||
| 			}; | 			}; | ||||||
|  | 			%nbrick.setTransform(%pos SPC "0 0 1 0"); | ||||||
| 			 | 			 | ||||||
| 			%err = %nbrick.plant(); | 			%err = %nbrick.plant(); | ||||||
| 			if(%err != 0 && %err != 2 && %err != 3) { | 			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)); | ||||||
| 				%nbrick.setRendering (getWord(%field, 6)); | 				%nbrick.setRendering (getWord(%field, 6)); | ||||||
| 				 | 				 | ||||||
| 				LuaLogic_RobotBrickGroup.add(%nbrick); | 				BrickGroup_12345678.add(%nbrick); | ||||||
| 				%nbrick.setTrusted(1); | 				%nbrick.setTrusted(1); | ||||||
| 			} | 			} | ||||||
| 		} else if(%first $= "M") { // move | 		} else if(%first $= "M") { // move | ||||||
| @@ -224,19 +226,17 @@ function LogicGate_RobotController_Data::getRelativeVector(%this, %obj, %vec) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function LogicRobot_CreateBrickGroup() { | function LogicRobot_CreateBrickGroup() { | ||||||
| 	if(!isObject(LuaLogic_RobotBrickGroup)) { | 	if(!isObject(BrickGroup_12345678)) { | ||||||
| 		new SimGroup(LuaLogic_RobotBrickGroup) { | 		new SimGroup(BrickGroup_12345678) { | ||||||
| 			bl_id = 12345678; | 			bl_id = 12345678; | ||||||
| 			name = "\c1Robot"; | 			name = "\c1Robot"; | ||||||
| 			QuotaObject = GlobalQuota; | 			QuotaObject = GlobalQuota; | ||||||
| 		}; | 		}; | ||||||
| 		mainBrickGroup.add(LuaLogic_RobotBrickGroup); | 		mainBrickGroup.add(BrickGroup_12345678); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| function LogicGate_RobotController_Data::createRobot(%this, %obj) { | function LogicGate_RobotController_Data::createRobot(%this, %obj) { | ||||||
| 	LogicRobot_CreateBrickGroup(); |  | ||||||
| 	 |  | ||||||
| 	if(isObject(%obj.luaLogicRobot)) return; | 	if(isObject(%obj.luaLogicRobot)) return; | ||||||
| 	 | 	 | ||||||
| 	%pos = %obj.getPosition(); | 	%pos = %obj.getPosition(); | ||||||
| @@ -245,6 +245,7 @@ function LogicGate_RobotController_Data::createRobot(%this, %obj) { | |||||||
| 		datablock = LuaLogic_RobotShapeData; | 		datablock = LuaLogic_RobotShapeData; | ||||||
| 		position = %rpos; | 		position = %rpos; | ||||||
| 	}; | 	}; | ||||||
|  | 	%robot.setScale("1 1 1"); | ||||||
| 	%robot.setNodeColor("ALL", "1 1 1 1"); | 	%robot.setNodeColor("ALL", "1 1 1 1"); | ||||||
| 	missionCleanup.add(%robot); | 	missionCleanup.add(%robot); | ||||||
| 	 | 	 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Redo
					Redo