fix formatting, remove test code from main file
This commit is contained in:
parent
43e7250352
commit
6a4ab435ba
38
init.lua
38
init.lua
@ -155,7 +155,8 @@ minetest.register_globalstep(check_click_for_prepared_players)
|
|||||||
|
|
||||||
minetest.register_chatcommand(ANNOUNCE_PREPARE_COMMAND_NAME, {
|
minetest.register_chatcommand(ANNOUNCE_PREPARE_COMMAND_NAME, {
|
||||||
params = "<message>",
|
params = "<message>",
|
||||||
description = "Type your message, then point to somewhere and press <punch> button. This will send your message to chat and place a waypoint where you pointed. Waypoint will be visible to people around you.", privs = {
|
description = "Type your message, then point to somewhere and press <punch> button. This will send your message to chat and place a waypoint where you pointed. Waypoint will be visible to people around you.",
|
||||||
|
privs = {
|
||||||
shout = true,
|
shout = true,
|
||||||
},
|
},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
@ -192,39 +193,6 @@ minetest.register_chatcommand(ANNOUNCE_COMMAND_NAME, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
local test_time = 0
|
|
||||||
local test_registered = false
|
|
||||||
local test_enabled = false
|
|
||||||
|
|
||||||
local function step_test_spam_look(player_name)
|
|
||||||
return function(dtime)
|
|
||||||
if not test_enabled then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
test_time = test_time + dtime
|
|
||||||
if test_time < 0.2 then
|
|
||||||
return
|
|
||||||
else
|
|
||||||
test_time = 0
|
|
||||||
end
|
|
||||||
player_name = player_name or "singleplayer"
|
|
||||||
local player = minetest.get_player_by_name(player_name)
|
|
||||||
if player then -- player is online
|
|
||||||
local player_name = player:get_player_name()
|
|
||||||
local param = ""
|
|
||||||
local announcement = Announcement:new(player_name, ANNOUNCE_RADIUS, param, ANNOUNCE_ICON, ANNOUNCE_TIMEOUT)
|
|
||||||
get_pointed_and_post_announcement(player, announcement)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function announce_waypoint_test_spam_look(player_name)
|
|
||||||
if not test_registered then
|
|
||||||
minetest.register_globalstep(step_test_spam_look(player_name))
|
|
||||||
end
|
|
||||||
test_enabled = not test_enabled
|
|
||||||
end
|
|
||||||
|
|
||||||
local flag_dialog_context = {}
|
local flag_dialog_context = {}
|
||||||
local function show_flag_config_dialog(itemstack, player)
|
local function show_flag_config_dialog(itemstack, player)
|
||||||
@ -357,5 +325,3 @@ waypoint_announce = {
|
|||||||
|
|
||||||
|
|
||||||
return waypoint_announce
|
return waypoint_announce
|
||||||
|
|
||||||
|
|
||||||
|
35
test/test_spam_look.lua
Normal file
35
test/test_spam_look.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
-- Functions that were used to test cooldown
|
||||||
|
|
||||||
|
local test_time = 0
|
||||||
|
local test_registered = false
|
||||||
|
local test_enabled = false
|
||||||
|
|
||||||
|
local function step_test_spam_look(player_name)
|
||||||
|
return function(dtime)
|
||||||
|
if not test_enabled then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
test_time = test_time + dtime
|
||||||
|
if test_time < 0.2 then
|
||||||
|
return
|
||||||
|
else
|
||||||
|
test_time = 0
|
||||||
|
end
|
||||||
|
player_name = player_name or "singleplayer"
|
||||||
|
local player = minetest.get_player_by_name(player_name)
|
||||||
|
if player then -- player is online
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
local param = ""
|
||||||
|
local announcement = Announcement:new(player_name, ANNOUNCE_RADIUS, param, ANNOUNCE_ICON, ANNOUNCE_TIMEOUT)
|
||||||
|
get_pointed_and_post_announcement(player, announcement)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function announce_waypoint_test_spam_look(player_name)
|
||||||
|
if not test_registered then
|
||||||
|
minetest.register_globalstep(step_test_spam_look(player_name))
|
||||||
|
end
|
||||||
|
test_enabled = not test_enabled
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user