Adapt use_texture_alpha and change node state for inactive nodes
This commit is contained in:
parent
8f73850f40
commit
7f39cceb0f
@ -61,21 +61,24 @@ local function postload_area(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function add_pos(pos, player)
|
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
|
if not in_list(lPos, pos) and (#lPos < techage.max_num_forceload_blocks or
|
||||||
creative and creative.is_enabled_for and
|
creative and creative.is_enabled_for and
|
||||||
creative.is_enabled_for(player:get_player_name())) then
|
creative.is_enabled_for(player:get_player_name())) then
|
||||||
lPos[#lPos+1] = pos
|
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
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
local function del_pos(pos, player)
|
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)
|
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
|
end
|
||||||
|
|
||||||
local function get_pos_list(player)
|
local function get_pos_list(player)
|
||||||
@ -100,7 +103,8 @@ end
|
|||||||
|
|
||||||
local function get_data(pos, player)
|
local function get_data(pos, player)
|
||||||
local pos1, pos2 = calc_area(pos)
|
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
|
local max = techage.max_num_forceload_blocks
|
||||||
return pos1, pos2, num, max
|
return pos1, pos2, num, max
|
||||||
end
|
end
|
||||||
|
@ -70,7 +70,7 @@ minetest.register_entity(":techage:position_cube", {
|
|||||||
"techage_cube_mark.png",
|
"techage_cube_mark.png",
|
||||||
"techage_cube_mark.png",
|
"techage_cube_mark.png",
|
||||||
},
|
},
|
||||||
--use_texture_alpha = true,
|
use_texture_alpha = true,
|
||||||
physical = false,
|
physical = false,
|
||||||
visual_size = {x = 1.1, y = 1.1},
|
visual_size = {x = 1.1, y = 1.1},
|
||||||
collisionbox = {-0.55,-0.55,-0.55, 0.55,0.55,0.55},
|
collisionbox = {-0.55,-0.55,-0.55, 0.55,0.55,0.55},
|
||||||
|
@ -408,6 +408,7 @@ function NodeStates:keep_running(pos, nvm, val)
|
|||||||
self:start(pos, nvm)
|
self:start(pos, nvm)
|
||||||
end
|
end
|
||||||
nvm.techage_countdown = val or 4
|
nvm.techage_countdown = val or 4
|
||||||
|
nvm.last_active = minetest.get_gametime()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Start/stop node based on button events.
|
-- 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)
|
local node = minetest.get_node(pos)
|
||||||
if node.name == "ignore" then -- unloaded node?
|
if node.name == "ignore" then -- unloaded node?
|
||||||
return "unloaded"
|
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
|
end
|
||||||
return techage.get_state_string(techage.get_nvm(pos))
|
return techage.get_state_string(techage.get_nvm(pos))
|
||||||
elseif topic == "fuel" then
|
elseif topic == "fuel" then
|
||||||
|
3
init.lua
3
init.lua
@ -39,7 +39,8 @@ elseif minetest.global_exists("safer_lua") and safer_lua.version < 1.0 then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Test MT 5.4 new string mode
|
-- 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
|
techage.NodeDef = {} -- node registration info
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ for idx,ratio in ipairs(lRatio) do
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
drawtype = "glasslike",
|
drawtype = "glasslike",
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
inventory_image = "techage_flame.png",
|
inventory_image = "techage_flame.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 13,
|
light_source = 13,
|
||||||
|
@ -35,7 +35,7 @@ techage.ironage_register_recipe({
|
|||||||
minetest.register_craftitem("techage:iron_ingot", {
|
minetest.register_craftitem("techage:iron_ingot", {
|
||||||
description = S("TA1 Iron Ingot"),
|
description = S("TA1 Iron Ingot"),
|
||||||
inventory_image = "techage_iron_ingot.png",
|
inventory_image = "techage_iron_ingot.png",
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.CLIP,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function check_protection(pos, name, text)
|
local function check_protection(pos, name, text)
|
||||||
|
@ -131,7 +131,7 @@ minetest.register_node("techage:basalt_glass", {
|
|||||||
description = S("Basalt Glass"),
|
description = S("Basalt Glass"),
|
||||||
drawtype = "glasslike_framed_optional",
|
drawtype = "glasslike_framed_optional",
|
||||||
tiles = {"techage_basalt_glass.png"},
|
tiles = {"techage_basalt_glass.png"},
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "glasslikeliquidlevel",
|
paramtype2 = "glasslikeliquidlevel",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
@ -155,7 +155,7 @@ minetest.register_node("techage:basalt_glass2", {
|
|||||||
description = S("Basalt Glass 2"),
|
description = S("Basalt Glass 2"),
|
||||||
drawtype = "glasslike_framed_optional",
|
drawtype = "glasslike_framed_optional",
|
||||||
tiles = {"techage_basalt_glass2.png"},
|
tiles = {"techage_basalt_glass2.png"},
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "glasslikeliquidlevel",
|
paramtype2 = "glasslikeliquidlevel",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
@ -185,7 +185,7 @@ minetest.register_node("techage:basalt_glass_thin", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tiles = {"techage_basalt_glass.png"},
|
tiles = {"techage_basalt_glass.png"},
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
@ -204,7 +204,7 @@ minetest.register_node("techage:basalt_glass_thin2", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tiles = {"techage_basalt_glass2.png"},
|
tiles = {"techage_basalt_glass2.png"},
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
@ -223,7 +223,7 @@ minetest.register_node("techage:basalt_glass_thin_xl", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tiles = {"techage_basalt_glass.png"},
|
tiles = {"techage_basalt_glass.png"},
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
@ -242,7 +242,7 @@ minetest.register_node("techage:basalt_glass_thin_xl2", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
tiles = {"techage_basalt_glass2.png"},
|
tiles = {"techage_basalt_glass2.png"},
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
@ -87,7 +87,7 @@ for idx,pgn in ipairs(tPgns) do
|
|||||||
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.CLIP,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
groups = {cracky=2, choppy=2, crumbly=2, techage_door = 1,
|
groups = {cracky=2, choppy=2, crumbly=2, techage_door = 1,
|
||||||
|
@ -73,7 +73,7 @@ for idx,pgn in ipairs(tPgns) do
|
|||||||
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.CLIP,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
groups = {cracky=2, choppy=2, crumbly=2, techage_door = 1,
|
groups = {cracky=2, choppy=2, crumbly=2, techage_door = 1,
|
||||||
|
@ -74,7 +74,7 @@ for idx,ratio in ipairs(lRatio) do
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.BLEND,
|
||||||
inventory_image = "techage_flame.png",
|
inventory_image = "techage_flame.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 13,
|
light_source = 13,
|
||||||
|
@ -89,7 +89,7 @@ minetest.register_tool("techage:trowel", {
|
|||||||
description = S("TechAge Trowel"),
|
description = S("TechAge Trowel"),
|
||||||
inventory_image = "techage_trowel.png",
|
inventory_image = "techage_trowel.png",
|
||||||
wield_image = "techage_trowel.png",
|
wield_image = "techage_trowel.png",
|
||||||
use_texture_alpha = true,
|
use_texture_alpha = techage.CLIP,
|
||||||
groups = {cracky=1},
|
groups = {cracky=1},
|
||||||
on_use = replace_node,
|
on_use = replace_node,
|
||||||
on_place = replace_node,
|
on_place = replace_node,
|
||||||
|
Loading…
Reference in New Issue
Block a user