diff demos/rpg/scripts/gamecontroller.py @ 537:764510a6d2f9

Added the move command. Updated the settings-dist.xml file that changes the camera zoom to 1 and adds the script module to the log.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 31 May 2010 21:37:10 +0000
parents 1afe46247ab1
children 2e739ae9a8bc
line wrap: on
line diff
--- a/demos/rpg/scripts/gamecontroller.py	Mon May 31 20:25:46 2010 +0000
+++ b/demos/rpg/scripts/gamecontroller.py	Mon May 31 21:37:10 2010 +0000
@@ -212,7 +212,7 @@
 				cmd.append(arg)
 		
 		if cmd[0] == "spawn":
-			result = "Usage: spawn [item|actor] [id] [posx] [posy]"
+			result = "Usage: spawn [item|actor] [object id] [posx] [posy]"
 			if len(cmd) != 5:
 				return result
 			else:
@@ -230,9 +230,22 @@
 				if obj:
 					try:
 						self._scene.addObjectToScene(obj)
+						obj.position = (float(cmd[3]), float(cmd[4]))
 						result = "--OK--"
 					except ObjectAlreadyInSceneError, e:
 						result = "Error: [" + cmd[2] + "] is already on the scene."
+						
+		elif cmd[0] == "move":
+			result = "Usage: move [object id] [posx] [posy]"
+			if len(cmd) != 4:
+				return result
+			else:
+				obj = self._scene.getObject(cmd[1])
+				if obj:
+					obj.position = (float(cmd[2]), float(cmd[3]))
+					result = "--OK--"
+				else:
+					result = "Error: [" + cmd[1] + "] does not exist on the scene."
 			
 		return result