Adjust things to work in twilight.
- Lenses no longer produce light from sun at all; artificial light is always needed. - Grass and trees survive, don't do dual-time check. - Breeze sounds work in twilight. - Sponge drying only requires twilight, now also can happen under artificial light. - Peat to grass happens under twilight.
This commit is contained in:
parent
5b2b334fe4
commit
6db8d9fc26
@ -430,6 +430,13 @@ function nodecore.get_depth_light(y, qty)
|
||||
return qty
|
||||
end
|
||||
|
||||
nodecore.light_sun = 15
|
||||
nodecore.light_sky = math_floor(0.5 + nodecore.light_sun * nodecore.get_depth_light(0))
|
||||
|
||||
function nodecore.is_full_sun(pos)
|
||||
return minetest.get_node_light(pos) == nodecore.light_sun
|
||||
end
|
||||
|
||||
function nodecore.get_node_light(pos)
|
||||
local artificial = minetest.get_node_light(pos, 0)
|
||||
local natural = math_floor(0.5 + minetest.get_node_light(pos, 0.5)
|
||||
|
@ -28,14 +28,13 @@ local function check(pos, done, srcs)
|
||||
end
|
||||
if minetest.get_node(sp).name ~= "air" then return end
|
||||
|
||||
local light = nodecore.get_node_light(sp, 0.5)
|
||||
if light == 15 then
|
||||
if nodecore.is_full_sun(sp) then
|
||||
if sp.y <= 0 then return end
|
||||
minetest.sound_play("nc_envsound_air", {
|
||||
pos = sp,
|
||||
gain = nodecore.windiness(sp.y) / 100
|
||||
})
|
||||
elseif light < 4 then
|
||||
elseif nodecore.get_node_light(sp) < 4 then
|
||||
minetest.sound_play("nc_envsound_drip", {
|
||||
pos = sp,
|
||||
pitchvary = 0.4,
|
||||
|
@ -13,17 +13,9 @@ local function lens_check(pos, node, check)
|
||||
end
|
||||
|
||||
local fore = vector.add(pos, face.f)
|
||||
local on
|
||||
if face.f.y == 1 then
|
||||
local ll = nodecore.get_node_light(fore)
|
||||
on = ll and ll >= 14
|
||||
end
|
||||
if not on then
|
||||
local nnode = minetest.get_node(fore)
|
||||
local def = minetest.registered_items[nnode.name] or {}
|
||||
on = def.light_source and def.light_source > 4
|
||||
end
|
||||
if on then
|
||||
local nnode = minetest.get_node(fore)
|
||||
local def = minetest.registered_items[nnode.name] or {}
|
||||
if def.light_source and def.light_source > 4 then
|
||||
return modname .. ":lens_on", {face.k}
|
||||
end
|
||||
|
||||
|
@ -55,7 +55,7 @@ local function canseeface(p1, p2)
|
||||
if dsqr < 1 then return end
|
||||
local ll = nodecore.get_node_light({x = o2.x, y = o2.y + e2, z = o2.z})
|
||||
if not ll then return end
|
||||
local ld = (ll / 15 * distance)
|
||||
local ld = (ll / nodecore.light_max * distance)
|
||||
if dsqr > (ld * ld) then return end
|
||||
|
||||
-- Make sure players' eyes are inside the same fluid.
|
||||
|
@ -57,7 +57,7 @@ nodecore.register_limited_abm({
|
||||
nodenames = {modname .. ":sponge_wet"},
|
||||
action = function(pos)
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if nodecore.get_node_light(above) >= 15 and #findwater(pos) < 1 then
|
||||
if nodecore.is_full_sun(above) and #findwater(pos) < 1 then
|
||||
minetest.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = pos})
|
||||
return minetest.set_node(pos, {name = modname .. ":sponge"})
|
||||
end
|
||||
@ -72,8 +72,8 @@ nodecore.register_aism({
|
||||
action = function(stack, data)
|
||||
if data.player and (data.list ~= "main"
|
||||
or data.slot ~= data.player:get_wield_index()) then return end
|
||||
local ll = data.pos and nodecore.get_node_light(data.pos)
|
||||
if ll and ll >= 15 and #findwater(data.pos) < 1 then
|
||||
if data.pos and nodecore.is_full_sun(data.pos)
|
||||
and #findwater(data.pos) < 1 then
|
||||
minetest.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = data.pos})
|
||||
local taken = stack:take_item(1)
|
||||
taken:set_name(modname .. ":sponge")
|
||||
|
@ -35,10 +35,9 @@ local function grassable(above)
|
||||
or (def.damage_per_second and def.damage_per_second > 0)
|
||||
then return false end
|
||||
|
||||
local ln = nodecore.get_node_light(above) or 0
|
||||
if ln >= 10 then return true end
|
||||
local ld = nodecore.get_node_light(above, 0.5) or 0
|
||||
if ld >= 10 then return end
|
||||
local ln = nodecore.get_node_light(above)
|
||||
if not ln then return end
|
||||
return ln >= 10
|
||||
end
|
||||
|
||||
local grasscost = 1000
|
||||
|
@ -14,7 +14,7 @@ nodecore.register_ambiance({
|
||||
pos.y = pos.y + 1
|
||||
if pos.y <= 0 then return end
|
||||
return minetest.get_node(pos).name == "air"
|
||||
and nodecore.get_node_light(pos, 0.5) == 15
|
||||
and nodecore.is_full_sun(pos)
|
||||
and {gain = nodecore.windiness(pos.y) / 20}
|
||||
end
|
||||
})
|
||||
|
@ -49,7 +49,7 @@ end
|
||||
function nodecore.tree_growth_rate(pos)
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if minetest.get_node(above).name ~= "air" then return end
|
||||
local ll = nodecore.get_node_light(above, 0.5)
|
||||
local ll = nodecore.get_node_light(above)
|
||||
if (not ll) or (ll < 8) then return end
|
||||
for y = 2, 5 do
|
||||
local p ={x = pos.x, y = pos.y + y, z = pos.z}
|
||||
|
@ -69,8 +69,8 @@ nodecore.register_soaking_abm({
|
||||
soakcheck = function(data, pos)
|
||||
if data.total < compostcost then return end
|
||||
minetest.get_meta(pos):from_table({})
|
||||
if math_random(1, 100) == 1 and nodecore.get_node_light(
|
||||
{x = pos.x, y = pos.y + 1, z = pos.z}) == 15 then
|
||||
if math_random(1, 100) == 1 and nodecore.is_full_sun(
|
||||
{x = pos.x, y = pos.y + 1, z = pos.z}) then
|
||||
nodecore.set_loud(pos, {name = "nc_terrain:dirt_with_grass"})
|
||||
return
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user