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
|
return qty
|
||||||
end
|
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)
|
function nodecore.get_node_light(pos)
|
||||||
local artificial = minetest.get_node_light(pos, 0)
|
local artificial = minetest.get_node_light(pos, 0)
|
||||||
local natural = math_floor(0.5 + minetest.get_node_light(pos, 0.5)
|
local natural = math_floor(0.5 + minetest.get_node_light(pos, 0.5)
|
||||||
|
@ -28,14 +28,13 @@ local function check(pos, done, srcs)
|
|||||||
end
|
end
|
||||||
if minetest.get_node(sp).name ~= "air" then return end
|
if minetest.get_node(sp).name ~= "air" then return end
|
||||||
|
|
||||||
local light = nodecore.get_node_light(sp, 0.5)
|
if nodecore.is_full_sun(sp) then
|
||||||
if light == 15 then
|
|
||||||
if sp.y <= 0 then return end
|
if sp.y <= 0 then return end
|
||||||
minetest.sound_play("nc_envsound_air", {
|
minetest.sound_play("nc_envsound_air", {
|
||||||
pos = sp,
|
pos = sp,
|
||||||
gain = nodecore.windiness(sp.y) / 100
|
gain = nodecore.windiness(sp.y) / 100
|
||||||
})
|
})
|
||||||
elseif light < 4 then
|
elseif nodecore.get_node_light(sp) < 4 then
|
||||||
minetest.sound_play("nc_envsound_drip", {
|
minetest.sound_play("nc_envsound_drip", {
|
||||||
pos = sp,
|
pos = sp,
|
||||||
pitchvary = 0.4,
|
pitchvary = 0.4,
|
||||||
|
@ -13,17 +13,9 @@ local function lens_check(pos, node, check)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local fore = vector.add(pos, face.f)
|
local fore = vector.add(pos, face.f)
|
||||||
local on
|
local nnode = minetest.get_node(fore)
|
||||||
if face.f.y == 1 then
|
local def = minetest.registered_items[nnode.name] or {}
|
||||||
local ll = nodecore.get_node_light(fore)
|
if def.light_source and def.light_source > 4 then
|
||||||
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
|
|
||||||
return modname .. ":lens_on", {face.k}
|
return modname .. ":lens_on", {face.k}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ local function canseeface(p1, p2)
|
|||||||
if dsqr < 1 then return end
|
if dsqr < 1 then return end
|
||||||
local ll = nodecore.get_node_light({x = o2.x, y = o2.y + e2, z = o2.z})
|
local ll = nodecore.get_node_light({x = o2.x, y = o2.y + e2, z = o2.z})
|
||||||
if not ll then return end
|
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
|
if dsqr > (ld * ld) then return end
|
||||||
|
|
||||||
-- Make sure players' eyes are inside the same fluid.
|
-- Make sure players' eyes are inside the same fluid.
|
||||||
|
@ -57,7 +57,7 @@ nodecore.register_limited_abm({
|
|||||||
nodenames = {modname .. ":sponge_wet"},
|
nodenames = {modname .. ":sponge_wet"},
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
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})
|
minetest.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = pos})
|
||||||
return minetest.set_node(pos, {name = modname .. ":sponge"})
|
return minetest.set_node(pos, {name = modname .. ":sponge"})
|
||||||
end
|
end
|
||||||
@ -72,8 +72,8 @@ nodecore.register_aism({
|
|||||||
action = function(stack, data)
|
action = function(stack, data)
|
||||||
if data.player and (data.list ~= "main"
|
if data.player and (data.list ~= "main"
|
||||||
or data.slot ~= data.player:get_wield_index()) then return end
|
or data.slot ~= data.player:get_wield_index()) then return end
|
||||||
local ll = data.pos and nodecore.get_node_light(data.pos)
|
if data.pos and nodecore.is_full_sun(data.pos)
|
||||||
if ll and ll >= 15 and #findwater(data.pos) < 1 then
|
and #findwater(data.pos) < 1 then
|
||||||
minetest.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = data.pos})
|
minetest.sound_play("nc_api_craft_hiss", {gain = 0.02, pos = data.pos})
|
||||||
local taken = stack:take_item(1)
|
local taken = stack:take_item(1)
|
||||||
taken:set_name(modname .. ":sponge")
|
taken:set_name(modname .. ":sponge")
|
||||||
|
@ -35,10 +35,9 @@ local function grassable(above)
|
|||||||
or (def.damage_per_second and def.damage_per_second > 0)
|
or (def.damage_per_second and def.damage_per_second > 0)
|
||||||
then return false end
|
then return false end
|
||||||
|
|
||||||
local ln = nodecore.get_node_light(above) or 0
|
local ln = nodecore.get_node_light(above)
|
||||||
if ln >= 10 then return true end
|
if not ln then return end
|
||||||
local ld = nodecore.get_node_light(above, 0.5) or 0
|
return ln >= 10
|
||||||
if ld >= 10 then return end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local grasscost = 1000
|
local grasscost = 1000
|
||||||
|
@ -14,7 +14,7 @@ nodecore.register_ambiance({
|
|||||||
pos.y = pos.y + 1
|
pos.y = pos.y + 1
|
||||||
if pos.y <= 0 then return end
|
if pos.y <= 0 then return end
|
||||||
return minetest.get_node(pos).name == "air"
|
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}
|
and {gain = nodecore.windiness(pos.y) / 20}
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -49,7 +49,7 @@ end
|
|||||||
function nodecore.tree_growth_rate(pos)
|
function nodecore.tree_growth_rate(pos)
|
||||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
if minetest.get_node(above).name ~= "air" then return end
|
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
|
if (not ll) or (ll < 8) then return end
|
||||||
for y = 2, 5 do
|
for y = 2, 5 do
|
||||||
local p ={x = pos.x, y = pos.y + y, z = pos.z}
|
local p ={x = pos.x, y = pos.y + y, z = pos.z}
|
||||||
|
@ -69,8 +69,8 @@ nodecore.register_soaking_abm({
|
|||||||
soakcheck = function(data, pos)
|
soakcheck = function(data, pos)
|
||||||
if data.total < compostcost then return end
|
if data.total < compostcost then return end
|
||||||
minetest.get_meta(pos):from_table({})
|
minetest.get_meta(pos):from_table({})
|
||||||
if math_random(1, 100) == 1 and nodecore.get_node_light(
|
if math_random(1, 100) == 1 and nodecore.is_full_sun(
|
||||||
{x = pos.x, y = pos.y + 1, z = pos.z}) == 15 then
|
{x = pos.x, y = pos.y + 1, z = pos.z}) then
|
||||||
nodecore.set_loud(pos, {name = "nc_terrain:dirt_with_grass"})
|
nodecore.set_loud(pos, {name = "nc_terrain:dirt_with_grass"})
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user