Make it so that if someone fixes what they have done they get the hpp back

master
minermoder27 2013-12-23 08:33:33 +11:00
parent 3118d439bc
commit ca0be0cfa0
1 changed files with 20 additions and 0 deletions

View File

@ -5,6 +5,8 @@ honeypots = {
},
actives = {
},
digged = {
},
}
local function setpts(cnt, name)
@ -41,12 +43,28 @@ local function ondig(p, node, digger)
local priv, missing = minetest.check_player_privs(name, {honeypot=true})
if priv==false then
addpts(1, name)
honeypots.digged[#honeypots.digged + 1] = {name = name, pos = {x=p.x, y=p.y, z=p.z}, nname = node.name}
end
end
end
end
minetest.register_on_dignode(ondig)
local function onplace(p, node, placer)
local name = placer:get_player_name()
for i=1, #honeypots.digged do
local hpt = honeypots.digged[i]
if hpt.name == name and node.name == hpt.nname and vector.equals(hpt.pos, p) then
local priv, missing = minetest.check_player_privs(name, {honeypot=true})
if priv==false then
addpts(-1, name)
end
table.remove(honeypots.digged, i)
end
end
end
minetest.register_on_placenode(onplace)
local function split(inputstr, sep)
if sep == nil then
sep = "%s"
@ -161,6 +179,7 @@ local loadSettingsFromFile = function()
if table~=nil then
honeypots = table
end
honeypots.digged = {}
print("loaded honeypots")
end
end
@ -169,6 +188,7 @@ local saveSettingsToFile = function()
local worldpath = minetest.get_worldpath()
io.output(worldpath.."/honeypots.txt")
io.write(minetest.serialize(honeypots))
honeypots.digged = {}
print("saved honeypots")
end