mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Added @ to mention triggers also allowed the prefix as a postfix
Avaliable triggers now: admin moderator @SimonFlapse #SimonFlapse SimonFlapse@ SimonFlapse# (@SimonFlapse might trigger discord)
This commit is contained in:
parent
dd7b546caa
commit
5c5c59c396
@ -99,7 +99,7 @@ local function hodor(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Gives a sound notification to a mentioned player using #[player-name]
|
-- Gives a sound notification to a mentioned player using #[player-name], [player-name]#, @[player-name], [player-name]@ or to admins with moderator or admin without prefix or postfix
|
||||||
if global.mention_enabled then
|
if global.mention_enabled then
|
||||||
local missing_player_string
|
local missing_player_string
|
||||||
local not_found = 0
|
local not_found = 0
|
||||||
@ -108,38 +108,43 @@ local function hodor(event)
|
|||||||
local lower_word = word:lower()
|
local lower_word = word:lower()
|
||||||
local trimmed_word = string.sub(word, 0, string.len(word)-1)
|
local trimmed_word = string.sub(word, 0, string.len(word)-1)
|
||||||
local lower_trimmed_word = string.sub(lower_word, 0, string.len(lower_word)-1)
|
local lower_trimmed_word = string.sub(lower_word, 0, string.len(lower_word)-1)
|
||||||
|
local first_char = string.sub(word, 0, 1)
|
||||||
|
local last_char = string.sub(word, string.len(word))
|
||||||
local success = false
|
local success = false
|
||||||
local admin_call = false
|
local admin_call = false
|
||||||
if lower_word == 'admin' or lower_word == 'moderator' or lower_trimmed_word == 'admin' or lower_trimmed_word == 'moderator' then
|
if lower_word == 'admin' or lower_word == 'moderator' or lower_trimmed_word == 'admin' or lower_trimmed_word == 'moderator' then
|
||||||
admin_call = true
|
admin_call = true
|
||||||
|
elseif (first_char ~= '#' and last_char ~= '#') and (first_char ~= '@' and last_char ~= '@') then
|
||||||
|
success = true
|
||||||
end
|
end
|
||||||
print(string.sub(word, 0, 1))
|
if not success then
|
||||||
if not admin_call and string.sub(word, 0, 1) ~= '#' then
|
for _, p in ipairs(game.connected_players) do
|
||||||
break;
|
local word_front_trim = string.sub(word, 2, string.len(word))
|
||||||
end
|
local word_back_trim = trimmed_word
|
||||||
for _, p in ipairs(game.connected_players) do
|
local word_front_back_trim = string.sub(word_front_trim, 0, string.len(word_front_trim)-1)
|
||||||
word = (lower_trimmed_word == 'admin' or lower_trimmed_word == 'moderator') and trimmed_word or word
|
local word_back_double_trim = string.sub(word_back_trim, 0, string.len(word_back_trim)-1)
|
||||||
if admin_call and p.admin then
|
word = (lower_trimmed_word == 'admin' or lower_trimmed_word == 'moderator') and trimmed_word or word
|
||||||
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned '..word..'!', {r = 1, g = 1, b = 0, a = 1})
|
if admin_call and p.admin then
|
||||||
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
|
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned '..word..'!', {r = 1, g = 1, b = 0, a = 1})
|
||||||
success = true
|
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
|
||||||
end
|
|
||||||
|
|
||||||
if not admin_call and ('#'..p.name == word or '#'..p.name == trimmed_word) then
|
|
||||||
if p.name == player.name then
|
|
||||||
if _DEBUG then
|
|
||||||
player.print(prefix..'Can\'t mention yourself!', {r = 1, g = 0, b = 0, a = 1})
|
|
||||||
end
|
|
||||||
success = true
|
success = true
|
||||||
|
end
|
||||||
|
if not admin_call and (p.name == word_front_trim or p.name == word_back_trim or p.name == word_back_double_trim or p.name == word_front_back_trim) then
|
||||||
|
if p.name == player.name then
|
||||||
|
if _DEBUG then
|
||||||
|
player.print(prefix..'Can\'t mention yourself!', {r = 1, g = 0, b = 0, a = 1})
|
||||||
|
end
|
||||||
|
success = true
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned you!', {r = 1, g = 1, b = 0, a = 1})
|
||||||
|
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
|
||||||
|
success = true
|
||||||
|
if _DEBUG then
|
||||||
|
player.print(prefix..'Successful mentioned '..p.name, {r = 0, g = 1, b = 0, a = 1})
|
||||||
|
end
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned you!', {r = 1, g = 1, b = 0, a = 1})
|
|
||||||
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
|
|
||||||
success = true
|
|
||||||
if _DEBUG then
|
|
||||||
player.print(prefix..'Successful mentioned '..p.name, {r = 0, g = 1, b = 0, a = 1})
|
|
||||||
end
|
|
||||||
break;
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not success then
|
if not success then
|
||||||
@ -164,4 +169,5 @@ local function hodor(event)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Event.add(defines.events.on_console_chat, hodor)
|
Event.add(defines.events.on_console_chat, hodor)
|
||||||
|
Loading…
Reference in New Issue
Block a user