Skip to content

Commit

Permalink
Replace more deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Jul 17, 2019
1 parent b50294d commit 0a16f11
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
12 changes: 2 additions & 10 deletions worldedit_commands/init.lua
Expand Up @@ -93,14 +93,6 @@ function worldedit.player_axis(name)
return "z", dir.z > 0 and 1 or -1
end

local function mkdir(path)
if minetest.mkdir then
minetest.mkdir(path)
else
os.execute('mkdir "' .. path .. '"')
end
end

local function check_filename(name)
return name:find("^[%w%s%^&'@{}%[%],%$=!%-#%(%)%%%.%+~_]+$") ~= nil
end
Expand Down Expand Up @@ -1115,7 +1107,7 @@ minetest.register_chatcommand("/save", {

local path = minetest.get_worldpath() .. "/schems"
-- Create directory if it does not already exist
mkdir(path)
minetest.mkdir(path)

local filename = path .. "/" .. param .. ".we"
local file, err = io.open(filename, "wb")
Expand Down Expand Up @@ -1282,7 +1274,7 @@ minetest.register_chatcommand("/mtschemcreate", {

local path = minetest.get_worldpath() .. "/schems"
-- Create directory if it does not already exist
mkdir(path)
minetest.mkdir(path)

local filename = path .. "/" .. param .. ".mts"
local ret = minetest.create_schematic(worldedit.pos1[name],
Expand Down
4 changes: 2 additions & 2 deletions worldedit_commands/mark.lua
Expand Up @@ -64,7 +64,7 @@ worldedit.mark_region = function(name)

local vec = vector.subtract(pos2, pos1)
local maxside = math.max(vec.x, math.max(vec.y, vec.z))
local limit = tonumber(minetest.setting_get("active_object_send_range_blocks")) * 16
local limit = tonumber(minetest.settings:get("active_object_send_range_blocks")) * 16
if maxside > limit * 1.5 then
-- The client likely won't be able to see the plane markers as intended anyway,
-- thus don't place them and also don't load the area into memory
Expand Down Expand Up @@ -101,7 +101,7 @@ worldedit.mark_region = function(name)
visual_size={x=sizez * 2, y=sizey * 2},
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
})
marker:setyaw(math.pi / 2)
marker:set_yaw(math.pi / 2)
marker:get_luaentity().player_name = name
table.insert(markers, marker)
end
Expand Down
8 changes: 4 additions & 4 deletions worldedit_gui/init.lua
Expand Up @@ -70,7 +70,7 @@ local get_formspec = function(name, identifier)
end

--implement worldedit.show_page(name, page) in different ways depending on the available APIs
if rawget(_G, "unified_inventory") then --unified inventory installed
if minetest.global_exists("unified_inventory") then -- unified inventory installed
local old_func = worldedit.register_gui_function
worldedit.register_gui_function = function(identifier, options)
old_func(identifier, options)
Expand Down Expand Up @@ -103,7 +103,7 @@ if rawget(_G, "unified_inventory") then --unified inventory installed
player:set_inventory_formspec(get_formspec(name, page))
end
end
elseif rawget(_G, "inventory_plus") then --inventory++ installed
elseif minetest.global_exists("inventory_plus") then -- inventory++ installed
minetest.register_on_joinplayer(function(player)
local can_worldedit = minetest.check_player_privs(player:get_player_name(), {worldedit=true})
if can_worldedit then
Expand Down Expand Up @@ -134,7 +134,7 @@ elseif rawget(_G, "inventory_plus") then --inventory++ installed
inventory_plus.set_inventory_formspec(player, get_formspec(name, page))
end
end
elseif rawget(_G, "smart_inventory") then -- smart_inventory installed
elseif minetest.global_exists("smart_inventory") then -- smart_inventory installed
-- redefinition: Update the code element on inventory page to show the we-page
function worldedit.show_page(name, page)
local state = smart_inventory.get_page_state("worldedit_gui", name)
Expand Down Expand Up @@ -183,7 +183,7 @@ elseif rawget(_G, "smart_inventory") then -- smart_inventory installed
smartfs_callback = smart_worldedit_gui_callback,
sequence = 99
})
elseif rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0.4.15)
elseif minetest.global_exists("sfinv") then -- sfinv installed
assert(sfinv.enabled)
local orig_get = sfinv.pages["sfinv:crafting"].get
sfinv.override_page("sfinv:crafting", {
Expand Down

0 comments on commit 0a16f11

Please sign in to comment.