prevent removing city block once the above condition is one

master
Juraj Vajda 2018-02-11 12:07:20 -05:00
parent c89cf47b95
commit 5c04be7837
3 changed files with 18 additions and 17 deletions

View File

@ -3,6 +3,8 @@
Remove nodes from players what are not anymore listed in the /players directory. Protector, Protector2, locked doors, locked trapdoors, protected chests, basic machines, enchantment tables, easy vending machines, city blocks and locked chest will be removed by defautlt. It's easy to edit what blocks should be removed from init.lua
Also removes new players what will leave the game without having by default: { "default:stick 1", "default:steel_ingot 1" } in the inventory.
The items can be easily modified. Player file form /players directory will be removed and (after server shutdown) also player data from auth.txt will be removed.
The items can be easily modified. Player file from /players directory will be removed and (after server shutdown) also player data from auth.txt will be removed.
After the player leaves the game with satisfied requirements (items in inventory), this player inventory will not be checked any more. So it's just for new players and only for the 1st time they have those items in invetory.
Prevents /players folder and auth.txt getting cluttered with players what only comes to the server to have a look or not really doing any work at the server.
Prevents /players folder and auth.txt getting cluttered with players what only comes to the server to have a look or not really doing any work at the server.
Tested on Linux server, for Windows you have to adjust the paths from common slash "/" to backslash "\".

View File

@ -1,6 +1,6 @@
Remove nodes from players what are not anymore listed in the /players directory. Protector, Protector2, locked doors, locked trapdoors, protected chests, basic machines, enchantment tables, easy vending machines, city blocks and locked chest will be removed by defautlt. It's easy to edit what blocks should be removed from init.lua
Also removes new players what will leave the game without having by default: { "default:stick 1", "default:steel_ingot 1" } in the inventory.
The items can be easily modified. Player file form /players directory will be removed and (after server shutdown) also player data from auth.txt will be removed.
The items can be easily modified. Player file from /players directory will be removed and (after server shutdown) also player data from auth.txt will be removed.
After the player leaves the game with satisfied requirements (items in inventory), this player inventory will not be checked any more. So it's just for new players and only for the 1st time they have those items in invetory.
Prevents /players folder and auth.txt getting cluttered with players what only comes to the server to have a look or not really doing any work at the server.

View File

@ -94,7 +94,7 @@ minetest.register_on_joinplayer(function(player)
-- set player inventory data
inv:set_size("newplayer", 1)
inv:set_stack("newplayer", 1, ItemStack("newplayer"))
-- print("adding player: "..pname.." to playerstable")
-- print("adding player: "..pname.." to newplayers")
junk_removal.playerstable[pname] = true
@ -139,7 +139,7 @@ minetest.register_on_leaveplayer(function(player, timed_out)
-- PROBLEM: deleting doesnt always work? seems minetest itself is saving stuff, so we wait a little and then we delete
minetest.after(1, function()
minetest.log("action", "[junk_removal] Removing player filename: "..pfilename)
local err, msg = os.remove(pfilename)
if err == nil then
@ -192,16 +192,16 @@ function junk_removal:remove_players_from_auth()
if not file then return end
for i, l in ipairs(lines) do
for i, l in ipairs(lines) do
file:write(l, "\n")
end
file:close()
minetest.log("action", "***************************[junk_removal]***************************")
minetest.log("action", "===========================[junk_removal]===========================")
minetest.log("action", " written players to auth.txt: "..count)
minetest.log("action", " removed players from auth.txt: "..removed)
minetest.log("action", " removed players names: "..minetest.serialize(junk_removal.removed_from_auth))
minetest.log("action", "**************************[/junk_removal]***************************")
minetest.log("action", "==========================[/junk_removal]===========================")
end
minetest.register_on_shutdown(function()
@ -210,15 +210,15 @@ minetest.register_on_shutdown(function()
-- print("k: "..k)
-- local filename = worldpath.."/players/"..k
-- local file, msg = io.open(filename, "r")
-- if not file then
-- minetest.log("warning", "[junk_removal] Error while opening player data "..filename.." error message: "..msg)
-- return
-- end
-- local content = file:read("*all")
-- file:close()
-- for _, item in ipairs(junk_removal.requirements) do
-- print("Item "..item:split(" ")[1])
-- if not string.find(content, "Item "..item:split(" ")[1]) then
@ -251,7 +251,7 @@ minetest.register_lbm({
local nname = node.name
if not nname or not meta or not owner then return end
local replace_nodename = "default:apple"
if math.random(2) == 1 then
replace_nodename = "default:leaves"
@ -259,23 +259,22 @@ minetest.register_lbm({
-- handle city block
if owner == "" and nname == "city_block:cityblock" and minetest.global_exists("city_block") then
for i, EachBlock in ipairs(city_block.blocks) do
if vector.equals(EachBlock.pos, pos) and not junk_removal.playerstable[EachBlock.owner] then
table.remove(city_block.blocks, i)
city_block:save()
-- print("removing player junk ("..nname.."): "..owner.." at "..minetest.pos_to_string(pos))
minetest.log("action", "removing player junk ("..nname.."): "..owner.." at "..minetest.pos_to_string(pos))
minetest.set_node(pos, {name = "default:apple"})
minetest.log("action", "removing player junk ("..nname.."): "..EachBlock.owner.." at "..minetest.pos_to_string(pos))
minetest.set_node(pos, {name = replace_nodename})
break
end
end
return
elseif owner == "" then
return
end
if not junk_removal.playerstable[owner] then
-- print("removing player junk ("..nname.."): "..owner.." at "..minetest.pos_to_string(pos))
minetest.log("action", "removing player junk ("..nname.."): "..owner.." at "..minetest.pos_to_string(pos))
minetest.set_node(pos, {name = replace_nodename})
end