Index: mods/starlit-electronics/sw.lua ================================================================== --- mods/starlit-electronics/sw.lua +++ mods/starlit-electronics/sw.lua @@ -27,11 +27,10 @@ else -- gas, liquid table.insert(charges, {id = k, mass = v}) end end end - print(dump(items)) return items, charges end return function(user, ctx) local function cleanup() @@ -53,10 +52,11 @@ end local shredTime = 1.0 local soundPitch = 1.0 -- TODO local pdraw = prop.powerDraw or 0 + if minetest.is_protected(what, user.entity:get_player_name()) then return end local node = minetest.get_node(what) local nd = minetest.registered_nodes[node.name] local elt, fab, vary if nd._starlit then fab = nd._starlit.recover or nd._starlit.fab @@ -100,25 +100,22 @@ else user.action.prog.shred = user.action.prog.shred + ctx.how.delta or 0 end --print('shred progress: ', user.action.prog.shred) if user.action.prog.shred >= shredTime then - if minetest.dig_node(what) then - --print('shred complete') - user:suitSound 'starlit-success' - if fab then - local vf = fab - if vary then - local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)] - vf = vf + vary(rng, {}) - end - local items, charges = fabToItemsAndCharges(vf) - for i, it in ipairs(items) do user:give(it) end - -- TODO give gasses, liquids + minetest.remove_node(what) + --print('shred complete') + user:suitSound 'starlit-success' + if fab then + local vf = fab + if vary then + local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)] + vf = vf + vary(rng, {}) end - else - user:suitSound 'starlit-error' + local items, charges = fabToItemsAndCharges(vf) + for i, it in ipairs(items) do user:give(it) end + -- TODO give gasses, liquids end cleanup() end elseif ctx.how.state == 'halt' then cleanup() Index: mods/starlit-scenario/init.lua ================================================================== --- mods/starlit-scenario/init.lua +++ mods/starlit-scenario/init.lua @@ -74,20 +74,21 @@ 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) + 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 - local st = starlit.item.canister.meta(can) - st.write('contents', {kind = kind, id = name, mass = mass}) - +-- 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, { Index: mods/starlit/element.lua ================================================================== --- mods/starlit/element.lua +++ mods/starlit/element.lua @@ -173,15 +173,13 @@ }); end) -local function canisterMeta(stack) - return lib.marshal.metaStore { - contents = {key = 'starlit:canister_contents', type = starlit.store.volume}; - } (stack) -end +local canisterMeta = lib.marshal.metaStore { + contents = {key = 'starlit:canister_contents', type = starlit.store.volume}; +} local function canisterDesc(stack, def) def = def or stack:get_definition()._starlit.canister local props = { {title = 'Volume', affinity = 'info', desc = lib.math.si('L', def.vol,nil,nil,2)}; @@ -198,23 +196,23 @@ }) end ]] local itemMeta = canisterMeta(stack) local e = itemMeta.read 'contents' local mass = lib.math.si('g', e.mass, nil, nil, 2) - local def, meas + local mdef, meas if e.kind == 'liquid' then - def = M.liquid.db[e.id] - local vol = lib.math.si('L', e.mass * def.composition.density, nil, nil, 2) - meas = string.format("%s %s (%s %s)", vol, def.name, e.mass, def.composition:formula()) + mdef = M.liquid.db[e.id] + local vol = lib.math.si('L', e.mass * mdef.density, nil, nil, 2) + meas = string.format("%s %s (%s %s)", vol, mdef.name, e.mass, mdef.composition:formula()) elseif e.kind == 'gas' then - def = M.gas.db[e.id] - meas = string.format("%s %s (%s)", mass, def.name, def.composition:formula()) + mdef = M.gas.db[e.id] + meas = string.format("%s %s (%s)", mass, mdef.name, mdef.composition:formula()) end local comp = def.composition table.insert(props, { title = meas; - desc = def.desc; + desc = mdef.desc; affinity = 'info'; }) end return starlit.ui.tooltip { title = def.name, desc = def.desc or 'A canister that can store a charge of gas or liquid'; @@ -248,6 +246,33 @@ }; }; }) end) -starlit.item.canister.meta = canisterMeta +function starlit.item.canister.contents(st) + local m = canisterMeta(st) + return m.read 'contents' +end + +function starlit.item.canister.update(st) + st:get_meta():set_string('description', canisterDesc(st)) +end + +function starlit.item.canister.replace(st, rec) + local m = canisterMeta(st) + m.write('contents', rec) + starlit.item.canister.update(st) +end + +function starlit.item.canister.empty(st, rec) + local m = st:get_meta() + m:set_string('starlit:canister_contents', '') + m:set_string('description', '') +end + +function starlit.item.canister.insert(st, rec) + local m = canisterMeta(st) + -- TODO + starlit.item.canister.update(st) +end + +-- starlit.item.canister.meta = canisterMeta Index: mods/starlit/fab.lua ================================================================== --- mods/starlit/fab.lua +++ mods/starlit/fab.lua @@ -84,10 +84,11 @@ local order = { 'element', 'metal', 'liquid', 'gas', 'item' } local lib = starlit.mod.lib + local fab fab = lib.class { __name = 'starlit:fab'; opClass = opClass; strClass = strClass; @@ -116,11 +117,10 @@ end) return el, em, s end; formula = function(self) - print('make formula', dump(self)) local ts,f=0 if self.element then f = {} local el, em, s = self:elementSeq() local eldb = starlit.world.material.element.db Index: mods/starlit/init.lua ================================================================== --- mods/starlit/init.lua +++ mods/starlit/init.lua @@ -349,10 +349,13 @@ return a.type ~= b.type or a.type == 'node' and vector.new(a.under) ~= vector.new(b.under) or a.type == 'object' and a.ref ~= b.ref end local function triggerPower(_, luser, point) + for k,v in pairs(starlit.activeUsers) do + print (k,v) end + print("trigger", luser, luser:get_player_name()) local user = starlit.activeUsers[luser:get_player_name()] local oldTgt = user.action.tgt user.action.tgt = point if bit.band(user.action.bits, 0x100)==0 then user.action.bits = bit.bor(user.action.bits, 0x100) @@ -369,18 +372,19 @@ end end core.noneitemdef_default.on_use = function(...) triggerPower(...) end core.noneitemdef_default.on_secondary_use = function(...) triggerPower(...) end ]] -print(dump(core.noneitemdef_default)) minetest.register_item(":", { type = "none", wield_image = "wieldhand.png", wield_scale = {x=1,y=1,z=2.5}, on_secondary_use = function(...) triggerPower(...) end; -- on_use = function(...) print'base' end; - after_use = function(...) triggerPower(...) end; + after_use = function(i,u,n,p) + if (u:is_player()) then triggerPower(i,u,p) end + end; }) minetest.register_item("starlit:_hand_dig", { type = "none", wield_image = "wieldhand.png", wield_scale = {x=1,y=1,z=2.5}, Index: mods/starlit/interfaces.lua ================================================================== --- mods/starlit/interfaces.lua +++ mods/starlit/interfaces.lua @@ -229,11 +229,11 @@ -- update the chip *wince* pgm.fd:write(pgm.file) user.entity:get_inventory():set_stack('starlit_suit_chips', pgm.chipSlot, pgm.chip) user:reconfigureSuit() - user:suitSound('starlit-configure') + user:suitSound 'starlit-configure' end return true, true end; render = function(state, user) Index: mods/starlit/terrain.lua ================================================================== --- mods/starlit/terrain.lua +++ mods/starlit/terrain.lua @@ -1,11 +1,24 @@ local T = starlit.translator local lib = starlit.mod.lib starlit.terrain = {} -local soilSounds = {} -local grassSounds = {} +local soilSounds = { + footstep = 'default-dirt-footstep'; + dig = 'default-dig-crumbly'; + dug = 'default-dug-node'; +} +local sandSounds = { + footstep = 'default-sand-footstep'; + dig = 'default-dig-crumbly'; + dug = 'default-dug-node'; +} +local grassSounds = { + footstep = 'default-grass-footstep'; + dig = 'default-dig-crumbly'; + dug = 'default-dug-node'; +} minetest.register_node('starlit:soil', { description = T 'Soil'; tiles = {'default_dirt.png'}; groups = {dirt = 1}; @@ -22,11 +35,11 @@ minetest.register_node('starlit:sand', { description = T 'Sand'; tiles = {'default_sand.png'}; groups = {dirt = 1}; drop = ''; - sounds = soilSounds; + sounds = sandSounds; _starlit = { kind = 'block'; fab = starlit.type.fab { element = { silicon = 25 } }; }; }) @@ -43,28 +56,10 @@ fab = starlit.type.fab { element = { carbon = 12 / 4 } }; }; }) function starlit.terrain.createGrass(def) - local function grassfst(i) - local nextNode = def.name - if i >= 0 then - nextNode = nextNode .. '_walk_' .. tostring(i) - end - return { - onWalk = function(pos) - minetest.set_node_at(pos, def.name .. '_walk_2'); - end; - onDecay = function(pos,delta) - minetest.set_node_at(pos, nextNode); - end; - onDestroy = function(pos) end; - fab = def.fab; - recover = def.recover; - recover_vary = def.recover_vary; - }; - end local drop = { max_items = 4; items = { { items = {'starlit:soil'}, rarity = 2; @@ -83,31 +78,16 @@ }; }; groups = {grass = 1, dirt = 1, sub_walk = 1}; drop = ''; sounds = grassSounds; - _starlit = grassfst(2); + _starlit = { + fab = def.fab; + recover = def.recover; + recover_vary = def.recover_vary; + }; }) - for i=2,0,-1 do - local opacity = tostring((i/2.0) * 255) - - minetest.register_node(def.name, { - description = def.desc; - tiles = { - def.img .. '.png^(default_footprint.png^[opacity:'..opacity..')'; - 'default_dirt.png'; - { - name = 'default_dirt.png^' .. def.img ..'_side.png'; - tileable_vertical = false; - }; - }; - groups = {grass = 1, sub_walk = 1, sub_decay = 5}; - drop = ''; - _starlit = grassfst(i-1); - sounds = grassSounds; - }) - end end starlit.terrain.createGrass { name = 'starlit:greengraze'; Index: mods/starlit/user.lua ================================================================== --- mods/starlit/user.lua +++ mods/starlit/user.lua @@ -745,11 +745,10 @@ canInteract = function(self, with) return true; -- TODO end; trigger = function(self, which, how) - --print('trigger', which, dump(how)) local p local wld = self.entity:get_wielded_item() if which == 'maneuver' then p = self.power.maneuver elseif which == 'retarget' then Index: mods/starlit/world.lua ================================================================== --- mods/starlit/world.lua +++ mods/starlit/world.lua @@ -105,10 +105,11 @@ description = b.name; drawtype = "plantlike"; tiles = { tostring(st.tex) }; paramtype = "light"; paramtype2 = "meshoptions"; + place_param2 = b.meshOpt; walkable = false; buildable_to = true; groups = { plant = 1; plant_grow = stageCt ~= n and 1 or 0; @@ -116,20 +117,35 @@ drop = st.drop; _starlit = { plant = { id = id, stage = n; }; + recover = starlit.type.fab { + time = { shred = .3; }; + cost = { shredPower = 1; }; + }; + recover_vary = function(rng, ctx) + return starlit.type.fab { + element = { + carbon = rng:int(0,1); + potassium = rng:int(0,1); + } + }; + end; }; } if st.swap then base.node_dig_prediction = stageID(st.swap) - function base.on_dig(pos, node, digger) + function base.after_dig_node(pos, node, digger) node.name = stageID(st.swap) minetest.swap_node(pos, node) return true end end + if st.biolum then + base.light_source = math.floor(st.biolum * (n/stageCt)) + end return base end for i, v in ipairs(b.stages) do local n = regStage(i, v) b.stageNodes[i] = n @@ -139,11 +155,11 @@ local dec = { deco_type = 'simple'; decoration = b.fullyGrown; height = 1; - param2 = 0; + param2 = b.meshOpt or 0; } for k,v in pairs(b.decoration) do dec[k] = v end b.decoration = minetest.register_decoration(dec) end) Index: mods/vtlib/marshal.lua ================================================================== --- mods/vtlib/marshal.lua +++ mods/vtlib/marshal.lua @@ -256,11 +256,11 @@ name = string.format("%sfixed<%s,%s,%s>", sign and 's' or 'u', bits, base, prec ); enc = function(v) - return c.enc(v) + return c.enc(v * mul) end; dec = function(s) local v = c.dec(s) return v / mul end; Index: mods/vtlib/math.lua ================================================================== --- mods/vtlib/math.lua +++ mods/vtlib/math.lua @@ -50,28 +50,28 @@ if uncommonScales or cmaj then local denom = 10^amt local vd = val/denom if prec then vd = lib.math.trim(vd, prec) end if math.abs(val) >= (10^(amt)) then - return string.format("%s %s%s", - vd, (full and pmaj or smaj), unit) + return string.format("%s%s%s", + vd, (full and (' ' .. pmaj) or smaj), unit) end end elseif math.abs(val) < 1 then if uncommonScales or cmin then local denom = 10^-amt local vd = val/denom if prec then vd = lib.math.trim(vd, prec) end if math.abs(val) <= (10^-(amt-1)) then - return string.format("%s %s%s", - vd, (full and pmin or smin), unit) + return string.format("%s%s%s", + vd, (full and (' ' .. pmin) or smin), unit) end end end end - return string.format("%s %s", val, unit) + return string.format("%s%s", val, unit) end function fn.lerp(t, a, b) return (1-t)*a + t*b end function fn.trim(fl, prec) Index: starlit.ct ================================================================== --- starlit.ct +++ starlit.ct @@ -74,5 +74,10 @@ you can select a Psi Maneuver in the Psionics panel and activate it by holding [*Aux1]. a Ritual is triggered directly from the psionics menu. as the name implies, these are complex, powerful abilities that require large amounts of Psi and time to meditate before they trigger, and any interruption will cancel the ability (though it will not restore any lost psi). the most famous Ritual is of course Conjoin Metric, which Starlit astropaths use in conjunction with powerful amplifiers to perform long-distance FTL jumps -- but without centuries of dedication to the art, the best you can hope for if you manage to learn this storied power is to move yourself a few kilometers. a Contextual ability is triggered in a specific situation, usually by interacting with a certain kind of object. Contextual abilities often require specialized equipment, to the point that many Starlit practitioners maintain their own Psionics Lab. + +## legal +starlit source code (*.lua, *.conf, *.txt, *.csd files) is released under the GNU AGPLv3. +assets (images, sounds, models, and anything else in the repo that doesn't qualify as source code) are released under the CC-BY-NC-SA 3.0 license. +sound files with the prefix `default-` are taken from Minetest Game, whose assets are available under the CC-BY-SA 3.0 license.