forked from minetest-mods/MoreMesecons
Fix a bug for wireless and teleporter
This commit is contained in:
parent
b44d0d2fbc
commit
71ddb8be2a
@ -1 +1,2 @@
|
||||
mesecons
|
||||
vector_extras
|
||||
|
@ -1,11 +1,12 @@
|
||||
local teleporters = {}
|
||||
local teleporters_rids = {}
|
||||
|
||||
|
||||
local register = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local RID = meta:get_int("RID")
|
||||
if teleporters[RID] == nil then
|
||||
local RID = vector.get_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x)
|
||||
if not RID then
|
||||
table.insert(teleporters, pos)
|
||||
meta:set_int("RID", #teleporters)
|
||||
vector.set_data_to_pos(teleporters_rids, pos.z,pos.y,pos.x, #teleporters)
|
||||
end
|
||||
end
|
||||
|
||||
@ -65,9 +66,10 @@ minetest.register_node("moremesecons_teleporter:teleporter", {
|
||||
register(pos)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local RID = minetest.get_meta(pos):get_int("RID")
|
||||
local RID = vector.get_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x)
|
||||
if RID then
|
||||
table.remove(teleporters, RID)
|
||||
vector.remove_data_from_pos(teleporters_rids, pos.z,pos.y,pos.x)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ local wireless_rids = {}
|
||||
|
||||
local register = function(pos)
|
||||
local RID = vector.get_data_from_pos(wireless_rids, pos.z,pos.y,pos.x)
|
||||
if wireless[RID] == nil then
|
||||
if not RID then
|
||||
table.insert(wireless, pos)
|
||||
vector.set_data_to_pos(wireless_rids, pos.z,pos.y,pos.x, #wireless)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user