starlit  Check-in [0e67c606c9]

Overview
Comment:fixes, sounds; add license info
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0e67c606c9587afd9971a06a609319ab118dd70b27b91adf54e06ca6fc648a8d
User & Date: lexi on 2024-05-01 16:25:38
Other Links: manifest | tags
Context
2024-05-02
00:22
plant growth, edibles, fixes check-in: e829ca194a user: lexi tags: trunk
2024-05-01
16:25
fixes, sounds; add license info check-in: 0e67c606c9 user: lexi tags: trunk
13:46
cleanups, fixes, begin canister rework, begin ecology check-in: a810a756ce user: lexi tags: trunk
Changes

Modified mods/starlit-electronics/sw.lua from [d777bc86b5] to [e776ef774d].

    25     25   					}
    26     26   					table.insert(items, st)
    27     27   				else -- gas, liquid
    28     28   					table.insert(charges, {id = k, mass = v})
    29     29   				end
    30     30   			end
    31     31   		end
    32         -		print(dump(items))
    33     32   		return items, charges
    34     33   	end
    35     34   
    36     35   	return function(user, ctx)
    37     36   		local function cleanup()
    38     37   			user.action.prog.shred = nil
    39     38   			if user.action.sfx.shred then
................................................................................
    51     50   			cleanup()
    52     51   			return false
    53     52   		end
    54     53   		local shredTime = 1.0
    55     54   		local soundPitch = 1.0 -- TODO
    56     55   		local pdraw = prop.powerDraw or 0
    57     56   
           57  +		if minetest.is_protected(what, user.entity:get_player_name()) then return end
    58     58   		local node = minetest.get_node(what)
    59     59   		local nd = minetest.registered_nodes[node.name]
    60     60   		local elt, fab, vary
    61     61   		if nd._starlit then
    62     62   			fab = nd._starlit.recover or nd._starlit.fab
    63     63   			vary = nd._starlit.recover_vary
    64     64   		end
................................................................................
    98     98   				})
    99     99   				user.action.fx.shred = starlit.fx.nano.shred(user, what, prop, shredTime, node)
   100    100   			else
   101    101   				user.action.prog.shred = user.action.prog.shred + ctx.how.delta or 0
   102    102   			end
   103    103   			--print('shred progress: ', user.action.prog.shred)
   104    104   			if user.action.prog.shred >= shredTime then
   105         -				if minetest.dig_node(what) then
   106         -					--print('shred complete')
   107         -					user:suitSound 'starlit-success'
   108         -					if fab then
   109         -						local vf = fab
   110         -						if vary then
   111         -							local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)]
   112         -							vf = vf + vary(rng, {})
   113         -						end
   114         -						local items, charges = fabToItemsAndCharges(vf)
   115         -						for i, it in ipairs(items) do user:give(it) end
   116         -						-- TODO give gasses, liquids
          105  +				minetest.remove_node(what)
          106  +				--print('shred complete')
          107  +				user:suitSound 'starlit-success'
          108  +				if fab then
          109  +					local vf = fab
          110  +					if vary then
          111  +						local rng = (starlit.world.seedbank+0xa891f62)[minetest.hash_node_position(what)]
          112  +						vf = vf + vary(rng, {})
   117    113   					end
   118         -				else
   119         -					user:suitSound 'starlit-error'
          114  +					local items, charges = fabToItemsAndCharges(vf)
          115  +					for i, it in ipairs(items) do user:give(it) end
          116  +					-- TODO give gasses, liquids
   120    117   				end
   121    118   				cleanup()
   122    119   			end
   123    120   		elseif ctx.how.state == 'halt' then
   124    121   			cleanup()
   125    122   		end
   126    123   		return true

Modified mods/starlit-scenario/init.lua from [2d3d2d3760] to [a141e7b70f].

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

Modified mods/starlit/element.lua from [e6ca28c621] to [4c0283cfa3].

   171    171   			};
   172    172   		};
   173    173   	});
   174    174   
   175    175   
   176    176   end)
   177    177   
   178         -local function canisterMeta(stack)
   179         -	return lib.marshal.metaStore {
   180         -		contents = {key = 'starlit:canister_contents', type = starlit.store.volume};
   181         -	} (stack)
   182         -end
          178  +local canisterMeta = lib.marshal.metaStore {
          179  +	contents = {key = 'starlit:canister_contents', type = starlit.store.volume};
          180  +}
   183    181   
   184    182   local function canisterDesc(stack, def)
   185    183   	def = def or stack:get_definition()._starlit.canister
   186    184   	local props = {
   187    185   		{title = 'Volume', affinity = 'info', desc = lib.math.si('L', def.vol,nil,nil,2)};
   188    186   	};
   189    187   	if stack then
................................................................................
   196    194   				desc = lib.math.si('g', e:get_count());
   197    195   				affinity = 'good';
   198    196   			})
   199    197   		end ]]
   200    198   		local itemMeta = canisterMeta(stack)
   201    199   		local e = itemMeta.read 'contents'
   202    200   		local mass = lib.math.si('g', e.mass, nil, nil, 2)
   203         -		local def, meas
          201  +		local mdef, meas
   204    202   		if e.kind == 'liquid' then
   205         -			def = M.liquid.db[e.id]
   206         -			local vol =  lib.math.si('L', e.mass * def.composition.density, nil, nil, 2)
   207         -			meas = string.format("%s %s (%s %s)", vol, def.name, e.mass, def.composition:formula())
          203  +			mdef = M.liquid.db[e.id]
          204  +			local vol =  lib.math.si('L', e.mass * mdef.density, nil, nil, 2)
          205  +			meas = string.format("%s %s (%s %s)", vol, mdef.name, e.mass, mdef.composition:formula())
   208    206   		elseif e.kind == 'gas' then
   209         -			def = M.gas.db[e.id]
   210         -			meas = string.format("%s %s (%s)", mass, def.name, def.composition:formula())
          207  +			mdef = M.gas.db[e.id]
          208  +			meas = string.format("%s %s (%s)", mass, mdef.name, mdef.composition:formula())
   211    209   		end
   212    210   		local comp = def.composition
   213    211   		table.insert(props, {
   214    212   			title = meas;
   215         -			desc = def.desc;
          213  +			desc = mdef.desc;
   216    214   			affinity = 'info';
   217    215   		})
   218    216   	end
   219    217   	return starlit.ui.tooltip {
   220    218   		title = def.name, desc = def.desc or 'A canister that can store a charge of gas or liquid';
   221    219   		color = lib.color(0.2,0.1,0.1);
   222    220   		props = props;
................................................................................
   246    244   					};
   247    245   				};
   248    246   			};
   249    247   		};
   250    248   	})
   251    249   end)
   252    250   
   253         -starlit.item.canister.meta = canisterMeta
          251  +function starlit.item.canister.contents(st)
          252  +	local m = canisterMeta(st)
          253  +	return m.read 'contents'
          254  +end
          255  +
          256  +function starlit.item.canister.update(st)
          257  +	st:get_meta():set_string('description', canisterDesc(st))
          258  +end
          259  +
          260  +function starlit.item.canister.replace(st, rec)
          261  +	local m = canisterMeta(st)
          262  +	m.write('contents', rec)
          263  +	starlit.item.canister.update(st)
          264  +end
          265  +
          266  +function starlit.item.canister.empty(st, rec)
          267  +	local m = st:get_meta()
          268  +	m:set_string('starlit:canister_contents', '')
          269  +	m:set_string('description', '')
          270  +end
          271  +
          272  +function starlit.item.canister.insert(st, rec)
          273  +	local m = canisterMeta(st)
          274  +	-- TODO
          275  +	starlit.item.canister.update(st)
          276  +end
          277  +
          278  +-- starlit.item.canister.meta = canisterMeta

Modified mods/starlit/fab.lua from [9968a2e2d9] to [800ac068f1].

    82     82   }
    83     83   
    84     84   local order = {
    85     85   	'element', 'metal', 'liquid', 'gas', 'item'
    86     86   }
    87     87   
    88     88   local lib = starlit.mod.lib
           89  +
    89     90   local fab fab = lib.class {
    90     91   	__name = 'starlit:fab';
    91     92   	
    92     93   	opClass = opClass;
    93     94   	strClass = strClass;
    94     95   	order = order;
    95     96   	construct = function(q) return q end;
................................................................................
   114    115   			table.sort(el, function(a,b)
   115    116   				return eldb[a].n > eldb[b].n
   116    117   			end)
   117    118   			return el, em, s
   118    119   		end;
   119    120   
   120    121   		formula = function(self)
   121         -			print('make formula', dump(self))
   122    122   			local ts,f=0
   123    123   			if self.element then
   124    124   				f = {}
   125    125   				local el, em, s = self:elementSeq()
   126    126   				local eldb = starlit.world.material.element.db
   127    127   				for i, e in ipairs(el) do
   128    128   					local sym, n = eldb[e].sym, em[e]

Modified mods/starlit/init.lua from [6f8dfbcd79] to [c40c4aaae1].

   347    347   
   348    348   local function pointChanged(a,b)
   349    349   	return a.type ~= b.type
   350    350   		or a.type == 'node'   and vector.new(a.under) ~= vector.new(b.under)
   351    351   		or a.type == 'object' and a.ref ~= b.ref 
   352    352   end
   353    353   local function triggerPower(_, luser, point)
          354  +	for k,v in pairs(starlit.activeUsers) do
          355  +	print (k,v) end
          356  +	print("trigger", luser, luser:get_player_name())
   354    357   	local user = starlit.activeUsers[luser:get_player_name()]
   355    358   	local oldTgt = user.action.tgt
   356    359   	user.action.tgt = point
   357    360   	if bit.band(user.action.bits, 0x100)==0 then
   358    361   		user.action.bits = bit.bor(user.action.bits, 0x100)
   359    362   		--return user:trigger('secondary', {state = 'prog', delta = 0})
   360    363   	elseif pointChanged(oldTgt, point) then
................................................................................
   367    370   	if not triggerPower(...) then
   368    371   		minetest.item_place(...)
   369    372   	end
   370    373   end
   371    374   core.noneitemdef_default.on_use           = function(...) triggerPower(...) end
   372    375   core.noneitemdef_default.on_secondary_use = function(...) triggerPower(...) end
   373    376   ]]
   374         -print(dump(core.noneitemdef_default))
   375    377   minetest.register_item(":", {
   376    378   	type = "none",
   377    379   	wield_image = "wieldhand.png",
   378    380   	wield_scale = {x=1,y=1,z=2.5},
   379    381   	on_secondary_use = function(...) triggerPower(...) end;
   380    382   -- 	on_use = function(...) print'base' end;
   381         -	after_use = function(...) triggerPower(...) end;
          383  +	after_use = function(i,u,n,p)
          384  +		if (u:is_player()) then triggerPower(i,u,p) end
          385  +	end;
   382    386   })
   383    387   minetest.register_item("starlit:_hand_dig", {
   384    388   	type = "none",
   385    389   	wield_image = "wieldhand.png",
   386    390   	wield_scale = {x=1,y=1,z=2.5},
   387    391   	tool_capabilities = {
   388    392   		groupcaps = {

Modified mods/starlit/interfaces.lua from [f0b5b90e43] to [5877ccf3fb].

   227    227   						table.insert(pgm.file.body.conf, {key='disable',value='yes'})
   228    228   					end
   229    229   					-- update the chip *wince*
   230    230   					pgm.fd:write(pgm.file)
   231    231   					user.entity:get_inventory():set_stack('starlit_suit_chips',
   232    232   					pgm.chipSlot, pgm.chip)
   233    233   					user:reconfigureSuit()
   234         -					user:suitSound('starlit-configure')
          234  +					user:suitSound 'starlit-configure'
   235    235   
   236    236   				end
   237    237   				return true, true
   238    238   			end;
   239    239   			render = function(state, user)
   240    240   				local suit = user:getSuit()
   241    241   				local swm

Modified mods/starlit/terrain.lua from [b5b4e3205a] to [43cb3c61b6].

     1      1   local T = starlit.translator
     2      2   local lib = starlit.mod.lib
     3      3   
     4      4   starlit.terrain = {}
     5         -local soilSounds = {}
     6         -local grassSounds = {}
            5  +local soilSounds = {
            6  +	footstep = 'default-dirt-footstep';
            7  +	dig = 'default-dig-crumbly';
            8  +	dug = 'default-dug-node';
            9  +}
           10  +local sandSounds = {
           11  +	footstep = 'default-sand-footstep';
           12  +	dig = 'default-dig-crumbly';
           13  +	dug = 'default-dug-node';
           14  +}
           15  +local grassSounds = {
           16  +	footstep = 'default-grass-footstep';
           17  +	dig = 'default-dig-crumbly';
           18  +	dug = 'default-dug-node';
           19  +}
     7     20   
     8     21   minetest.register_node('starlit:soil', {
     9     22   	description = T 'Soil';
    10     23   	tiles = {'default_dirt.png'};
    11     24   	groups = {dirt = 1};
    12     25   	drop = '';
    13     26   	sounds = soilSounds;
................................................................................
    20     33   
    21     34   
    22     35   minetest.register_node('starlit:sand', {
    23     36   	description = T 'Sand';
    24     37   	tiles = {'default_sand.png'};
    25     38   	groups = {dirt = 1};
    26     39   	drop = '';
    27         -	sounds = soilSounds;
           40  +	sounds = sandSounds;
    28     41   	_starlit = {
    29     42   		kind = 'block';
    30     43   		fab = starlit.type.fab { element = { silicon = 25 } };
    31     44   	};
    32     45   })
    33     46   minetest.register_craftitem('starlit:soil_clump', {
    34     47   	short_description = T 'Soil';
................................................................................
    41     54   	groups = {soil = 1};
    42     55   	_starlit = {
    43     56   		fab = starlit.type.fab { element = { carbon = 12 / 4 } };
    44     57   	};
    45     58   })
    46     59   
    47     60   function starlit.terrain.createGrass(def)
    48         -	local function grassfst(i)
    49         -		local nextNode = def.name
    50         -		if i >= 0 then
    51         -			nextNode = nextNode .. '_walk_' .. tostring(i)
    52         -		end
    53         -		return {
    54         -			onWalk = function(pos)
    55         -				minetest.set_node_at(pos, def.name .. '_walk_2');
    56         -			end;
    57         -			onDecay = function(pos,delta)
    58         -				minetest.set_node_at(pos, nextNode);
    59         -			end;
    60         -			onDestroy = function(pos) end;
    61         -			fab = def.fab;
    62         -			recover = def.recover;
    63         -			recover_vary = def.recover_vary;
    64         -		};
    65         -	end
    66     61   	local drop = {
    67     62   		max_items = 4;
    68     63   		items = {
    69     64   			{
    70     65   				items = {'starlit:soil'}, rarity = 2;
    71     66   				tool_groups = { 'shovel', 'trowel' };
    72     67   			};
................................................................................
    81     76   				name = 'default_dirt.png^' .. def.img ..'_side.png';
    82     77   				tileable_vertical = false;
    83     78   			};
    84     79   		};
    85     80   		groups = {grass = 1, dirt = 1, sub_walk = 1};
    86     81   		drop = '';
    87     82   		sounds = grassSounds;
    88         -		_starlit = grassfst(2);
           83  +		_starlit = {
           84  +			fab = def.fab;
           85  +			recover = def.recover;
           86  +			recover_vary = def.recover_vary;
           87  +		};
    89     88   	})
    90         -	for i=2,0,-1 do
    91         -		local opacity = tostring((i/2.0) * 255)
    92         -
    93         -		minetest.register_node(def.name, {
    94         -			description = def.desc;
    95         -			tiles = {
    96         -				def.img .. '.png^(default_footprint.png^[opacity:'..opacity..')';
    97         -				'default_dirt.png';
    98         -				{
    99         -					name = 'default_dirt.png^' .. def.img ..'_side.png';
   100         -					tileable_vertical = false;
   101         -				};
   102         -			};
   103         -			groups = {grass = 1, sub_walk = 1, sub_decay = 5};
   104         -			drop = '';
   105         -			_starlit = grassfst(i-1);
   106         -			sounds = grassSounds;
   107         -		})
   108         -	end
   109     89   end
   110     90   
   111     91   
   112     92   starlit.terrain.createGrass {
   113     93   	name = 'starlit:greengraze';
   114     94   	desc = T 'Greengraze';
   115     95   	img = 'default_grass';

Modified mods/starlit/user.lua from [43bf528964] to [a0e5424f99].

   743    743   		end;
   744    744   
   745    745   		canInteract = function(self, with)
   746    746   			return true; -- TODO
   747    747   		end;
   748    748   
   749    749   		trigger = function(self, which, how)
   750         -			--print('trigger', which, dump(how))
   751    750   			local p
   752    751   			local wld = self.entity:get_wielded_item()
   753    752   			if which == 'maneuver' then
   754    753   				p = self.power.maneuver
   755    754   			elseif which == 'retarget' then
   756    755   				self.action.prog = {}
   757    756   			elseif wld and not wld:is_empty() then

Modified mods/starlit/world.lua from [d9bc181e37] to [c6867ae3a2].

   103    103   	local function regStage(n, st)
   104    104   		local base = {
   105    105   			description = b.name;
   106    106   			drawtype = "plantlike";
   107    107   			tiles = { tostring(st.tex) };
   108    108   			paramtype = "light";
   109    109   			paramtype2 = "meshoptions";
          110  +			place_param2 = b.meshOpt;
   110    111   			walkable = false;
   111    112   			buildable_to = true;
   112    113   			groups = {
   113    114   				plant = 1;
   114    115   				plant_grow = stageCt ~= n and 1 or 0;
   115    116   			};
   116    117   			drop = st.drop;
   117    118   			_starlit = {
   118    119   				plant = {
   119    120   					id = id, stage = n;
   120    121   				};
          122  +				recover = starlit.type.fab {
          123  +					time = { shred = .3; };
          124  +					cost = { shredPower = 1; };
          125  +				};
          126  +				recover_vary = function(rng, ctx)
          127  +					return starlit.type.fab {
          128  +						element = {
          129  +							carbon    = rng:int(0,1);
          130  +							potassium = rng:int(0,1);
          131  +						}
          132  +					};
          133  +				end;
   121    134   			};
   122    135   		}
   123    136   		if st.swap then
   124    137   			base.node_dig_prediction = stageID(st.swap)
   125         -			function base.on_dig(pos, node, digger)
          138  +			function base.after_dig_node(pos, node, digger)
   126    139   				node.name = stageID(st.swap)
   127    140   				minetest.swap_node(pos, node)
   128    141   				return true
   129    142   			end
   130    143   		end
          144  +		if st.biolum then
          145  +			base.light_source = math.floor(st.biolum * (n/stageCt))
          146  +		end
   131    147   		return base
   132    148   	end
   133    149   	for i, v in ipairs(b.stages) do
   134    150   		local n = regStage(i, v)
   135    151   		b.stageNodes[i] = n
   136    152   		minetest.register_node(stageID(i), n)
   137    153   	end
   138    154   	b.fullyGrown = stageID(stageCt)
   139    155   
   140    156   	local dec = {
   141    157   		deco_type = 'simple';
   142    158   		decoration = b.fullyGrown;
   143    159   		height = 1;
   144         -		param2 = 0;
          160  +		param2 = b.meshOpt or 0;
   145    161   	}
   146    162   	for k,v in pairs(b.decoration) do dec[k] = v end
   147    163   	b.decoration = minetest.register_decoration(dec)
   148    164   end)
   149    165   
   150    166   local toward = lib.math.toward
   151    167   local hfinterval = 1.5

Modified mods/vtlib/marshal.lua from [670a4be42e] to [500f446f0a].

   254    254   	return {
   255    255   		sz = c.sz;
   256    256   		name = string.format("%sfixed<%s,%s,%s>",
   257    257   			sign and 's' or 'u',
   258    258   			bits, base, prec
   259    259   		);
   260    260   		enc = function(v)
   261         -			return c.enc(v)
          261  +			return c.enc(v * mul)
   262    262   		end;
   263    263   		dec = function(s)
   264    264   			local v = c.dec(s)
   265    265   			return v / mul
   266    266   		end;
   267    267   	}
   268    268   end

Modified mods/vtlib/math.lua from [988785061c] to [9f5dd95326].

    48     48   
    49     49   		if math.abs(val) > 1 then
    50     50   			if uncommonScales or cmaj then
    51     51   				local denom = 10^amt
    52     52   				local vd = val/denom
    53     53   				if prec then vd = lib.math.trim(vd, prec) end
    54     54   				if math.abs(val) >= (10^(amt)) then
    55         -					return string.format("%s %s%s",
    56         -						vd, (full and pmaj or smaj), unit)
           55  +					return string.format("%s%s%s",
           56  +						vd, (full and (' ' .. pmaj) or smaj), unit)
    57     57   				end
    58     58   			end
    59     59   		elseif math.abs(val) < 1 then
    60     60   			if uncommonScales or cmin then
    61     61   				local denom = 10^-amt
    62     62   				local vd = val/denom
    63     63   				if prec then vd = lib.math.trim(vd, prec) end
    64     64   				if math.abs(val) <= (10^-(amt-1)) then
    65         -					return string.format("%s %s%s",
    66         -						vd, (full and pmin or smin), unit)
           65  +					return string.format("%s%s%s",
           66  +						vd, (full and (' ' .. pmin) or smin), unit)
    67     67   				end
    68     68   			end
    69     69   		end
    70     70   	end
    71     71   
    72         -	return string.format("%s %s", val, unit)
           72  +	return string.format("%s%s", val, unit)
    73     73   end
    74     74   
    75     75   function fn.lerp(t, a, b) return (1-t)*a + t*b end
    76     76   
    77     77   function fn.trim(fl, prec)
    78     78   	local fac = 10^prec
    79     79   	return math.floor(fl * fac) / fac

Modified starlit.ct from [5320fb7a47] to [3827ce4fcb].

    72     72   you can assign two Manual abilities at any given time and access them with the mouse buttons in Psionics mode.
    73     73   
    74     74   you can select a Psi Maneuver in the Psionics panel and activate it by holding [*Aux1].
    75     75   
    76     76   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.
    77     77   
    78     78   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.
           79  +
           80  +## legal
           81  +starlit source code (*.lua, *.conf, *.txt, *.csd files) is released under the GNU AGPLv3.
           82  +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.
           83  +sound files with the prefix `default-` are taken from Minetest Game, whose assets are available under the CC-BY-SA 3.0 license.