Simplify some chessboard messages

This commit is contained in:
Wuzzy 2023-07-12 11:30:15 +02:00
parent 0d9af7803a
commit c99e2efe09

View File

@ -1723,8 +1723,7 @@ function realchess.fields(pos, _, fields, sender)
realchess.init(pos) realchess.init(pos)
else else
minetest.chat_send_player(playerName, chat_prefix .. minetest.chat_send_player(playerName, chat_prefix ..
S("You can't reset the chessboard, a game has been started. " .. S("You can't reset the chessboard, a game has been started. Try again in @1.",
"If you aren't a current player, try again in @1",
timeout_format(timeout_limit))) timeout_format(timeout_limit)))
end end
end end
@ -1775,13 +1774,26 @@ function realchess.dig(pos, player)
local playerName = player:get_player_name() local playerName = player:get_player_name()
local timeout_limit = meta:get_int("lastMoveTime") + 300 local timeout_limit = meta:get_int("lastMoveTime") + 300
local lastMoveTime = meta:get_int("lastMoveTime") local lastMoveTime = meta:get_int("lastMoveTime")
local playerWhite = meta:get_string("playerWhite")
local playerBlack = meta:get_string("playerBlack")
-- Timeout is 5 min. by default for digging the chessboard (non-players only) -- Timeout is 5 min. by default for digging the chessboard (non-players only)
return (lastMoveTime == 0 and minetest.get_gametime() > timeout_limit) or if (lastMoveTime == 0 and minetest.get_gametime() > timeout_limit) then
minetest.chat_send_player(playerName, chat_prefix .. return true
S("You can't dig the chessboard, a game has been started. " .. else
"Reset it first if you're a current player, or dig it again in @1", if playerName == playerWhite or playerName == playerBlack then
timeout_format(timeout_limit))) minetest.chat_send_player(playerName, chat_prefix ..
S("You can't dig the chessboard, a game has been started. " ..
"Reset it first or dig it again in @1.",
timeout_format(timeout_limit)))
else
minetest.chat_send_player(playerName, chat_prefix ..
S("You can't dig the chessboard, a game has been started. " ..
"Try it again in @1.",
timeout_format(timeout_limit)))
end
return false
end
end end
-- Helper function for realchess.move. -- Helper function for realchess.move.