mirror of
https://github.com/minetest-mods/MoreMesecons.git
synced 2024-08-19 20:54:07 +02:00
Fix a bug for wireless
This commit is contained in:
parent
9df8c6be64
commit
b44d0d2fbc
@ -1 +1,2 @@
|
|||||||
mesecons
|
mesecons
|
||||||
|
vector_extras
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
local wireless = {}
|
local wireless = {}
|
||||||
|
local wireless_rids = {}
|
||||||
|
|
||||||
|
|
||||||
local register = function(pos)
|
local register = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local RID = vector.get_data_from_pos(wireless_rids, pos.z,pos.y,pos.x)
|
||||||
local RID = meta:get_int("RID")
|
|
||||||
if wireless[RID] == nil then
|
if wireless[RID] == nil then
|
||||||
table.insert(wireless, pos)
|
table.insert(wireless, pos)
|
||||||
meta:set_int("RID", #wireless)
|
vector.set_data_to_pos(wireless_rids, pos.z,pos.y,pos.x, #wireless)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local wireless_activate = function(pos)
|
local wireless_activate = function(pos)
|
||||||
if not minetest.registered_nodes["moremesecons_wireless:wireless"] then return end
|
if not minetest.registered_nodes["moremesecons_wireless:wireless"] then return end
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
local channel_first_wireless = nil
|
local channel_first_wireless = nil
|
||||||
|
|
||||||
for i = 1, #wireless do
|
for i = 1, #wireless do
|
||||||
@ -57,9 +57,10 @@ minetest.register_node("moremesecons_wireless:wireless", {
|
|||||||
register(pos)
|
register(pos)
|
||||||
end,
|
end,
|
||||||
on_destruct = function(pos)
|
on_destruct = function(pos)
|
||||||
local RID = minetest.get_meta(pos):get_int("RID")
|
local RID = vector.get_data_from_pos(wireless_rids, pos.z,pos.y,pos.x)
|
||||||
if RID then
|
if RID then
|
||||||
table.remove(wireless, RID)
|
table.remove(wireless, RID)
|
||||||
|
vector.remove_data_from_pos(wireless_rids, pos.z,pos.y,pos.x)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
on_receive_fields = function(pos, formname, fields, sender)
|
on_receive_fields = function(pos, formname, fields, sender)
|
||||||
|
Loading…
Reference in New Issue
Block a user