island reset tweak. added script for top100 players and players with level < 3

master
ac-minetest 2020-03-24 14:00:07 +01:00
parent 5e7fc128f2
commit 9d39566e4c
3 changed files with 17 additions and 4 deletions

View File

@ -0,0 +1,14 @@
-- show top 100 players
if not init then init = true n=100 turn.angle(0); self.label("") local filepath = minetest.get_worldpath()..'/skyblock'; local get_data = function(name) local file,err = _G.io.open(filepath..'/'..name, 'rb') local pdata = {}; if not err then -- load from file local pdatastring = file:read("*a"); file:close() pdata = minetest.deserialize(pdatastring) or {}; if pdata.stats then local level = pdata.level; if pdata.total~=0 then level = level + pdata.completed/pdata.total end --pdata.time_played return level, pdata.id or -1 end end return 0 end local plist = minetest.get_dir_list(filepath,false); --say(serialize(plist)) local players = {} local sortf = function(a,b) return a[2]>b[2] end islands = {}; for _,pname in pairs(plist) do local stat, id = get_data(pname) if id then players[#players+1] = {pname, stat, id} islands[#islands+1]=id end end table.sort(islands); table.sort(players,sortf) local ret = {} for i = 1,math.min(#players,n) do ret[i] = string.format("%02d %15s %d",i, players[i][1] .. " " .. math.floor(players[i][2]*100)/100, players[i][3]) end
local msg = "\n TOP PRO SKYBLOCK\n\n " .. table.concat(ret,"\n ") self.label(msg)
-- get all players with level < 3
ret = {};
for i = 1,#players do
if players[i][2]<3 then ret[#ret+1] = players[i][3] end
end
book.write(1,"",table.concat(ret,",")) -- write output to book
end

View File

@ -20,4 +20,4 @@ dofile(modpath..'/skyblock.lua') -- handles quest tracking, load/save player dat
dofile(modpath..'/tutorial.lua') -- display hints for new player
print('[MOD]'.. " SKY BLOCK v2 loaded , version 12/13/2019a.")
print('[MOD]'.. " SKY BLOCK v2 loaded , version 03/24/2020a.")

View File

@ -92,9 +92,8 @@ skyblock.delete_island = function(pos, is_check) -- is_check: do we check for no
if is_check then
local count = #minetest.find_nodes_in_area({x=ppos.x-5,y=ppos.y-5,z=ppos.z-5}, {x=ppos.x+5,y=ppos.y+5,z=ppos.z+5}, {"default:dirt"});
if is_check and count==1 then delete = false end -- we have 1 dirt
--minetest.chat_send_all("#SKYBLOCK: detected " .. count .. " air near " .. ppos.x .. " " .. ppos.y .. " " .. ppos.z)
if not delete and minetest.find_node_near(ppos, 5, "default:chest") then delete = true end
if count==1 then delete = false end -- we have only 1 dirt
if not delete and minetest.find_node_near(ppos, 5, {"default:chest","default:tree","default:wood"}) then delete = true end
end
if delete then