mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-19 22:03:56 +01:00
Fix deprecation warning issue #120
This commit is contained in:
parent
c263c77b4c
commit
96355a2534
@ -75,32 +75,37 @@ local function get_node_lvm(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function add_pos(pos, player)
|
local function add_pos(pos, player)
|
||||||
local lPos = minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or {}
|
local meta = player:get_meta()
|
||||||
|
local lPos = minetest.deserialize(meta:get_string("tubelib_forceload_blocks")) or {}
|
||||||
if not in_list(lPos, pos) and #lPos < tubelib.max_num_forceload_blocks then
|
if not in_list(lPos, pos) and #lPos < tubelib.max_num_forceload_blocks then
|
||||||
lPos[#lPos+1] = pos
|
lPos[#lPos+1] = pos
|
||||||
player:set_attribute("tubelib_forceload_blocks", minetest.serialize(lPos))
|
meta:set_string("tubelib_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("tubelib_forceload_blocks")) or {}
|
local meta = player:get_meta()
|
||||||
|
local lPos = minetest.deserialize(meta:get_string("tubelib_forceload_blocks")) or {}
|
||||||
lPos = remove_list_elem(lPos, pos)
|
lPos = remove_list_elem(lPos, pos)
|
||||||
player:set_attribute("tubelib_forceload_blocks", minetest.serialize(lPos))
|
meta:set_string("tubelib_forceload_blocks", minetest.serialize(lPos))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_pos_list(player)
|
local function get_pos_list(player)
|
||||||
return minetest.deserialize(player:get_attribute("tubelib_forceload_blocks")) or {}
|
local meta = player:get_meta()
|
||||||
|
return minetest.deserialize(meta:get_string("tubelib_forceload_blocks")) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_pos_list(player, lPos)
|
local function set_pos_list(player, lPos)
|
||||||
player:set_attribute("tubelib_forceload_blocks", minetest.serialize(lPos))
|
local meta = player:get_meta()
|
||||||
|
meta:set_string("tubelib_forceload_blocks", minetest.serialize(lPos))
|
||||||
end
|
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("tubelib_forceload_blocks")) or 0
|
local meta = player:get_meta()
|
||||||
|
local num = #minetest.deserialize(meta:get_string("tubelib_forceload_blocks")) or 0
|
||||||
local max = tubelib.max_num_forceload_blocks
|
local max = tubelib.max_num_forceload_blocks
|
||||||
return pos1, pos2, num, max
|
return pos1, pos2, num, max
|
||||||
end
|
end
|
||||||
|
@ -25,19 +25,21 @@ local function join_to_string(tbl)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function reset_programmer(itemstack, user, pointed_thing)
|
local function reset_programmer(itemstack, user, pointed_thing)
|
||||||
user:set_attribute("tubelib_prog_numbers", nil)
|
local meta = user:get_meta()
|
||||||
|
meta:set_string("tubelib_prog_numbers", nil)
|
||||||
minetest.chat_send_player(user:get_player_name(), S("[Tubelib Programmer] programmer reset"))
|
minetest.chat_send_player(user:get_player_name(), S("[Tubelib Programmer] programmer reset"))
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
local function read_number(itemstack, user, pointed_thing)
|
local function read_number(itemstack, user, pointed_thing)
|
||||||
local pos = pointed_thing.under
|
local pos = pointed_thing.under
|
||||||
|
local meta = user:get_meta()
|
||||||
if pos then
|
if pos then
|
||||||
local number = tubelib.get_node_number(pos)
|
local number = tubelib.get_node_number(pos)
|
||||||
if number then
|
if number then
|
||||||
local numbers = minetest.deserialize(user:get_attribute("tubelib_prog_numbers")) or {}
|
local numbers = minetest.deserialize(meta:get_string("tubelib_prog_numbers")) or {}
|
||||||
numbers[number] = true
|
numbers[number] = true
|
||||||
user:set_attribute("tubelib_prog_numbers", minetest.serialize(numbers))
|
meta:set_string("tubelib_prog_numbers", minetest.serialize(numbers))
|
||||||
minetest.chat_send_player(user:get_player_name(), S("[Tubelib Programmer] number").." "..number.." "..S("read"))
|
minetest.chat_send_player(user:get_player_name(), S("[Tubelib Programmer] number").." "..number.." "..S("read"))
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(user:get_player_name(), S("[Tubelib Programmer] Unknown node on").." "..minetest.pos_to_string(pos))
|
minetest.chat_send_player(user:get_player_name(), S("[Tubelib Programmer] Unknown node on").." "..minetest.pos_to_string(pos))
|
||||||
@ -50,11 +52,12 @@ end
|
|||||||
|
|
||||||
local function program_numbers(itemstack, placer, pointed_thing)
|
local function program_numbers(itemstack, placer, pointed_thing)
|
||||||
local pos = pointed_thing.under
|
local pos = pointed_thing.under
|
||||||
|
local pmeta = placer:get_meta()
|
||||||
if pos then
|
if pos then
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local node_number = tubelib.get_node_number(pos)
|
local node_number = tubelib.get_node_number(pos)
|
||||||
local numbers = minetest.deserialize(placer:get_attribute("tubelib_prog_numbers")) or {}
|
local numbers = minetest.deserialize(pmeta:get_string("tubelib_prog_numbers")) or {}
|
||||||
placer:set_attribute("tubelib_prog_numbers", nil)
|
pmeta:set_string("tubelib_prog_numbers", nil)
|
||||||
local text = join_to_string(numbers)
|
local text = join_to_string(numbers)
|
||||||
local player_name = placer:get_player_name()
|
local player_name = placer:get_player_name()
|
||||||
if meta and meta:get_string("owner") ~= player_name then
|
if meta and meta:get_string("owner") ~= player_name then
|
||||||
|
Loading…
Reference in New Issue
Block a user