Adapt use_texture_alpha and change node state for inactive nodes

This commit is contained in:
Joachim Stolberg 2021-04-24 19:24:15 +02:00
parent 8f73850f40
commit 7f39cceb0f
12 changed files with 31 additions and 20 deletions

View File

@ -61,21 +61,24 @@ local function postload_area(pos)
end
local function add_pos(pos, player)
local lPos = minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or {}
local meta = player:get_meta()
local lPos = minetest.deserialize(meta:get_string("techage_forceload_blocks")) or {}
if not in_list(lPos, pos) and (#lPos < techage.max_num_forceload_blocks or
creative and creative.is_enabled_for and
creative.is_enabled_for(player:get_player_name())) then
lPos[#lPos+1] = pos
player:set_attribute("techage_forceload_blocks", minetest.serialize(lPos))
local meta = player:get_meta()
meta:set_string("techage_forceload_blocks", minetest.serialize(lPos))
return true
end
return false
end
local function del_pos(pos, player)
local lPos = minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or {}
local meta = player:get_meta()
local lPos = minetest.deserialize(meta:get_string("techage_forceload_blocks")) or {}
lPos = remove_list_elem(lPos, pos)
player:set_attribute("techage_forceload_blocks", minetest.serialize(lPos))
player:set_string("techage_forceload_blocks", minetest.serialize(lPos))
end
local function get_pos_list(player)
@ -100,7 +103,8 @@ end
local function get_data(pos, player)
local pos1, pos2 = calc_area(pos)
local num = #minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or 0
local meta = player:get_meta()
local num = #minetest.deserialize(meta:get_string("techage_forceload_blocks")) or 0
local max = techage.max_num_forceload_blocks
return pos1, pos2, num, max
end

View File

@ -347,7 +347,7 @@ local tubing = {
end,
on_push_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos)
if meta:get_int("push_dir") == in_dir or in_dir == 5 then
if meta:get_int("push_dir") == in_dir or in_dir == 5 then
local inv = M(pos):get_inventory()
--CRD(pos).State:start_if_standby(pos) -- would need power!
return techage.put_items(inv, "main", stack)

View File

@ -70,7 +70,7 @@ minetest.register_entity(":techage:position_cube", {
"techage_cube_mark.png",
"techage_cube_mark.png",
},
--use_texture_alpha = true,
use_texture_alpha = true,
physical = false,
visual_size = {x = 1.1, y = 1.1},
collisionbox = {-0.55,-0.55,-0.55, 0.55,0.55,0.55},

View File

@ -408,6 +408,7 @@ function NodeStates:keep_running(pos, nvm, val)
self:start(pos, nvm)
end
nvm.techage_countdown = val or 4
nvm.last_active = minetest.get_gametime()
end
-- Start/stop node based on button events.
@ -450,6 +451,11 @@ function NodeStates:on_receive_message(pos, topic, payload)
local node = minetest.get_node(pos)
if node.name == "ignore" then -- unloaded node?
return "unloaded"
elseif nvm.techage_state == RUNNING then
local ttl = (nvm.last_active or 0) + 2 * (self.cycle_time or 0)
if ttl < minetest.get_gametime() then
return "inactive"
end
end
return techage.get_state_string(techage.get_nvm(pos))
elseif topic == "fuel" then

View File

@ -39,7 +39,8 @@ elseif minetest.global_exists("safer_lua") and safer_lua.version < 1.0 then
end
-- Test MT 5.4 new string mode
techage.CLIP = minetest.features.use_texture_alpha_string_modes and "clip" or true
techage.CLIP = minetest.features.use_texture_alpha_string_modes and "clip" or false
techage.BLEND = minetest.features.use_texture_alpha_string_modes and "blend" or true
techage.NodeDef = {} -- node registration info

View File

@ -133,7 +133,7 @@ for idx,ratio in ipairs(lRatio) do
end,
drawtype = "glasslike",
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
inventory_image = "techage_flame.png",
paramtype = "light",
light_source = 13,

View File

@ -35,7 +35,7 @@ techage.ironage_register_recipe({
minetest.register_craftitem("techage:iron_ingot", {
description = S("TA1 Iron Ingot"),
inventory_image = "techage_iron_ingot.png",
use_texture_alpha = true,
use_texture_alpha = techage.CLIP,
})
local function check_protection(pos, name, text)

View File

@ -131,7 +131,7 @@ minetest.register_node("techage:basalt_glass", {
description = S("Basalt Glass"),
drawtype = "glasslike_framed_optional",
tiles = {"techage_basalt_glass.png"},
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
paramtype = "light",
paramtype2 = "glasslikeliquidlevel",
sunlight_propagates = true,
@ -155,7 +155,7 @@ minetest.register_node("techage:basalt_glass2", {
description = S("Basalt Glass 2"),
drawtype = "glasslike_framed_optional",
tiles = {"techage_basalt_glass2.png"},
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
paramtype = "light",
paramtype2 = "glasslikeliquidlevel",
sunlight_propagates = true,
@ -185,7 +185,7 @@ minetest.register_node("techage:basalt_glass_thin", {
},
},
tiles = {"techage_basalt_glass.png"},
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
@ -204,7 +204,7 @@ minetest.register_node("techage:basalt_glass_thin2", {
},
},
tiles = {"techage_basalt_glass2.png"},
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
@ -223,7 +223,7 @@ minetest.register_node("techage:basalt_glass_thin_xl", {
},
},
tiles = {"techage_basalt_glass.png"},
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
@ -242,7 +242,7 @@ minetest.register_node("techage:basalt_glass_thin_xl2", {
},
},
tiles = {"techage_basalt_glass2.png"},
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,

View File

@ -87,7 +87,7 @@ for idx,pgn in ipairs(tPgns) do
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = true,
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
sounds = default.node_sound_stone_defaults(),
groups = {cracky=2, choppy=2, crumbly=2, techage_door = 1,

View File

@ -73,7 +73,7 @@ for idx,pgn in ipairs(tPgns) do
paramtype = "light",
paramtype2 = "facedir",
use_texture_alpha = true,
use_texture_alpha = techage.CLIP,
sunlight_propagates = true,
sounds = default.node_sound_stone_defaults(),
groups = {cracky=2, choppy=2, crumbly=2, techage_door = 1,

View File

@ -74,7 +74,7 @@ for idx,ratio in ipairs(lRatio) do
end
end,
use_texture_alpha = true,
use_texture_alpha = techage.BLEND,
inventory_image = "techage_flame.png",
paramtype = "light",
light_source = 13,

View File

@ -89,7 +89,7 @@ minetest.register_tool("techage:trowel", {
description = S("TechAge Trowel"),
inventory_image = "techage_trowel.png",
wield_image = "techage_trowel.png",
use_texture_alpha = true,
use_texture_alpha = techage.CLIP,
groups = {cracky=1},
on_use = replace_node,
on_place = replace_node,