starlit  Diff

Differences From Artifact [d9bc181e37]:

To Artifact [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