Loading

Paste #pvl8ki4t0

  1.   for _, object in pairs(object_list) do
  2.     if object.existing_object then
  3.       object.existing_objects = {object.existing_object}
  4.     end
  5.     self.objects[#self.objects + 1] = object
  6.     if pay_for then
  7.       local build_cost = self.ui.hospital:getObjectBuildCost(object.object.id)
  8.       self.ui.hospital:spendMoney(object.qty * build_cost, _S.transactions.buy_object .. ": " .. object.object.name, object.qty * build_cost)
  9.     end
  10.   end
  11.  
  12.   for _,ob in ipairs(self.objects) do
  13.     if ob.object.orientations == nil then
  14.       print(ob)
  15.       for k,v in pairs(ob) do
  16.         print("    ", k,v)
  17.         if k == "object" then
  18.           for ok,ov in pairs(v) do
  19.             print("        ", ok,ov)
  20.           end
  21.         end
  22.       end
  23.       print()
  24.     end
  25.   end
  26.  
  27.   -- sort list by size of object (number of tiles in the first existing orientation (usually north))
  28.   table.sort(self.objects, function(o1, o2)
  29.     local orient1 = o1.object.orientations.north or o1.object.orientations.east
  30.                  or o1.object.orientations.south or o1.object.orientations.west
  31.     local orient2 = o2.object.orientations.north or o2.object.orientations.east
  32.                  or o2.object.orientations.south or o2.object.orientations.west
  33.     return #orient1.footprint > #orient2.footprint
  34.   end)

Comments