Index: asset.list ================================================================== --- asset.list +++ asset.list @@ -6,15 +6,18 @@ mods/starlit-building/textures/starlit-item-pipe.png mods/starlit-building/textures/starlit-item-panel.png mods/starlit-building/textures/starlit-item-concrete.png mods/starlit-building/textures/starlit-node-concrete.png mods/starlit-building/textures/starlit-node-floor-panel-side.png -mods/starlit-building/textures/starlit-node-floor-panel-side-conduit.png mods/starlit-building/textures/starlit-node-floor-panel-top.png mods/starlit-building/textures/starlit-node-floor-panel-top-vent.png mods/starlit-building/textures/starlit-node-insulation-top.png -mods/starlit-building/textures/starlit-node-insulation-cable-top.png +mods/starlit-building/textures/starlit-node-cable-run.png +mods/starlit-building/textures/starlit-node-cable-plug.png +mods/starlit-building/textures/starlit-node-pipe-run.png +mods/starlit-building/textures/starlit-node-pipe-plug.png +mods/starlit-building/textures/starlit-node-insulated-panels.png mods/starlit-eco/textures/starlit-eco-plant-berry-bunch.png mods/starlit-eco/textures/starlit-eco-plant-bloom-leaf.png mods/starlit-eco/textures/starlit-eco-plant-bloom-petal.png mods/starlit-eco/textures/starlit-eco-plant-bloom-stalk.png mods/starlit-eco/textures/starlit-eco-plant-fiber.png Index: makefile ================================================================== --- makefile +++ makefile @@ -1,17 +1,24 @@ all: asset-sync doc-sync +repo-uri = https://c.hale.su/starlit + starlit.html: starlit.ct cortav -y html:fossil-uv "$<" -o "$@" .PHONY: doc-sync doc-sync: starlit.html fossil uv add "$<" fossil uv sync -asset.cpxz: asset.list $(cat asset.list) +asset.cpxz: asset.list $(shell cat asset.list) cpio -o <"$<" | xz >"$@" .PHONY: asset-sync asset-sync: asset.cpxz fossil uv add "$<" fossil uv sync + +.PHONY: unpack +unpack: + fossil uv ex asset.cpxz asset.cpxz || curl $(repo-uri)/uv/asset.cpxz -o asset.cpxz + xzcat asset.cpxz | cpio -i Index: mods/starlit-building/init.lua ================================================================== --- mods/starlit-building/init.lua +++ mods/starlit-building/init.lua @@ -90,10 +90,11 @@ description = starlit.ui.tooltip { title = e.name; desc = e.desc; props = props; }; + stack_max = e.max or (e.mass and math.min(math.max(math.floor(500 / e.mass), 1), 500)) or 10; inventory_image = e.img; on_place = function(stack, luser, point) local node = minetest.get_node(point.under) local function tryBuild() local p = B.path[node.name] @@ -178,18 +179,19 @@ minetest.register_node(id, { description = 'Construction'; drawtype = (e.box and 'nodebox') or (e.mesh and 'mesh') or 'regular'; - paramtype = (e.box or e.mesh or e.light) and 'light' or nil; - paramtype2 = e.stateful or 'none'; + paramtype = e.paramtype or (e.box or e.mesh or e.light) and 'light' or nil; + paramtype2 = e.paramtype2 or 'none'; tiles = e.tex; node_box = e.box; mesh = e.mesh; groups = grp; _starlit = { stage = id; + recover = e.recover; }; }) if e.begin then for _, kind in ipairs {'part', 'tool'} do for i, v in ipairs(e.begin[kind] or {}) do @@ -207,6 +209,6 @@ end end) starlit.include 'parts' -starlit.include 'stages' +starlit.include 'stages/arch' Index: mods/starlit-building/parts.lua ================================================================== --- mods/starlit-building/parts.lua +++ mods/starlit-building/parts.lua @@ -92,17 +92,17 @@ desc = 'A sturdy base for modular construction units.'; img = 'starlit-item-concrete.png'; fab = starlit.type.fab { element = { calcium = 1; - carbon = 4; + carbon = 3; }; cost = {power = 200}; flag = {print=true}; time = {print=5}; }; - mass = 5; + mass = 4; rarity = 1; }) B.part.link('starlit_building:insulation', { name = 'Insulation'; @@ -124,17 +124,17 @@ name = 'Panel'; desc = 'A sheet of aluminum suitable for use as a wall or floor panel.'; img = 'starlit-item-panel.png'; fab = starlit.type.fab { element = { - aluminum = 8; + aluminum = 4; }; cost = {power = 300}; flag = {print=true}; time = {print=15}; }; - mass = 8; + mass = 4; rarity = 1; }) B.part.link('starlit_building:pipe', { name = 'Pipe'; DELETED mods/starlit-building/stages.lua Index: mods/starlit-building/stages.lua ================================================================== --- mods/starlit-building/stages.lua +++ mods/starlit-building/stages.lua @@ -1,130 +0,0 @@ -local lib = starlit.mod.lib -local B = starlit.mod.building -B.stage.link('starlit_building:stage_foundation', { - tex = { - 'starlit-node-concrete.png'; - }; - begin = { - part = { - 'starlit_building:concrete'; - }; - }; - build = { - part = { - ['starlit_building:insulation'] = 'starlit_building:stage_foundation_insulation'; - }; - }; - box = { - type = 'fixed'; - fixed = { - -.5, -.5, -.5; - .5, -.5 + (2/16), .5; - }; - }; -}) - -B.stage.link('starlit_building:stage_foundation_insulation', { - tex = { - 'starlit-node-insulation-top.png'; - 'starlit-node-concrete.png'; - 'starlit-node-floor-panel-side.png'; - }; - build = { - part = { - ['starlit_building:insulation'] = 'starlit_building:stage_foundation_insulation_x2'; - ['starlit_building:cable_electric'] = 'starlit_building:stage_foundation_insulation_conduit'; - }; - }; - box = { - type = 'fixed'; - fixed = { - -.5, -.5, -.5; - .5, -.5 + (6/16), .5; - }; - }; -}) - -B.stage.link('starlit_building:stage_foundation_insulation_x2', { - tex = { - 'starlit-node-insulation-top.png'; - 'starlit-node-concrete.png'; - 'starlit-node-floor-panel-side.png'; - }; - build = { - part = { - ['starlit_building:panel'] = 'starlit_building:floor'; - }; - }; - box = { - type = 'fixed'; - fixed = { - -.5, -.5, -.5; - .5, -.5 + (14/16), .5; - }; - }; -}) - -B.stage.link('starlit_building:stage_foundation_insulation_conduit', { - tex = { - 'starlit-node-insulation-cable-top.png'; - 'starlit-node-concrete.png'; - 'starlit-node-floor-panel-side-conduit.png'; - }; - groups = { - conduit = 1; - }; - build = { - part = { - ['starlit_building:insulation'] = 'starlit_building:stage_foundation_insulated_conduit'; - }; - }; - box = { - type = 'fixed'; - fixed = { - -.5, -.5, -.5; - .5, -.5 + (8/16), .5; - }; - }; -}) - -B.stage.link('starlit_building:stage_foundation_insulated_conduit', { - tex = { - 'starlit-node-insulation-top.png'; - 'starlit-node-concrete.png'; - 'starlit-node-floor-panel-side-conduit.png'; - }; - build = { - part = { - ['starlit_building:panel'] = 'starlit_building:conduit'; - }; - }; - groups = { - conduit = 1; - }; - box = { - type = 'fixed'; - fixed = { - -.5, -.5, -.5; - .5, -.5 + (14/16), .5; - }; - }; -}) - -B.stage.link('starlit_building:conduit', { - tex = { - 'starlit-node-floor-panel-top.png'; - 'starlit-node-concrete.png'; - 'starlit-node-floor-panel-side-conduit.png'; - }; - groups = { - conduit = 1; - }; -}) - -B.stage.link('starlit_building:floor', { - tex = { - 'starlit-node-floor-panel-top.png'; - 'starlit-node-concrete.png'; - 'starlit-node-floor-panel-side.png'; - }; -}) ADDED mods/starlit-building/stages/arch.lua Index: mods/starlit-building/stages/arch.lua ================================================================== --- mods/starlit-building/stages/arch.lua +++ mods/starlit-building/stages/arch.lua @@ -0,0 +1,385 @@ +local lib = starlit.mod.lib +local B = starlit.mod.building + +local function fabFor(x) + local def = ItemStack(x):get_definition() + assert(def ~= nil, 'invalid item ID ' .. tostring(x)) + return (def._starlit and def._starlit.recover) or starlit.type.fab {} +end + +B.stage.link('starlit_building:foundation', { + tex = { + 'starlit-node-concrete.png'; + }; + begin = { + part = { + 'starlit_building:concrete'; + }; + }; + build = { + part = { + ['starlit_building:insulation'] = 'starlit_building:stage_foundation_insulation'; + ['starlit_building:concrete'] = 'starlit_building:step_concrete'; + }; + }; + recover = fabFor 'starlit_building:concrete'; + box = { + type = 'fixed'; + fixed = { + -.5, -.5, -.5; + .5, -.5 + (2/16), .5; + }; + }; +}) + +B.stage.link('starlit_building:step_concrete', { + tex = { + 'starlit-node-concrete.png'; + }; + build = { + part = { + ['starlit_building:concrete'] = 'starlit_building:pillar_concrete'; + }; + }; + recover = fabFor 'starlit_building:concrete' * 2; + box = { + type = 'fixed'; + fixed = { + -.5, -.5, -.5; + .5, -.5 + (8/16), .5; + }; + }; +}) + +B.stage.link('starlit_building:pillar_concrete', { + tex = { + 'starlit-node-concrete.png'; + }; + recover = fabFor 'starlit_building:concrete' * 3; +}) + +B.stage.link('starlit_building:stage_foundation_insulation', { + tex = { + 'starlit-node-insulation-top.png'; + 'starlit-node-concrete.png'; + 'starlit-node-floor-panel-side.png'; + }; + recover = fabFor 'starlit_building:concrete' + + fabFor 'starlit_building:insulation'; + build = { + part = { + ['starlit_building:panel'] = 'starlit_building:floor'; + }; + tool = { + object = { + speed = 2; + drop = 'starlit_building:insulation'; + swap = 'starlit_building:foundation'; + }; + }; + }; + box = { + type = 'fixed'; + fixed = { + -.5, -.5, -.5; + .5, -.5 + (12/16), .5; + }; + }; +}) + +B.panelRun = lib.registry.mk 'starlit_building:panelRun' +B.panelRun.foreach('starlit_building:runGen', {}, function(id, run) + local F = string.format + assert(run.name, 'missing name for panelrun') + local name = run.name + local buildPart = ItemStack(run.buildPart):get_name() + local plugItem = ItemStack(run.plugItem):get_name() + local floorStageRaw = id .. '_floor_open' + local floorStage = id .. '_floor' + local floorStagePlug = id .. '_floor_plug' + + local wallStageRaw = id .. '_wall_open' + local wallStage = id .. '_wall' + local wallStagePlug = id .. '_wall_plug' + + local texRun = run.run or F('starlit-node-%s-run.png', name) + local texPlug = run.plug or F('starlit-node-%s-plug.png', name) + + local imgRun = lib.image(texRun) + local imgPlug = lib.image(texPlug) + + local baseMat = fabFor(run.buildPart) + fabFor 'starlit_building:insulation' + local floorMat = baseMat + fabFor 'starlit_building:concrete' + local wallMat = baseMat + fabFor 'starlit_building:panel' + + ------------------ + -- floor stages -- + ------------------ + B.stage.link(floorStageRaw, { + tex = { + imgRun:blit(lib.image 'starlit-node-insulation-top.png'):render(); + 'starlit-node-concrete.png'; + imgPlug:blit(lib.image 'starlit-node-floor-panel-side.png'):render(); + }; + recover = floorMat; + build = { + part = { + ['starlit_building:panel'] = floorStage; + }; + tool = { + object = { + speed = 1; + drop = run.buildPart; + swap = floorStageRaw; + }; + }; + }; + box = { + type = 'fixed'; + fixed = { + -.5, -.5, -.5; + .5, -.5 + (12/16), .5; + }; + }; + }) + + local floorBasis = run.floorBasis or 'starlit_building:stage_foundation_insulation' + B.pathLink(floorBasis, 'part', buildPart, floorStageRaw) + + mat = floorMat + fabFor 'starlit_building:panel'; + B.stage.link(floorStage, { + tex = { + 'starlit-node-floor-panel-top.png'; + 'starlit-node-concrete.png'; + imgPlug:blit(lib.image 'starlit-node-floor-panel-side.png'):render(); + }; + recover = floorMat + fabFor 'starlit_building:panel'; + build = { + part = { + [plugItem] = floorStagePlug; + }; + tool = { + unscrew = { + speed = 1; + drop = 'starlit_building:panel'; + swap = floorBasis; + }; + }; + }; + groups = run.groups; + }) + + if run.plugGroups then + B.stage.link(floorStagePlug, { + tex = { + imgPlug:blit(lib.image 'starlit-node-floor-panel-top.png'):render(); + 'starlit-node-concrete.png'; + imgPlug:blit(lib.image 'starlit-node-floor-panel-side.png'):render(); + }; + recover = floorMat + fabFor(run.plugItem); + build = { + tool = { + unscrew = { + speed = 1; + drop = run.plugItem; + swap = floorStage; + }; + }; + }; + groups = run.plugGroups; + }) + end + + ----------------- + -- wall stages -- + ----------------- + local imgPanel = lib.image 'starlit-node-insulated-panels.png' + B.stage.link(wallStageRaw, { + tex = { + imgPlug:blit(imgPanel):render(); + imgPlug:blit(imgPanel):render(); + + imgPlug:blit(imgPanel:transform 'R270'):render(); + imgPlug:blit(imgPanel:transform 'R90'):render(); + + imgRun:blit(lib.image 'starlit-node-insulation-top.png'):render(); + 'starlit-node-floor-panel-top.png'; + }; + recover = wallMat; + build = { + part = { + ['starlit_building:panel'] = wallStage; + }; + }; + groups = run.groups; + paramtype2 = '4dir'; + box = { + type = 'fixed'; + fixed = { + -.5, -.5, -.5; + 0.5, 0.5, -.5 + (12/16); + }; + }; + }) + + local wallBasis = run.wallBasis or 'starlit_building:stage_wall_insulation' + B.pathLink(wallBasis, 'part', buildPart, wallStageRaw) + + B.stage.link(wallStage, { + tex = { + imgPlug:blit(imgPanel):render(); + imgPlug:blit(imgPanel):render(); + + imgPlug:blit(imgPanel:transform 'R270'):render(); + imgPlug:blit(imgPanel:transform 'R90'):render(); + + 'starlit-node-floor-panel-top.png'; + 'starlit-node-floor-panel-top.png'; + }; + recover = wallMat + fabFor 'starlit_building:panel'; + build = { + part = { + [plugItem] = wallStagePlug; + }; + }; + paramtype2 = '4dir'; + groups = run.groups; + }) + + if run.plugGroups then + B.stage.link(wallStagePlug, { + tex = { + imgPlug:blit(imgPanel):render(); + imgPlug:blit(imgPanel):render(); + + imgPlug:blit(imgPanel:transform 'R270'):render(); + imgPlug:blit(imgPanel:transform 'R90'):render(); + + 'starlit-node-floor-panel-top.png'; + imgPlug:blit(lib.image 'starlit-node-floor-panel-top.png'):render(); + }; + recover = wallMat + fabFor(plugItem); + build = { + }; + paramtype2 = '4dir'; + groups = run.plugGroups; + }) + end +end) + + +B.stage.link('starlit_building:floor', { + tex = { + 'starlit-node-floor-panel-top.png'; + 'starlit-node-concrete.png'; + 'starlit-node-floor-panel-side.png'; + }; + recover = fabFor 'starlit_building:concrete' + + fabFor 'starlit_building:insulation' + + fabFor 'starlit_building:panel'; + build = { + tool = { + unscrew = { + speed = 2; + drop = 'starlit_building:panel'; + swap = 'starlit_building:stage_foundation_insulation'; + }; + }; + }; +}) + +B.stage.link('starlit_building:stage_wall_panel', { + tex = { + 'starlit-node-insulated-panels.png'; + 'starlit-node-insulated-panels.png'; + 'starlit-node-insulated-panels.png^[transformR270'; + 'starlit-node-insulated-panels.png^[transformR90'; + 'starlit-node-floor-panel-top.png'; + }; + recover = fabFor 'starlit_building:panel'; + begin = { + part = {'starlit_building:panel'}; + }; + build = { + part = { + ['starlit_building:insulation'] = 'starlit_building:stage_wall_insulation'; + }; + }; + paramtype2 = '4dir'; + box = { + type = 'fixed'; + fixed = { + -.5, -.5, -.5; + 0.5, 0.5, -.5 + (2/16); + }; + }; +}) + +B.stage.link('starlit_building:stage_wall_insulation', { + tex = { + 'starlit-node-insulated-panels.png'; + 'starlit-node-insulated-panels.png'; + 'starlit-node-insulated-panels.png^[transformR270'; + 'starlit-node-insulated-panels.png^[transformR90'; + 'starlit-node-insulation-top.png'; + 'starlit-node-floor-panel-top.png'; + }; + recover = fabFor 'starlit_building:panel' + + fabFor 'starlit_building:insulation'; + build = { + part = { + ['starlit_building:panel'] = 'starlit_building:wall'; + }; + }; + paramtype2 = '4dir'; + box = { + type = 'fixed'; + fixed = { + -.5, -.5, -.5; + 0.5, 0.5, -.5 + (12/16); + }; + }; +}) + +B.stage.link('starlit_building:wall', { + tex = { + 'starlit-node-insulated-panels.png'; + 'starlit-node-insulated-panels.png'; + 'starlit-node-insulated-panels.png^[transformR270'; + 'starlit-node-insulated-panels.png^[transformR90'; + 'starlit-node-floor-panel-top.png'; + 'starlit-node-floor-panel-top.png'; + }; + recover = (fabFor 'starlit_building:panel' * 2) + + fabFor 'starlit_building:insulation'; + build = { + }; + paramtype2 = '4dir'; +}) + + +B.panelRun.link('starlit_building:conduit_power', { + name = 'cable'; + buildPart = 'starlit_building:cable_electric'; + plugItem = 'starlit_building:electrode'; + groups = { + conduit_power = 1; + conduit_data = 1; + }; + plugGroups = { + conduit_power = 2; + conduit_data = 2; + }; +}) + +B.panelRun.link('starlit_building:conduit_fluid', { + name = 'pipe'; + buildPart = 'starlit_building:pipe'; + plugItem = 'starlit_building:pipe'; + groups = { + conduit_fluid = 1; + }; + plugGroups = { + conduit_fluid = 2; + }; +}) Index: mods/starlit/fab.lua ================================================================== --- mods/starlit/fab.lua +++ mods/starlit/fab.lua @@ -393,25 +393,29 @@ new[cat] = lib.tbl.copy(vals) else local f = fields[cat].op for k,v in pairs(vals) do local n = f(new[cat][k], v, 1) - new[cat][k] = n > 0 and n or nil + if type(n) == 'number' and n < 0 then n = nil end + new[cat][k] = n end end end return new end; __mul = function(x,n) + if n == 1 then return fab.clone(x) end local new = fab {} + if n == 0 then return new end for cat, vals in pairs(x) do new[cat] = {} local f = fields[cat].op for k,v in pairs(vals) do local num = f(v,nil,n) - new[cat][k] = num > 0 and num or nil + if type(num) == 'number' and n < 0 then n = nil end + new[cat][k] = num end end return new end; Index: mods/starlit/terrain.lua ================================================================== --- mods/starlit/terrain.lua +++ mods/starlit/terrain.lua @@ -246,11 +246,11 @@ cost = { shredPower = 3; }; }; recover_vary = function(rng, ctx) return starlit.type.fab { element = { - aluminum = rng:int(0,4); + aluminum = rng:int(0,16); potassium = rng:int(0,2); calcium = rng:int(0,2); } }; end; @@ -264,19 +264,19 @@ among = 'starlit:mineral_feldspar'; height = {-200,30}; sheetCols = {1, 16}; }; recover = starlit.type.fab { - time = { shred = 3.5; }; + time = { shred = 3.3; }; cost = { shredPower = 8; }; }; recover_vary = function(rng, ctx) return starlit.type.fab { element = { - iron = rng:int(0,4); - magnesium = rng:int(0,2); - titanium = rng:int(0,1); + iron = rng:int(0,16); + magnesium = rng:int(0,8); + titanium = rng:int(0,2); } }; end; })