forked from mtcontrib/pipeworks
Replace minetest
namespace with core
(#158)
Co-authored-by: SX <50966843+S-S-X@users.noreply.github.com>
This commit is contained in:
@ -5,19 +5,19 @@ pipeworks.luaentity = luaentity
|
||||
|
||||
luaentity.registered_entities = {}
|
||||
|
||||
local filename = minetest.get_worldpath().."/luaentities"
|
||||
local filename = core.get_worldpath().."/luaentities"
|
||||
local function read_file()
|
||||
local f = io.open(filename, "r")
|
||||
if f == nil then return {} end
|
||||
local t = f:read("*all")
|
||||
f:close()
|
||||
if t == "" or t == nil then return {} end
|
||||
return minetest.deserialize(t) or {}
|
||||
return core.deserialize(t) or {}
|
||||
end
|
||||
|
||||
local function write_file(tbl)
|
||||
local f = io.open(filename, "w")
|
||||
f:write(minetest.serialize(tbl))
|
||||
f:write(core.serialize(tbl))
|
||||
f:close()
|
||||
end
|
||||
|
||||
@ -64,7 +64,7 @@ local function write_entities()
|
||||
write_file(luaentity.entities)
|
||||
end
|
||||
|
||||
minetest.register_on_shutdown(write_entities)
|
||||
core.register_on_shutdown(write_entities)
|
||||
luaentity.entities_index = 0
|
||||
|
||||
local move_entities_globalstep_part1
|
||||
@ -80,11 +80,11 @@ if pipeworks.use_real_entities then
|
||||
end
|
||||
|
||||
move_entities_globalstep_part1 = function(dtime)
|
||||
local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
|
||||
local active_block_range = tonumber(core.settings:get("active_block_range")) or 2
|
||||
for key in pairs(active_blocks) do
|
||||
active_blocks[key] = nil
|
||||
end
|
||||
for _, player in ipairs(minetest.get_connected_players()) do
|
||||
for _, player in ipairs(core.get_connected_players()) do
|
||||
local blockpos = get_blockpos(player:get_pos())
|
||||
local minpx = blockpos.x - active_block_range
|
||||
local minpy = blockpos.y - active_block_range
|
||||
@ -97,7 +97,7 @@ if pipeworks.use_real_entities then
|
||||
for y = minpy, maxpy do
|
||||
for z = minpz, maxpz do
|
||||
local pos = {x = x, y = y, z = z}
|
||||
active_blocks[minetest.hash_node_position(pos)] = true
|
||||
active_blocks[core.hash_node_position(pos)] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -106,7 +106,7 @@ if pipeworks.use_real_entities then
|
||||
end
|
||||
|
||||
is_active = function(pos)
|
||||
return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
|
||||
return active_blocks[core.hash_node_position(get_blockpos(pos))] ~= nil
|
||||
end
|
||||
else
|
||||
move_entities_globalstep_part1 = function()
|
||||
@ -168,7 +168,7 @@ local entitydef_default = {
|
||||
if not is_active(entity_pos) then
|
||||
return
|
||||
end
|
||||
local object = minetest.add_entity(entity_pos, entity.name)
|
||||
local object = core.add_entity(entity_pos, entity.name)
|
||||
if not object then
|
||||
return
|
||||
end
|
||||
@ -290,7 +290,7 @@ end
|
||||
|
||||
function luaentity.add_entity(pos, name)
|
||||
if not luaentity.entities then
|
||||
minetest.after(0, luaentity.add_entity, vector.new(pos), name)
|
||||
core.after(0, luaentity.add_entity, vector.new(pos), name)
|
||||
return
|
||||
end
|
||||
local index = luaentity.entities_index
|
||||
@ -399,7 +399,7 @@ local dtime_accum = 0
|
||||
local dtime_delayed = 0
|
||||
local skip_update = false
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
core.register_globalstep(function(dtime)
|
||||
if dtime >= 0.2 and dtime_delayed < 1 then
|
||||
-- Reduce activity when the server is lagging.
|
||||
skip_update = true
|
||||
|
Reference in New Issue
Block a user