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