Changes

load Equipment lazily (on slot() access)
Line 211: Line 211:  
local equipment_slot = self._equipment[slot]
 
local equipment_slot = self._equipment[slot]
 
if equipment_slot then
 
if equipment_slot then
 +
if type(equipment_slot.equipment) == "string" then
 +
equipment_slot.equipment = Equipment(equipment_slot.equipment)
 +
end
 
return equipment_slot.equipment, equipment_slot.size
 
return equipment_slot.equipment, equipment_slot.size
 
end
 
end
Line 255: Line 258:  
if ship._class then
 
if ship._class then
 
ship._class = ShipClass(ship._class)
 
ship._class = ShipClass(ship._class)
end
  −
if ship._equipment then
  −
for _, slot in ipairs(ship._equipment) do
  −
if slot.equipment then
  −
slot.equipment = Equipment(slot.equipment)
  −
end
  −
end
   
end
 
end
 
setmetatable(ship, ship)
 
setmetatable(ship, ship)
Anonymous user