 
 		push "if (#{terrainItemCondition}) {"
 
-		push "setTerrainItem(prevPosition, '#{resolveItem rule.outTerrainItemName}')"
+		if rule.outTerrainItemName?
+			push "setTerrainItem(prevPosition, #{resolveItem rule.outTerrainItemName})"
 
 		push "}"
 


		push 'function applyLeaveRules (prevPosition) {'

		push 'var terrainItem = getTerrainItem(prevPosition)'

		push 'var inventoryItem = getInventoryItem()'

		ruleLines = makeList()
		rules.forEach (rule) ->

			when '_inventory'
				'inventoryItem'
			else
				"'#{reference}'"


	makeList = ->
