mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-03-03 14:53:01 +02:00
Minor text changes and _DEBUG options
This commit is contained in:
parent
560cf2575c
commit
948ed4ab1f
@ -76,7 +76,7 @@ end
|
||||
|
||||
local function hodor(event)
|
||||
local message = event.message:lower()
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
|
||||
if message:match('hodor') then
|
||||
local index = math.random(1, message_weight_sum)
|
||||
local message_weight_sum = 0
|
||||
@ -91,6 +91,7 @@ local function hodor(event)
|
||||
|
||||
-- player_index is nil if the message came from the server,
|
||||
-- and indexing Game.players with nil is apparently an error.
|
||||
local player = Game.get_player_by_index(event.player_index)
|
||||
local player_index = event.player_index
|
||||
if not player_index then
|
||||
return
|
||||
@ -123,6 +124,7 @@ local function hodor(event)
|
||||
-- Gives a sound notification to a mentioned player using @[player-name]
|
||||
if global.mention_enabled then
|
||||
local missing_player_string
|
||||
local not_found = 0
|
||||
for word in event.message:gmatch('@%S+') do
|
||||
local cannot_mention = {}
|
||||
for _, p in ipairs(game.connected_players) do
|
||||
@ -131,11 +133,14 @@ local function hodor(event)
|
||||
player.print(prefix..'Can\'t mention yourself!', {r = 1, g = 0, b = 0, a = 1})
|
||||
break;
|
||||
end
|
||||
p.print('## - '..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}
|
||||
player.print(prefix..'Successful mentioned '..p.name, {r = 0, g = 1, b = 0, a = 1})
|
||||
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 }
|
||||
if _DEBUG then
|
||||
player.print(prefix..'Successful mentioned '..p.name, {r = 0, g = 1, b = 0, a = 1})
|
||||
end
|
||||
else
|
||||
table.insert(cannot_mention, string.sub((word .. ', '), 2))
|
||||
not_found = not_found + 1
|
||||
table.insert(cannot_mention, (word .. ', '))
|
||||
end
|
||||
end
|
||||
for _, pname in ipairs(cannot_mention) do
|
||||
@ -144,7 +149,11 @@ local function hodor(event)
|
||||
end
|
||||
if missing_player_string ~= nil then
|
||||
missing_player_string = string.sub(missing_player_string, 1, (string.len(missing_player_string)-2))
|
||||
player.print(prefix..'Failed to mention: ' .. missing_player_string, {r = 1, g = 1, b = 0, a = 1})
|
||||
if not_found > 1 then
|
||||
player.print(prefix..'Players not found: ' .. missing_player_string, {r = 1, g = 1, b = 0, a = 1})
|
||||
else
|
||||
player.print(prefix..'Player not found: ' .. missing_player_string, {r = 1, g = 1, b = 0, a = 1})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user