Skip to content

Commit

Permalink
fix some indent issues
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jan 22, 2021
1 parent 7367f1e commit d9cd2ab
Show file tree
Hide file tree
Showing 6 changed files with 259 additions and 259 deletions.
22 changes: 11 additions & 11 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
local http = minetest.request_http_api()

if not http then
minetest.log("error", "the 'blockexchange' mod needs access to the http api!")
return
minetest.log("error", "the 'blockexchange' mod needs access to the http api!")
return
end


blockexchange = {
api = {},
api_version_major = 1,
http = http,
url = minetest.settings:get("blockexchange.url") or "https://blockexchange.minetest.land",
part_length = 16,
-- maximum usage of microseconds per second for blockexchange processes
max_cpu_micros_per_second = 50000,
pos1 = {}, -- name -> pos
pos2 = {} -- name -> pos
api = {},
api_version_major = 1,
http = http,
url = minetest.settings:get("blockexchange.url") or "https://blockexchange.minetest.land",
part_length = 16,
-- maximum usage of microseconds per second for blockexchange processes
max_cpu_micros_per_second = 50000,
pos1 = {}, -- name -> pos
pos2 = {} -- name -> pos
}

local MP = minetest.get_modpath("blockexchange")
Expand Down
12 changes: 6 additions & 6 deletions license.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
blockexchange.licenses = {}

function blockexchange.persist_licenses()
local file = io.open(minetest.get_worldpath() .. "/blockexchange_licenses","w")
local file = io.open(minetest.get_worldpath() .. "/blockexchange_licenses","w")
local json = minetest.write_json(blockexchange.licenses)
if file and file:write(json) and file:close() then
return
Expand All @@ -14,12 +14,12 @@ function blockexchange.persist_licenses()
end

function blockexchange.load_tokens()
local file = io.open(minetest.get_worldpath() .. "/blockexchange_licenses","r")
local file = io.open(minetest.get_worldpath() .. "/blockexchange_licenses","r")

if file then
local json = file:read("*a")
blockexchange.licenses = minetest.parse_json(json or "") or {}
end
if file then
local json = file:read("*a")
blockexchange.licenses = minetest.parse_json(json or "") or {}
end
end


Expand Down
100 changes: 50 additions & 50 deletions markers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,67 @@ local pos1_player_map = {}
local pos2_player_map = {}

function blockexchange.get_pos(index, playername)
if minetest.get_modpath("worldedit") then
-- use WE's positions
if index == 1 then
return worldedit.pos1[playername]
else
return worldedit.pos2[playername]
end
end
if minetest.get_modpath("worldedit") then
-- use WE's positions
if index == 1 then
return worldedit.pos1[playername]
else
return worldedit.pos2[playername]
end
end

-- use local positions
if index == 1 then
return blockexchange.pos1[playername]
else
return blockexchange.pos2[playername]
end
-- use local positions
if index == 1 then
return blockexchange.pos1[playername]
else
return blockexchange.pos2[playername]
end
end

function blockexchange.set_pos(index, playername, pos)
if minetest.get_modpath("worldedit") then
-- worldedit available, use its markers
if index == 1 then
worldedit.pos1[playername] = pos
worldedit.mark_pos1(playername);
elseif index == 2 then
worldedit.pos2[playername] = pos
worldedit.mark_pos2(playername);
end
if minetest.get_modpath("worldedit") then
-- worldedit available, use its markers
if index == 1 then
worldedit.pos1[playername] = pos
worldedit.mark_pos1(playername);
elseif index == 2 then
worldedit.pos2[playername] = pos
worldedit.mark_pos2(playername);
end

return
end
return
end

local player = minetest.get_player_by_name(playername)
if player then
local map = blockexchange.pos1
local hud_map = pos1_player_map
if index == 2 then
map = blockexchange.pos2
hud_map = pos2_player_map
end
local player = minetest.get_player_by_name(playername)
if player then
local map = blockexchange.pos1
local hud_map = pos1_player_map
if index == 2 then
map = blockexchange.pos2
hud_map = pos2_player_map
end

local pos_str = minetest.pos_to_string(pos)
minetest.chat_send_player(playername, "Position " .. index .. " set to " .. pos_str)
map[playername] = pos
local pos_str = minetest.pos_to_string(pos)
minetest.chat_send_player(playername, "Position " .. index .. " set to " .. pos_str)
map[playername] = pos

if hud_map[playername] then
player:hud_remove(hud_map[playername])
end
if hud_map[playername] then
player:hud_remove(hud_map[playername])
end

hud_map[playername] = player:hud_add({
hud_elem_type = "waypoint",
name = "Position " .. index .. " @ " .. pos_str,
text = "m",
number = 0xFF0000,
world_pos = pos
})
end
hud_map[playername] = player:hud_add({
hud_elem_type = "waypoint",
name = "Position " .. index .. " @ " .. pos_str,
text = "m",
number = 0xFF0000,
world_pos = pos
})
end
end

-- cleanup
minetest.register_on_leaveplayer(function(player)
local playername = player:get_player_name()
pos1_player_map[playername] = nil
pos2_player_map[playername] = nil
local playername = player:get_player_name()
pos1_player_map[playername] = nil
pos2_player_map[playername] = nil
end)
8 changes: 4 additions & 4 deletions privs.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

-- can do *everything*
minetest.register_privilege("blockexchange", {
description = "can use the blockexchange commands",
give_to_singleplayer = true
description = "can use the blockexchange commands",
give_to_singleplayer = true
})

-- can do only a subset of the commands
minetest.register_privilege("blockexchange_protected_upload", {
description = "can use the blockexchange upload command on self-protected areas",
give_to_singleplayer = false
description = "can use the blockexchange upload command on self-protected areas",
give_to_singleplayer = false
})
Loading

0 comments on commit d9cd2ab

Please sign in to comment.