Commits

Chris Klimas committed 30fabb3

Handle nil properties in __tostring() methods

Comments (0)

Files changed (7)

zoetrope/core/app.lua

 			result = result .. 'inactive'
 		end
 
-		return result .. ', ' .. self.fps .. ' fps, ' .. self.view:count(true) .. ' sprites)'
+		return result .. ', ' .. tostring(self.fps) .. ' fps, ' .. self.view:count(true) .. ' sprites)'
 	end
 }

zoetrope/sprites/animation.lua

 	end,
 
 	__tostring = function (self)
-		local result = 'Animation (x: ' .. self.x .. ', y: ' .. self.y ..
-					   ', w: ' .. self.width .. ', h: ' .. self.height .. ', '
+		local result = 'Animation (x: ' .. tostring(self.x) .. ', y: ' .. tostring(self.y) ..
+					   ', w: ' .. tostring(self.width) .. ', h: ' .. tostring(self.height) .. ', '
 
 		if self.currentName then
 			result = result .. 'playing ' .. self.currentName .. ', '
 		end
 
-		result = result .. ' frame ' .. self.currentFrame .. ', '
+		result = result .. ' frame ' .. tostring(self.currentFrame) .. ', '
 
 		if self.active then
 			result = result .. 'active, '

zoetrope/sprites/emitter.lua

 	end,
 
 	__tostring = function (self)
-		local result = 'Emitter (x: ' .. self.x .. ', y: ' .. self.y ..
-					   ', w: ' .. self.width .. ', h: ' .. self.height .. ', '
+		local result = 'Emitter (x: ' .. tostring(self.x) .. ', y: ' .. tostring(self.y) ..
+					   ', w: ' .. tostring(self.width) .. ', h: ' .. tostring(self.height) .. ', '
 
 		if self.emitting then
-			result = result .. 'emitting with period ' .. self.period .. ', '
+			result = result .. 'emitting with period ' .. tostring(self.period) .. ', '
 		else
 			result = result .. 'not emitting, '
 		end

zoetrope/sprites/fill.lua

 	end,
 
 	__tostring = function (self)
-		local result = 'Fill (x: ' .. self.x .. ', y: ' .. self.y ..
-					   ', w: ' .. self.width .. ', h: ' .. self.height .. ', '
+		local result = 'Fill (x: ' .. tostring(self.x) .. ', y: ' .. tostring(self.y) ..
+					   ', w: ' .. tostring(self.width) .. ', h: ' .. tostring(self.height) .. ', '
 
 		if self.fill then
-			result = result .. 'fill {' .. table.concat(self.fill, ', ') .. '}, '
+			result = result .. 'fill {' .. table.concat(tostring(self.fill), ', ') .. '}, '
 		else
 			result = result .. 'no fill, '
 		end
 
 		if self.border then
-			result = result .. 'border {' .. table.concat(self.border, ', ') .. '}, '
+			result = result .. 'border {' .. table.concat(tostring(self.border), ', ') .. '}, '
 		else
 			result = result .. 'no border, '
 		end

zoetrope/sprites/map.lua

 	end,
 
 	__tostring = function (self)
-		local result = 'Map (x: ' .. self.x .. ', y: ' .. self.y ..
-					   ', w: ' .. self.width .. ', h: ' .. self.height .. ', '
+		local result = 'Map (x: ' .. tostring(self.x) .. ', y: ' .. tostring(self.y) ..
+					   ', w: ' .. tostring(self.width) .. ', h: ' .. tostring(self.height) .. ', '
 
 		if self.active then
 			result = result .. 'active, '

zoetrope/sprites/text.lua

 	end,
 
 	__tostring = function (self)
-		local result = 'Text (x: ' .. self.x .. ', y: ' .. self.y ..
-					   ', w: ' .. self.width .. ', h: ' .. self.height .. ', '
+		local result = 'Text (x: ' .. tostring(self.x) .. ', y: ' .. tostring(self.y) ..
+					   ', w: ' .. tostring(self.width) .. ', h: ' .. tostring(self.height) .. ', '
 
 		result = result .. 'font ' .. dump(self.font) .. ', ' .. string.len(self.text) .. ' chars, '
 

zoetrope/sprites/tile.lua

 	end,
 
 	__tostring = function (self)
-		local result = 'Tile (x: ' .. self.x .. ', y: ' .. self.y ..
-					   ', w: ' .. self.width .. ', h: ' .. self.height .. ', '
+		local result = 'Tile (x: ' .. tostring(self.x) .. ', y: ' .. tostring(self.y) ..
+					   ', w: ' .. tostring(self.width) .. ', h: ' .. tostring(self.height) .. ', '
 
 		result = result .. 'image \'' .. self.image .. '\', '