mirror of
https://github.com/joe7575/tubelib2.git
synced 2024-08-19 21:14:22 +02:00
v1.2 'force_to_use_tubes' added
This commit is contained in:
parent
3316bed8a2
commit
b02e80c765
@ -73,3 +73,4 @@ Textures: CC0
|
|||||||
- 2019-02-09 v0.9 * storage.lua added, code partly restructured
|
- 2019-02-09 v0.9 * storage.lua added, code partly restructured
|
||||||
- 2019-02-17 v1.0 * released
|
- 2019-02-17 v1.0 * released
|
||||||
- 2019-03-02 v1.1 * API function 'switch_tube_line' added, secondary node placement bugfix
|
- 2019-03-02 v1.1 * API function 'switch_tube_line' added, secondary node placement bugfix
|
||||||
|
- 2019-04-18 v1.2 * 'force_to_use_tubes' added
|
||||||
|
@ -96,7 +96,7 @@ end
|
|||||||
function Tube:update_secondary_node(pos1, dir1, pos2, dir2)
|
function Tube:update_secondary_node(pos1, dir1, pos2, dir2)
|
||||||
local _, node = self:get_node(pos1)
|
local _, node = self:get_node(pos1)
|
||||||
if self.secondary_node_names[node.name] then
|
if self.secondary_node_names[node.name] then
|
||||||
if minetest.registered_nodes[node.name].tubelib2_on_update then
|
if (minetest.registered_nodes[node.name] or {}).tubelib2_on_update then
|
||||||
minetest.registered_nodes[node.name].tubelib2_on_update(node, pos1, dir1, pos2, Turn180Deg[dir2])
|
minetest.registered_nodes[node.name].tubelib2_on_update(node, pos1, dir1, pos2, Turn180Deg[dir2])
|
||||||
elseif self.clbk_update_secondary_node then
|
elseif self.clbk_update_secondary_node then
|
||||||
self.clbk_update_secondary_node(node, pos1, dir1, pos2, Turn180Deg[dir2])
|
self.clbk_update_secondary_node(node, pos1, dir1, pos2, Turn180Deg[dir2])
|
||||||
@ -219,7 +219,6 @@ function Tube:replace_nodes(pos1, pos2, dir1, dir2)
|
|||||||
self.clbk_after_place_tube(self:get_tube_data(pos2, dir1, dir2, 1))
|
self.clbk_after_place_tube(self:get_tube_data(pos2, dir1, dir2, 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Tube:switch_nodes(pos, dir, state)
|
function Tube:switch_nodes(pos, dir, state)
|
||||||
pos = get_pos(pos, dir)
|
pos = get_pos(pos, dir)
|
||||||
local old_dir = dir
|
local old_dir = dir
|
||||||
@ -228,7 +227,6 @@ function Tube:switch_nodes(pos, dir, state)
|
|||||||
if param2 then
|
if param2 then
|
||||||
local dir1, dir2, num_conn = self:decode_param2(pos, param2)
|
local dir1, dir2, num_conn = self:decode_param2(pos, param2)
|
||||||
self.clbk_after_place_tube(self:get_tube_data(pos, dir1, dir2, num_conn, state))
|
self.clbk_after_place_tube(self:get_tube_data(pos, dir1, dir2, num_conn, state))
|
||||||
print(S(pos), param2, dir1, dir2, num_conn)
|
|
||||||
if dir1 == Turn180Deg[old_dir] then
|
if dir1 == Turn180Deg[old_dir] then
|
||||||
pos = get_pos(pos, dir2)
|
pos = get_pos(pos, dir2)
|
||||||
old_dir = dir2
|
old_dir = dir2
|
||||||
|
@ -23,15 +23,15 @@ local function update_mod_storage()
|
|||||||
for k,v in pairs(MemStore) do
|
for k,v in pairs(MemStore) do
|
||||||
if v.used then
|
if v.used then
|
||||||
v.used = false
|
v.used = false
|
||||||
v.best_before = gametime + 10
|
v.best_before = gametime + (60 * 30) -- 30 min
|
||||||
storage:set_string(k, minetest.serialize(v))
|
storage:set_string(k, minetest.serialize(v))
|
||||||
elseif v.best_before < gametime then
|
elseif v.best_before < gametime then
|
||||||
storage:set_string(k, minetest.serialize(v))
|
storage:set_string(k, minetest.serialize(v))
|
||||||
MemStore[k] = nil -- remove from memory
|
MemStore[k] = nil -- remove from memory
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- run every minute
|
-- run every 10 minutes
|
||||||
minetest.after(60, update_mod_storage)
|
minetest.after(600, update_mod_storage)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
@ -40,7 +40,7 @@ minetest.register_on_shutdown(function()
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.after(60, update_mod_storage)
|
minetest.after(600, update_mod_storage)
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- Version for compatibility checks, see readme.md/history
|
-- Version for compatibility checks, see readme.md/history
|
||||||
tubelib2.version = 1.1
|
tubelib2.version = 1.2
|
||||||
|
|
||||||
-- for lazy programmers
|
-- for lazy programmers
|
||||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
||||||
@ -146,6 +146,7 @@ function Tube:new(attr)
|
|||||||
primary_node_names = Tbl(attr.primary_node_names or {}),
|
primary_node_names = Tbl(attr.primary_node_names or {}),
|
||||||
secondary_node_names = Tbl(attr.secondary_node_names or {}),
|
secondary_node_names = Tbl(attr.secondary_node_names or {}),
|
||||||
show_infotext = attr.show_infotext or false,
|
show_infotext = attr.show_infotext or false,
|
||||||
|
force_to_use_tubes = attr.force_to_use_tubes or false,
|
||||||
clbk_after_place_tube = attr.after_place_tube,
|
clbk_after_place_tube = attr.after_place_tube,
|
||||||
pairingList = {}, -- teleporting nodes
|
pairingList = {}, -- teleporting nodes
|
||||||
connCache = {}, -- connection cache {pos1 = {dir1 = {pos2 = pos2, dir2 = dir2},...}
|
connCache = {}, -- connection cache {pos1 = {dir1 = {pos2 = pos2, dir2 = dir2},...}
|
||||||
@ -183,8 +184,10 @@ function Tube:after_place_node(pos, dirs)
|
|||||||
update1(self, pos, dir)
|
update1(self, pos, dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if not self.force_to_use_tubes then
|
||||||
update4(self, pos, dirs)
|
update4(self, pos, dirs)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- To be called after a tube/primary node is placed.
|
-- To be called after a tube/primary node is placed.
|
||||||
-- Returns false, if placing is not allowed
|
-- Returns false, if placing is not allowed
|
||||||
@ -204,8 +207,10 @@ function Tube:after_dig_node(pos, dirs)
|
|||||||
for _,dir in ipairs(self:update_after_dig_node(pos, dirs)) do
|
for _,dir in ipairs(self:update_after_dig_node(pos, dirs)) do
|
||||||
update1(self, pos, dir)
|
update1(self, pos, dir)
|
||||||
end
|
end
|
||||||
|
if not self.force_to_use_tubes then
|
||||||
update5(self, pos, dirs)
|
update5(self, pos, dirs)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- To be called after a tube/primary node is removed.
|
-- To be called after a tube/primary node is removed.
|
||||||
function Tube:after_dig_tube(pos, oldnode)
|
function Tube:after_dig_tube(pos, oldnode)
|
||||||
|
Loading…
Reference in New Issue
Block a user