starlit  Check-in [9d4ddb7701]

Overview
Comment:fix colors, add grass
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9d4ddb770122e23390fd1e3064583c984348924cc57ecfbb66e2d2f6d8aef5c6
User & Date: lexi on 2024-05-04 02:18:17
Other Links: manifest | tags
Context
2024-05-04
22:41
add beginnings of matter compiler UI, check in missing files check-in: 0e7832a24c user: lexi tags: trunk
02:18
fix colors, add grass check-in: 9d4ddb7701 user: lexi tags: trunk
2024-05-03
21:00
add primitive thermal hazard LEDs; further documentation check-in: 511814aace user: lexi tags: trunk
Changes

Modified mods/starlit-eco/plants.lua from [798314c789] to [c84dadb0c1].

    10     10   	a = strdrop(a)
    11     11   	b = strdrop(b)
    12     12   	return {
    13     13   		max_items = a.max_items + b.max_items;
    14     14   		items = lib.tbl.append(a.items, b.items);
    15     15   	}
    16     16   end
           17  +
           18  +local function simpleDrop(rarity, what)
           19  +	return {
           20  +		max_items = 1;
           21  +		items = {
           22  +			{rarity = rarity, items = {what}};
           23  +		};
           24  +	};
           25  +end
           26  +
           27  +local function biomeGrass(biomes, seed)
           28  +	return function(def)
           29  +		world.ecology.plants.link(def.id, {
           30  +			stages = {{
           31  +				tex = def.tex;
           32  +				drop = simpleDrop(4, 'starlit_eco:fiber');
           33  +			}};
           34  +			decoration = {
           35  +				deco_type = 'simple';
           36  +				place_on = 'starlit:greengraze';
           37  +				biomes = biomes;
           38  +				noise_params = {
           39  +					offset = def.ofs;
           40  +					spread = vector.new(10,10,10);
           41  +					seed = seed;
           42  +					octaves = 3;
           43  +				};
           44  +			}
           45  +		})
           46  +	end
           47  +end
           48  +
           49  +do gg = biomeGrass({'starlit:steppe', 'starlit:forest'}, 0x5e8fa0)
           50  +	gg {
           51  +		id = 'starlit_eco:greengraze_low';
           52  +		name = 'Low Greengraze';
           53  +		tex = 'starlit-eco-plant-grass-sprig.png';
           54  +		ofs = -.3;
           55  +	}
           56  +	gg {
           57  +		id = 'starlit_eco:greengraze_high';
           58  +		name = 'High Greengraze';
           59  +		tex = 'starlit-eco-plant-grass-high.png';
           60  +		ofs = -.5;
           61  +	}
           62  +	gg {
           63  +		id = 'starlit_eco:greengraze_tall';
           64  +		name = 'Tall Greengraze';
           65  +		tex = 'starlit-eco-plant-grass-tall.png';
           66  +		ofs = -.7;
           67  +	}
           68  +end
           69  +
    17     70   local function stalkPlant(def)
    18     71   	local function stage(s, drops, swap)
    19     72   		return {
    20         -			tex = lib.image(string.format('starlit-eco-plant-stalk%s.png',s)):shift(def.color);
           73  +			tex = lib.image(string.format('starlit-eco-plant-stalk%s.png',s)):colorize(def.color);
    21     74   			drop = drops;
    22     75   			swap = swap;
    23     76   		}
    24     77   	end
    25     78   	local function plantMatter(opts)
    26     79   		local dps = {
    27     80   			seed = def.seed;
................................................................................
    64    117   		name = def.name;
    65    118   		stages = stages;
    66    119   		decoration = def.decoration;
    67    120   		meshOpt = 3;
    68    121   	})
    69    122   end
    70    123   
    71         -local function simpleDrop(rarity, what)
    72         -	return {
    73         -		max_items = 1;
    74         -		items = {
    75         -			{rarity = rarity, items = {what}};
    76         -		};
    77         -	};
    78         -end
    79    124   
    80    125   function stalkPlantAuto(def)
    81    126   	local id = def.id
    82    127   	local id_berries = def.id .. '_berry'
    83    128   	local id_seed = def.id .. '_seed'
    84    129   
    85    130   	local p = lib.tbl.proto({}, def)
................................................................................
   121    166   	biolum = 5;
   122    167   	leaf = {
   123    168   		color = lib.color(.6, .8, .8);
   124    169   		drop = simpleDrop(2, 'starlit_eco:moondrop_petal');
   125    170   	};
   126    171   	berries = {
   127    172   		desc = "The fruits of the moondrop are not very nutritious, but their peculiar sweet-sour flavor profile makes them one of Farthest Shadow's great delicacies";
   128         -		color = lib.color(1,0,.4);
          173  +		color = lib.color(.5,0,.1);
   129    174   		mass = 1;
   130    175   		impact = starlit.type.impact {
   131    176   			nutrition = 10;
   132    177   			hydration = 0.05;
   133    178   			taste = 1*60;
   134    179   		};
   135    180   	};
................................................................................
   143    188   }
   144    189   
   145    190   stalkPlantAuto {
   146    191   	id = 'starlit_eco:dustrose';
   147    192   	name = "Dust Rose";
   148    193   	fiber = simpleDrop(2, 'starlit_eco:fiber');
   149    194   	seed = {};
   150         -	color = lib.color(.3, .1, .2);
          195  +	color = lib.color(.9, .8, .3);
   151    196   	leaf = {
   152    197   		color = lib.color(.7, .4, .8);
   153    198   		drop = simpleDrop(2, 'starlit_eco:dustrose_petal');
   154    199   	};
   155    200   	decoration = {
   156    201   		place_on = 'starlit:greengraze';
   157    202   		fill_ratio = 0.03;

Modified mods/starlit-eco/trees.lua from [a9d406a1cb] to [d43bf4970e].

    57     57   	_starlit = woodProps{};
    58     58   })
    59     59   
    60     60   
    61     61   starlit.item.food.link('starlit_eco:lambent_pine_berry', {
    62     62   	name = 'Lambent Pine Berry';
    63     63   	desc = 'Though packed with human-compatible nutrients, these berries are almost painfully sour when eaten raw.';
    64         -	tex = lib.image('starlit-eco-plant-berry-bunch.png'):shift{hue=180,sat=-30,lum=30}:render();
           64  +	tex = lib.image('starlit-eco-plant-berry-bunch.png'):shift{hue=180,sat=-.3,lum=3}:render();
    65     65   	impact = starlit.type.impact {
    66     66   		nutrition = 150;
    67     67   		taste = -2 * 60;
    68     68   	};
    69     69   	mass = 2;
    70     70   })
    71     71   
    72     72   starlit.item.seed.link('starlit_eco:lambent_pine_seed', {
    73     73   	name = 'Lambent Pine Seed';
    74         -	tex = lib.image('starlit-eco-plant-seeds.png'):shift{hue=150, sat=-50, lum=80}:render();
           74  +	tex = lib.image('starlit-eco-plant-seeds.png'):shift{hue=150, sat=-.5, lum=.8}:render();
    75     75   	grow = {kind = 'tree', id = 'starlit_eco:lambent_pine'};
    76     76   })
    77     77   
    78     78   minetest.register_node('starlit_eco:lambent_pine_bulb', {
    79     79   	description = 'Lambent Pine Bulb';
    80     80   	drawtype = 'nodebox';
    81     81   	connects_to = {'starlit_eco:lambent_pine_needles'};

Modified mods/starlit/user.lua from [7074af2318] to [b2784a81d4].

   243    243   				number = 0xffffff;
   244    244   			}
   245    245   			m.destroy = function()
   246    246   				luser:hud_remove(m.meter)
   247    247   				luser:hud_remove(m.readout)
   248    248   			end
   249    249   			m.update = function()
   250         -				local v,txt,color,txtcolor = def.measure(luser,def)
          250  +				local v,txt,color,txtcolor,hl,hlcolor = def.measure(luser,def)
   251    251   				v = math.max(0, math.min(1, v))
   252    252   				local n = math.floor(v*16) + 1
   253         -				local img = hudAdjustBacklight(lib.image('starlit-ui-meter.png'))
   254         -					:colorize(color or def.color)
          253  +				local function adjust(img)
          254  +					return hudAdjustBacklight(lib.image(img)):shift(color or def.color)
          255  +				end
          256  +				local img = adjust 'starlit-ui-meter.png'
   255    257   				if def.flipX then
   256    258   					img = img:transform 'FX'
   257    259   				end
   258    260   				img = img:render()
   259    261   				img = img .. '^[verticalframe:17:' .. tostring(17 - n)
          262  +				if hl then
          263  +					hl = math.floor(hl*16) + 1
          264  +					local hi = hudAdjustBacklight(lib.image 'starlit-ui-meter-hl.png')
          265  +						:shift(hlcolor or def.color)
          266  +						:render()
          267  +					hi = hi .. '^[verticalframe:17:' .. tostring(17 - hl)
          268  +					img = string.format('%s^(%s)', img, hi)
          269  +				end
          270  +				img = string.format('%s^(%s)', img, adjust 'starlit-ui-meter-readout.png':render())
   260    271   				luser:hud_change(m.meter, 'text', img)
   261    272   				if txt then
   262    273   					luser:hud_change(m.readout, 'text', txt)
   263    274   				end
   264    275   				if txtcolor then
   265    276   					luser:hud_change(m.readout, 'number', txtcolor:hex())
   266    277   				end
................................................................................
   385    396   			self.hud.elt.temp = self:attachMeter {
   386    397   				name = 'temp';
   387    398   				align = {x=1, y=-1};
   388    399   				pos = {x=0, y=1};
   389    400   				ofs = {x=20, y=-20};
   390    401   				measure = function(user)
   391    402   					local warm = self:effectiveStat 'warmth'
   392         -					local n, color if warm < 0 then
   393         -						n = math.min(100, -warm)
   394         -						color = lib.color(0.1,0.3,1):lerp(lib.color(0.7, 1, 1), math.min(1, n/50))
   395         -					else
   396         -						n = math.min(100,  warm)
   397         -						color = lib.color(0.1,0.3,1):lerp(lib.color(1, 0, 0), math.min(1, n/50))
          403  +					local exposure = starlit.world.climate.temp(self.entity:get_pos())
          404  +
          405  +					local function tempVals(warm, br)
          406  +						local n if warm < 0 then
          407  +							n = math.min(100, -warm)
          408  +-- 							color = lib.color(0.1,0.3,1):lerp(lib.color(0.7, 1, 1), math.min(1, n/50))
          409  +						else
          410  +							n = math.min(100,  warm)
          411  +-- 							color = lib.color(0.1,0.3,1):lerp(lib.color(1, 0, 0), math.min(1, n/50))
          412  +						end
          413  +						local hue = lib.math.gradient({
          414  +							205, 264, 281, 360 + 17
          415  +						}, (warm + 50) / 100) % 360
          416  +						return {hue=hue, sat = 1, lum = br}, n
   398    417   					end
          418  +
          419  +					local color, n = tempVals(warm,0)
          420  +					local hlcolor, hl = tempVals(exposure,.5)
   399    421   					local txt = string.format("%s°", math.floor(warm))
   400         -					return (n/50), txt, color
          422  +					return (n/50), txt, color, nil, (hl/50), hlcolor
   401    423   				end;
   402    424   			}
   403    425   			self.hud.elt.geiger = self:attachMeter {
   404    426   				name = 'geiger';
   405    427   				align = {x=-1, y=-1};
   406    428   				pos = {x=1, y=1};
   407    429   				ofs = {x=-20, y=-20};
................................................................................
   512    534   			local s = self:getSuit()
   513    535   			if s:powerState() == 'off' then return false end
   514    536   			local sd = s:def()
   515    537   			local w = self:effectiveStat 'warmth'
   516    538   			local kappa = starlit.constant.heat.thermalConductivity
   517    539   			local insul = sd.temp.insulation
   518    540   			local dt = (kappa * (1-insul)) * (t - w)
   519         -			print('dt', dt, dump(sd.temp))
   520    541   			if (dt > 0 and          dt  > sd.temp.maxCool)
   521    542   			or (dt < 0 and math.abs(dt) > sd.temp.maxHeat) then return false end
   522    543   			return true
   523    544   		end;
   524    545   		-- will exposure to temperature t cause the player eventual harm
   525    546   		tempHazard = function(self, t)
   526    547   			local tr = self:species().tempRange.survivable

Modified mods/starlit/world.lua from [a2ac450e1c] to [5368f81f41].

     7      7   	local day = days % world.planet.orbit;
     8      8   	return {
     9      9   		year = year, day = day;
    10     10   		season = day / world.planet.orbit + 0.5; -- begin summer
    11     11   	}
    12     12   end
    13     13   local lerp = lib.math.lerp
    14         -
    15         -local function gradient(grad, pos)
    16         -	local n = #grad
    17         -	if n == 1 then return grad[1] end
    18         -	local op = pos*(n-1)
    19         -	local idx = math.floor(op)
    20         -	local t = op-idx
    21         -	return lerp(t, grad[1 + idx], grad[2 + idx])
    22         -end
           14  +local gradient = lib.math.gradient
    23     15   
    24     16   local altitudeCooling = 10 / 100
    25         -local heatRange = {min = -70, max = 70} -- translate mt temps into real temps
           17  +local heatRange = {min = -50, max = 50} -- translate mt temps into real temps
    26     18   
    27     19   -- this function provides the basis for temperature calculation,
    28     20   -- which is performed by adding this value to the ambient temperature,
    29     21   -- determined by querying nearby group:heatSource items in accordance
    30     22   -- with the inverse-square law
    31     23   function world.climate.eval(pos, tod, season)
    32     24   	local data = minetest.get_biome_data(pos)
    33     25   	local biome = world.ecology.biomes.db[minetest.get_biome_name(data.biome)]
           26  +-- 	print('climate:', dump(data))
    34     27   	local heat, humid = data.heat, data.humidity
    35     28   	heat = lerp(heat/100, heatRange.min, heatRange.max)
    36     29   	tod = tod or minetest.get_timeofday()
    37     30   	heat = lerp(math.abs(tod - 0.5)*2, heat, heat + biome.nightTempDelta)
    38     31   -- 	print('base heat', heat)
    39     32   
    40     33   	local td = world.date()

Modified mods/vtlib/image.lua from [9575362639] to [33182947e9].

    82     82   					color = lib.color(color)
    83     83   				end
    84     84   				color = color:to_hsl()
    85     85   			end
    86     86   			return image.change(self, {
    87     87   				fx = lib.tbl.append(self.fx, {
    88     88   					string.format('hsl:%s:%s:%s',
    89         -						color.hue, color.sat, color.lum)
           89  +						color.hue, color.sat*100, color.lum*100)
    90     90   				})
    91     91   			})
    92     92   		end;
    93     93   
    94     94   		rehue = function(self, hue)
    95     95   			return self.shift{hue=hue, sat=0, lum=0}
    96     96   		end;

Modified mods/vtlib/math.lua from [54a7601a0f] to [3edc02f291].

    69     69   		end
    70     70   	end
    71     71   
    72     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  +function fn.gradient(grad, pos)
           77  +	local n = #grad
           78  +	if n == 1 then return grad[1] end
           79  +	local op = pos*(n-1)
           80  +	local idx = math.floor(op)
           81  +	local t = op-idx
           82  +	return fn.lerp(t, grad[1 + idx], grad[2 + idx])
           83  +end
    76     84   
    77     85   function fn.trim(fl, prec)
    78     86   	local fac = 10^prec
    79     87   	return math.floor(fl * fac) / fac
    80     88   end
    81     89   
    82     90   function fn.sign(v)