Show last move time in chat

This commit is contained in:
jp 2015-11-21 19:57:27 +01:00
parent 269e93d50c
commit f4ba8de408

@ -1,4 +1,5 @@
local realchess = {} local realchess = {}
screwdriver = screwdriver or {}
local function index_to_xy(index) local function index_to_xy(index)
index = index - 1 index = index - 1
@ -525,9 +526,9 @@ function realchess.move(pos, from_list, from_index, to_list, to_index, count, pl
meta:set_int("lastMoveTime", minetest.get_gametime()) meta:set_int("lastMoveTime", minetest.get_gametime())
if meta:get_string("lastMove") == "black" then if meta:get_string("lastMove") == "black" then
minetest.chat_send_player(playerWhite, playerName.." has moved a "..pieceFrom:match("%a+:(%a+)")..", it's now your turn.") minetest.chat_send_player(playerWhite, "["..os.date("%H:%M:%S").."] "..playerName.." has moved a "..pieceFrom:match("%a+:(%a+)")..", it's now your turn.")
elseif meta:get_string("lastMove") == "white" then elseif meta:get_string("lastMove") == "white" then
minetest.chat_send_player(playerBlack, playerName.." has moved a "..pieceFrom:match("%a+:(%a+)")..", it's now your turn.") minetest.chat_send_player(playerBlack, "["..os.date("%H:%M:%S").."] "..playerName.." has moved a "..pieceFrom:match("%a+:(%a+)")..", it's now your turn.")
end end
if pieceTo:find("king") then if pieceTo:find("king") then
@ -593,10 +594,11 @@ minetest.register_node("realchess:chessboard", {
tiles = {"chessboard_top.png", "chessboard_top.png", tiles = {"chessboard_top.png", "chessboard_top.png",
"chessboard_sides.png", "chessboard_sides.png", "chessboard_sides.png", "chessboard_sides.png",
"chessboard_top.png", "chessboard_top.png"}, "chessboard_top.png", "chessboard_top.png"},
groups = {choppy=3, flammable=3}, groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
node_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}}, node_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}},
sunlight_propagates = true, sunlight_propagates = true,
on_rotate = screwdriver.rotate_simple,
can_dig = realchess.dig, can_dig = realchess.dig,
on_construct = realchess.init, on_construct = realchess.init,
on_receive_fields = realchess.fields, on_receive_fields = realchess.fields,