96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
world.ecology.plants.foreach('starlit:plant-gen', {}, function(id, b)
local stageCt = #b.stages
local function stageID(n)
if n == stageCt then return id end
return id .. string.format('_stage_%s', n)
end
b.stageNodes = {}
local function regStage(n, st)
local base = {
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;
};
drop = st.drop;
_starlit = {
plant = {
id = id, stage = n;
};
recover = starlit.type.fab {
................................................................................
potassium = rng:int(0,1);
}
};
end;
};
}
if st.swap then
base.node_dig_prediction = stageID(st.swap)
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 = st.biolum; end
................................................................................
user:statDelta('health', -dmg)
end
end
end)
world.ecology.trees.foreach('starlit:tree-gen', {}, function(id, t)
local dec = {
deco_type = 'lsystem';
treedef = t.def;
}
for k,v in pairs(t.decorate) do dec[k]=v end
minetest.register_decoration(dec)
end)
minetest.register_abm {
label = "plant growth";
nodenames = {'group:plant_grow'};
chance = 15;
interval = 20;
catch_up = true;
action = function(pos, node)
local def = minetest.registered_nodes[node.name]._starlit.plant
local plant = starlit.world.ecology.plants.db[def.id]
local nextStage = plant.stageNodes[def.stage + 1]
minetest.swap_node(pos, {name=nextStage})
end;
}
|
>
>
|
>
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
>
|
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
...
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
world.ecology.plants.foreach('starlit:plant-gen', {}, function(id, b)
local stageCt = #b.stages
local function stageID(n)
if n == stageCt then return id end
return id .. string.format('_stage_%s', n)
end
b.stageNodes = {}
b.req = b.req or {}
local function regStage(n, st)
local base = {
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;
attached_node = 3;
};
drop = st.drop;
_starlit = {
plant = {
id = id, stage = n;
};
recover = starlit.type.fab {
................................................................................
potassium = rng:int(0,1);
}
};
end;
};
}
if st.swap then
base.node_dig_prediction = ""
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 = st.biolum; end
................................................................................
user:statDelta('health', -dmg)
end
end
end)
world.ecology.trees.foreach('starlit:tree-gen', {}, function(id, t)
for i,td in ipairs(t.decorate) do
local dec = {
deco_type = 'lsystem';
treedef = t.def;
}
for k,v in pairs(td) do dec[k]=v end
minetest.register_decoration(dec)
end
end)
minetest.register_abm {
label = "plant growth";
nodenames = {'group:plant_grow'};
chance = 15;
interval = 20;
catch_up = true;
action = function(pos, node)
local def = minetest.registered_nodes[node.name]._starlit.plant
-- 5 W: maximum power for UV lamps
-- 7 W: maximum solar power
local uv = (minetest.get_natural_light(pos) / 15) * 7
-- TODO compute artificial contribution
local req = lib.tbl.defaults({
uv = 3;
soil = 'soil';
temp = -10;
humid = nil;
}, def.growReq);
-- TODO check other reqs
if uv > req.uv then
local plant = starlit.world.ecology.plants.db[def.id]
local nextStage = plant.stageNodes[def.stage + 1]
minetest.swap_node(pos, {name=nextStage})
end
end;
}
|