for _, object in pairs(object_list) do if object.existing_object then object.existing_objects = {object.existing_object} end self.objects[#self.objects + 1] = object if pay_for then local build_cost = self.ui.hospital:getObjectBuildCost(object.object.id) self.ui.hospital:spendMoney(object.qty * build_cost, _S.transactions.buy_object .. ": " .. object.object.name, object.qty * build_cost) end end for _,ob in ipairs(self.objects) do if ob.object.orientations == nil then print(ob) for k,v in pairs(ob) do print(" ", k,v) if k == "object" then for ok,ov in pairs(v) do print(" ", ok,ov) end end end print() end end -- sort list by size of object (number of tiles in the first existing orientation (usually north)) table.sort(self.objects, function(o1, o2) local orient1 = o1.object.orientations.north or o1.object.orientations.east or o1.object.orientations.south or o1.object.orientations.west local orient2 = o2.object.orientations.north or o2.object.orientations.east or o2.object.orientations.south or o2.object.orientations.west return #orient1.footprint > #orient2.footprint end)