diff demos/rpg/scripts/objects/baseobject.py @ 547:e59ece21ab3e

Item serialization will now assume some default values if they are not found in the save files. The 'spawn' console command can now spawn items with default values. Cleaned up some print statements.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 04 Jun 2010 21:01:34 +0000
parents 8fee2d2286e9
children 718e154a43c8
line wrap: on
line diff
--- a/demos/rpg/scripts/objects/baseobject.py	Thu Jun 03 21:35:06 2010 +0000
+++ b/demos/rpg/scripts/objects/baseobject.py	Fri Jun 04 21:01:34 2010 +0000
@@ -102,7 +102,7 @@
 		if createInstance:
 			self._createFIFEInstance(self._layer)
 		else:
-			self._instance = None
+			self._findFIFEInstance(self._layer)
 			
 		self._activated = True
 		
@@ -140,9 +140,16 @@
 		
 		return lvars
 
-	def deserialize(self, valuedict):	
-		x = float(valuedict['posx'])
-		y = float(valuedict['posy'])
+	def deserialize(self, valuedict):
+		if valuedict.has_key("posx"):
+			x = float(valuedict['posx'])
+		else:
+			x = 0
+			
+		if valuedict.has_key("posy"):
+			y = float(valuedict['posy'])
+		else:
+			y = 0
 		
 		self.setMapPosition(x,y)
 
@@ -187,7 +194,10 @@
 		return self._name
 		
 	def _getPosition(self):
-		self._position = self.location.getExactLayerCoordinates()
+		#if there isn't a FIFE instance just return last known coordinates
+		if self._instance:
+			self._position = self.location.getExactLayerCoordinates()
+		
 		return (self._position.x, self._position.y)
 		
 	def _setPosition(self, tuplexy):