72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
end
table.sort(sorted, function(a,b) return a.can.vol < b.can.vol end)
local liq = starlit.world.material[kind].db[name]
local can
for i, v in ipairs(sorted) do
if v.can.vol <= liq.density * mass then
can = ItemStack(i)
break
end
end
if can == nil then log.fatal('failed to find canister size for gift %s', kind) end
local st = starlit.item.canister.meta(can)
st.write('contents', {kind = kind, id = name, mass = mass})
return can
end
table.insert(scenario, {
id = 'starlit_scenario:imperialExpat';
name = 'Imperial Expat';
|
|
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
end
table.sort(sorted, function(a,b) return a.can.vol < b.can.vol end)
local liq = starlit.world.material[kind].db[name]
local can
for i, v in ipairs(sorted) do
if v.can.vol >= liq.density * mass then
can = ItemStack(v.id)
break
end
end
if can == nil then log.fatal('failed to find canister size for gift %s', kind) end
-- print('mass = ',mass)
starlit.item.canister.replace(can, {kind = kind, id = name, mass = mass})
-- print('content', dump(starlit.item.canister.contents(can)))
-- print("can", dump(can:get_meta():get_string 'starlit:canister_contents'))
return can
end
table.insert(scenario, {
id = 'starlit_scenario:imperialExpat';
name = 'Imperial Expat';
|