Differences From
Artifact [bf764e9a62]:
1 1 local lib = starlit.mod.lib
2 2 local scenario = starlit.world.scenario
3 +local log = starlit.logger 'scenario'
3 4
4 5 local function makeChip(label, schem, sw)
5 6 local E = starlit.mod.electronics
6 7 local files = {}
7 8 local sz = 0
8 9 for _, e in ipairs(schem) do
9 10 local p = E.sw.findSchematicFor(e[1])
10 11 if p then
11 12 local file = {
12 13 kind = 'sw', name = '', drm = e[2];
13 - body = {pgmId = p};
14 + body = {pgmId = p, conf = {}};
14 15 }
15 16 table.insert(files, file)
16 17 sz = sz + E.chip.fileSize(file)
17 18 end
18 19 end
19 20 for _, e in ipairs(sw) do
20 21 local file = {
21 22 kind = 'sw', name = '', drm = e[2];
22 - body = {pgmId = e[1]};
23 + body = {pgmId = e[1], conf = {}};
23 24 }
24 25 table.insert(files, file)
25 26 sz = sz + E.chip.fileSize(file)
26 27 end
27 28 local chip = ItemStack(assert(E.chip.findBest(function(c)
28 29 return c.flash >= sz, c.ram + c.clockRate
29 30 end)))
................................................................................
60 61
61 62 local battery = function(name)
62 63 local s = ItemStack(name)
63 64 starlit.mod.electronics.battery.setChargeF(s, 1.0)
64 65 return s
65 66 end
66 67
68 +local function volume(kind,name,mass)
69 + local sorted = {}
70 + for k,v in pairs(starlit.item.canister.db) do
71 + table.insert(sorted, {id=k, can=v})
72 + end
73 + table.sort(sorted, function(a,b) return a.can.vol < b.can.vol end)
74 +
75 + local liq = starlit.world.material[kind].db[name]
76 +
77 + local can
78 + for i, v in ipairs(sorted) do
79 + if v.can.vol <= liq.density * mass then
80 + can = ItemStack(i)
81 + break
82 + end
83 + end
84 + if can == nil then log.fatal('failed to find canister size for gift %s', kind) end
85 +
86 + local st = starlit.item.canister.meta(can)
87 + st.write('contents', {kind = kind, id = name, mass = mass})
88 +
89 + return can
90 +end
91 +
67 92
68 93 table.insert(scenario, {
69 94 id = 'starlit_scenario:imperialExpat';
70 95 name = 'Imperial Expat';
71 96 desc = "Hoping to escape a miserable life deep in the grinding gears of the capitalist machine for the bracing freedom of the frontier, you sought entry as a colonist to the new Commune world of Thousand Petal. Fate -- which is to say, terrorists -- intervened, and you wound up stranded on Farthest Shadow with little more than the nanosuit on your back, ship blown to tatters and your soul thoroughly mauled by the explosion of a twisted alien artifact -- which SOMEONE neglected to inform you your ride would be carrying.\nAt least you got some nifty psionic powers out of this whole clusterfuck. Hopefully they're safe to use.";
72 97
73 98 species = 'human';
................................................................................
91 116 -- came with this chip already plugged in. it's apparently true
92 117 -- what they say: the Commune is always prepared for everything.
93 118 -- E V E R Y T H I N G.
94 119 };
95 120 suitGuns = {};
96 121 suitAmmo = {};
97 122 suitCans = {
98 - ItemStack('starlit_material:canister_small');
123 +-- ItemStack('starlit_material:canister_small');
124 + volume('liquid', 'water', 5);
99 125 };
100 126 carry = {
101 127 chipLibrary.compendium;
102 128 -- you bought this on a whim before you left the Empire, and
103 129 -- just happened to still have it on your person when everything
104 130 -- went straight to the Wild Gods' privy
105 131 };