Index: mods/starlit-building/init.lua ================================================================== --- mods/starlit-building/init.lua +++ mods/starlit-building/init.lua @@ -7,11 +7,11 @@ --[[ { part = { ['starlit_building:pipe'] = 'myMod:stage3'; }; tool = { - ['starlit:scredriver'] = 'myMod:otherThing_stage1'; + ['starlit:screwdriver'] = 'myMod:otherThing_stage1'; ['starlit:saw'] = function(node, tool) minetest.replace_node(node, {name='myMod:stage1'}) minetest.drop_item(node, 'starlit_building:pipe') end; ['myMod:laserWrench'] = { @@ -61,19 +61,65 @@ }) ]] B.part = lib.registry.mk 'starlit_building:part' -- a part is implemented as a special craftitem with the proper callbacks --- to index the registries and place/replace noes by reference to the +-- to index the registries and place/replace nodes by reference to the -- build tree. --[[ starlit.mod.building.part.link(id, { name = ''; -- display name desc = ''; -- display desc img = ''; -- display image + mass = 0; + fab = {}; -- (optional) auto-gen schematic + rarity = 0; }) ]] +B.part.foreach('starlit:partGen', {}, function(id, e) + local props = {} + if e.mass then + table.insert(props, {title='Mass', desc=lib.math.siUI('g',e.mass), affinity='info'}) + end + local rev, scmID + if e.fab then + scmID = string.format('%s_schematic', id) + rev = { + sw = scmID; + complexity = e.complexity or 1; + } + end + minetest.register_craftitem(id, { + short_description = e.name; + description = starlit.ui.tooltip { + title = e.name; + desc = e.desc; + props = props; + }; + inventory_image = e.img; + _starlit = { + mass = e.mass; + reverseEngineer = rev; + recover = e.recover or e.fab; + }; + }) + if e.fab then + starlit.item.sw.link(scmID, { + kind = 'schematic'; + name = string.format('%s Schematic', e.name); + size = e.size or 32e6; + input = e.fab; + output = id; + cost = e.cost or { + cycles = 4e9; + ram = 1e9; + }; + rarity = e.rarity or 0; + }) + end + +end) B.stage.foreach('starlit:stageGen', {}, function(id, e) local box = {type = 'fixed', fixed = {}} local tex = {} local ofs = vector.new(0,0,0) @@ -131,5 +177,6 @@ function B.pathFind(from, kind, what) if not B.path[from] then return nil end return B.path[from][kind][what] end +starlit.include 'parts' ADDED mods/starlit-building/parts.lua Index: mods/starlit-building/parts.lua ================================================================== --- mods/starlit-building/parts.lua +++ mods/starlit-building/parts.lua @@ -0,0 +1,88 @@ +local lib = starlit.mod.lib +local E = starlit.mod.electronics +local B = starlit.mod.building + +B.part.link('starlit_building:battery_box', { + name = 'Battery Box'; + desc = 'A receptacle for a battery.'; + img = 'starlit-item-battery-box.png'; + fab = starlit.type.fab { + element = { + copper = 5; + aluminum = 10; + }; + cost = {power = 300}; + flag = {print=true}; + time = {print=10}; + }; + mass = 15; + rarity = 1; +}) + +B.part.link('starlit_building:electrode', { + name = 'Electrode'; + desc = 'An electrical conductor used to make contact with a nonmetallic circuit component.'; + img = 'starlit-item-electrode.png'; + fab = starlit.type.fab { + element = { + copper = 1; + aluminum = 1; + }; + cost = {power = 150}; + flag = {print=true}; + time = {print=5}; + }; + mass = 2; + rarity = 1; +}) + +B.part.link('starlit_building:heating_element', { + name = 'Heating Element'; + desc = 'An extremely inefficient conductor of electricity.'; + img = 'starlit-item-heating-element.png'; + fab = starlit.type.fab { + element = { + copper = 2; + nickel = 2; + }; + cost = {power = 300}; + flag = {print=true}; + time = {print=10}; + }; + mass = 4; + rarity = 1; +}) + +B.part.link('starlit_building:cable_electric', { + name = 'Electric Cable'; + desc = 'A length of conductive metal in a protective graphene sheathe.'; + img = 'starlit-item-cable-electric.png'; + fab = starlit.type.fab { + element = { + copper = 16; + carbon = 16; + }; + cost = {power = 700}; + flag = {print=true}; + time = {print=20}; + }; + mass = 32; + rarity = 1; +}) + +B.part.link('starlit_building:transformer', { + name = 'Transformer'; + desc = 'An electrical component used to step-up or step-down voltage levels.'; + img = 'starlit-item-transformer.png'; + fab = starlit.type.fab { + element = { + copper = 8; + iron = 16; + }; + cost = {power = 500}; + flag = {print=true}; + time = {print=20}; + }; + mass = 24; + rarity = 1; +}) Index: mods/starlit-electronics/init.lua ================================================================== --- mods/starlit-electronics/init.lua +++ mods/starlit-electronics/init.lua Index: mods/starlit-electronics/sw.lua ================================================================== --- mods/starlit-electronics/sw.lua +++ mods/starlit-electronics/sw.lua @@ -185,11 +185,11 @@ end starlit.item.sw.link('starlit_electronics:compile_commune', matterCompiler { name = 'Compile Matter'; desc = "A basic suit matter compiler program. It's rather slow, but it's been ruthlessly optimized for size- and memory-efficiency by some of the Commune's most fanatic coders, to the point where every Commune nanosuit can come with the program preinstalled."; - size = 700e3; + size = 700e6; cost = { cycles = 4e9; ram = .3e9; }; }) @@ -196,11 +196,11 @@ starlit.item.sw.link('starlit_electronics:compile_block_commune', { name = 'Compile Block'; kind = 'suitPower', powerKind = 'active'; desc = "An advanced suit matter compiler program, capable of printing complete devices and structure parts directly into the world."; - size = 5e6; + size = 500e6; cost = { cycles = 8e9; ram = 1e9; }; ui = 'starlit:compile-matter-block'; @@ -209,13 +209,13 @@ }) starlit.item.sw.link('starlit_electronics:compile_imperial', matterCompiler { name = 'Genesis Deluxe'; desc = "House Bascundir has long dominated the matter compiler market in the Crystal Sea. Their firmware is excessively complex due to mountains of specialized edge-case handling, but the end result is certainly speedier than the competitors'."; - size = 2e4; + size = 2e9; cost = { - cycles = 100e6; + cycles = 1e9; ram = 1.5e9; }; }) do local J = starlit.store.compilerJob Index: mods/starlit-material/elements.lua ================================================================== --- mods/starlit-material/elements.lua +++ mods/starlit-material/elements.lua @@ -78,10 +78,15 @@ vanadium = { name = 'vanadium', sym = 'V', n = 23; density = 6; metal = true; color = lib.color(.3,0.5,.3); }; + nickel = { + name = 'nickel', sym = 'ni', n = 28, density = 8.908; + metal = true; + color = lib.color(.7,.7,.6); + }; xenon = { name = 'xenon', sym = 'Xe', n = 54; density = 0.005894; gas = true; color = lib.color(.5,.1,1); }; Index: mods/starlit-scenario/init.lua ================================================================== --- mods/starlit-scenario/init.lua +++ mods/starlit-scenario/init.lua @@ -36,10 +36,15 @@ end local survivalBasics = { {'starlit_tech:chem_lamp', 0}; {'starlit_tech:crate', 0}; + {'starlit_building:battery_box', 0}; + {'starlit_building:heating_element', 0}; + {'starlit_building:electrode', 0}; + {'starlit_building:cable_electric', 0}; + {'starlit_building:transformer', 0}; } local chipLibrary = { compendium = makeChip('The Gentleman Adventurer\'s Compleat Wilderness Compendium', lib.tbl.append(survivalBasics, { {'starlit_electronics:battery_chemical_imperial_small', 0}; Index: mods/starlit-tech/init.lua ================================================================== --- mods/starlit-tech/init.lua +++ mods/starlit-tech/init.lua @@ -96,11 +96,11 @@ minetest.register_node('starlit_tech:crate', { short_description = 'Crate'; description = starlit.ui.tooltip { title = 'Crate'; - desc = 'A sturdy but lightweight storage crate made from solid carbon polymer.'; + desc = 'A sturdy but lightweight storage crate woven from graphene.'; props = { {title='Mass', affinity='info', desc='100g'} }; }; drawtype = 'nodebox'; node_box = { type = 'fixed'; Index: mods/starlit/interfaces.lua ================================================================== --- mods/starlit/interfaces.lua +++ mods/starlit/interfaces.lua @@ -323,11 +323,11 @@ end if r.powerCost then table.insert(props, {title = "Power Draw", desc=lib.math.siUI('W', r.powerCost), affinity='info'}) end if r.speed then - table.insert(props, {title = "Minimum Runtime", desc=lib.math.timespec(r.speed), affinity='info'}) + table.insert(props, {title = "Base Runtime", desc=lib.math.timespec(r.speed), affinity='info'}) end table.insert(tbl, { color = color, fg = fg; label = r.sw.label or r.sw.name; id = string.format('suit_pgm_%s_', id); Index: mods/starlit/ui.lua ================================================================== --- mods/starlit/ui.lua +++ mods/starlit/ui.lua @@ -178,28 +178,44 @@ totalH = totalH + rowH state.h = math.max(state.h, totalH) + state.padding state.w = state.x + state.padding/2 state.x = maxX elseif def.kind == 'pane' then + local top = state.y widget('scroll_container[%s,%s;%s,%s;%s;vertical]', state.x, state.y, state.w, state.h, def.id) local y = 0 + local x,w = state.x,state.w +-- state.x = state.x + .75 +-- state.w = state.w - .75 + local widgs = {} for _, w in ipairs(def) do local src, st = starlit.ui.build(w, state) - widget('container[%s,%s]%scontainer_end[]', 0, y, src) + table.insert(widgs, { + y=y, src=src + }) y=y + state.spacing + st.h state.w = math.max(state.w, st.w) end + local xo, barred = 0, false + if y-top > state.h then + barred, xo = true, .60 + end + for k,v in ipairs(widgs) do + widget('container[%s,%s]%scontainer_end[]', xo, v.y, v.src) + end widget('scroll_container_end[]') - if y > state.h then - widget('scrollbar[%s,%s;%s,%s;vertical;%s;]', - state.x, state.y, .5, state.h, + if barred then + widget('scrollbaroptions[max=%s]scrollbar[%s,%s;%s,%s;vertical;%s;]', + (y-top-state.h)*10, x, state.y, .5, state.h, def.id) end - state.w = state.w + state.padding + state.x = x + state.w = w + state.padding state.h = state.h + state.padding/2 + state.y = state.y + state.h elseif def.kind == 'list' then local slotTypes = { plain = {hue = 200, sat = -.1, lum = 0}; -- element = {hue = 20, sat = -.3, lum = 0}; chip = {hue = 0, sat = -1, lum = 0}; @@ -325,10 +341,11 @@ l = string.format('background9[%s,%s;%s,%s;%s;false;64]', originX, originY, state.w, state.h, E(string.format('starlit-ui-bg-%s.png%s^[resize:128x128', (def.mode == 'sw') and 'digital' or 'panel', cmod))) .. l +-- l = string.format('style_type[scrollbar;bgcolor=#1155ff]') .. l end if parent == nil or state.color ~= parent.color then l = btnColorDef() .. l end end Index: mods/vtlib/marshal.lua ================================================================== --- mods/vtlib/marshal.lua +++ mods/vtlib/marshal.lua @@ -197,20 +197,22 @@ if select('#', ...) >= 2 then name, def = ... else def = ... end - name = 'struct' .. (name and ':' .. name or ''); + name = 'struct' .. (name and (':' .. name) or ''); report('defining struct name=%q fields=%s', name, dump(def)) return { name = name; enc = function(obj) report('encoding struct name=%q vals=%s', name, dump(obj)) local enc = m.streamEncoder() local n = 0 for k,ty in pairs(def) do n=n+1 - if obj[k] == nil then error('missing key '..dump(k)..' for type '..ty.name) end + if obj[k] == nil then + error(string.format("missing %s field %q for %s", ty.name, k, name)) + end local encoded = ty.enc(obj[k]) enc.push(T.u8.enc(#k), size.enc(#encoded), k, encoded) end return size.enc(n) .. enc.peek() end;