Compare commits
5 Commits
dbfd2cf49c
...
f1019d13a6
Author | SHA1 | Date |
---|---|---|
TalkLounge | f1019d13a6 | |
TalkLounge | 3b6c354dd2 | |
TalkLounge | e9287e844a | |
mckaygerhard | abd1706571 | |
TalkLounge | 3b4551c9e8 |
22
init.lua
22
init.lua
|
@ -2,6 +2,8 @@
|
|||
-- =================
|
||||
-- See README.md for licensing and other information.
|
||||
|
||||
local timeout_message = minetest.settings and tonumber(minetest.settings:get("adblock_timeout_message")) or 10
|
||||
|
||||
local adusers = {}
|
||||
|
||||
local function form()
|
||||
|
@ -23,23 +25,20 @@ local function adcheck()
|
|||
local pos = player:getpos()
|
||||
local control = player:get_player_control()
|
||||
local controlBit = player:get_player_control_bits()
|
||||
if adusers[name] and vector.equals(adusers[name].pos, pos) and adusers[name].controlBit == controlBit and (control.up or control.down or control.right or control.left) and not isAttached(name) then
|
||||
if adusers[name] and not adusers[name].active and vector.equals(adusers[name].pos, pos) and adusers[name].controlBit == controlBit and (control.up or control.down or control.right or control.left) and not isAttached(name) then
|
||||
adusers[name].counter = (adusers[name].counter or 1) + 1
|
||||
if adusers[name].counter >= 10 then
|
||||
elseif adusers[name] and adusers[name].counter and adusers[name].counter >= timeout_message then
|
||||
if not adusers[name].active or adusers[name].active == true then
|
||||
adusers[name].active = true
|
||||
end
|
||||
elseif adusers[name] and adusers[name].active then
|
||||
if adusers[name].active == true then
|
||||
minetest.show_formspec(name, "adblock:main", form() .."button[1.35,3.5;1.2,0.1;adblock_main;Accept]")
|
||||
else
|
||||
if adusers[name].active >= 1 then
|
||||
minetest.show_formspec(name, "adblock:main", form() .."label[0.5,3.5;You can close this message in ".. adusers[name].active .." seconds]")
|
||||
adusers[name].active = adusers[name].active - 1
|
||||
else
|
||||
minetest.show_formspec(name, "adblock:main", form() .."button_exit[1.35,3.5;1.2,0.1;adblock_close;Close]")
|
||||
end
|
||||
adusers[name].active = adusers[name].active - 1
|
||||
if adusers[name].active <= -1 then
|
||||
adusers[name].active = nil
|
||||
adusers[name].counter = nil
|
||||
end
|
||||
end
|
||||
elseif adusers[name] then
|
||||
|
@ -56,13 +55,12 @@ end
|
|||
adcheck()
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "adblock:main" or not fields.adblock_main then
|
||||
local name = player:get_player_name()
|
||||
if formname ~= "adblock:main" or not fields.adblock_main or adusers[name].active ~= true then
|
||||
return
|
||||
end
|
||||
local name = player:get_player_name()
|
||||
minetest.log(string.format("AdBlock: %s seen an ad for %s seconds", name, adusers[name].counter))
|
||||
adusers[name].active = 10
|
||||
adusers[name].counter = nil
|
||||
adusers[name].active = timeout_message
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
adblock_timeout_message (Timeout of the message [seconds]) string 10
|
Loading…
Reference in New Issue