+function realchess.on_move(pos, from_list, from_index)
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ inv:set_stack(from_list, from_index, '')
+
+ local board = board_to_table(inv)
+ local black_king_idx, white_king_idx = locate_kings(board)
+ local black_king_attacked = attacked("black", black_king_idx, board)
+ local white_king_attacked = attacked("white", white_king_idx, board)
+
+ local playerWhite = meta:get_string("playerWhite")
+ local playerBlack = meta:get_string("playerBlack")
+
+ local moves = meta:get_string("moves")
+ local eaten_img = meta:get_string("eaten_img")
+ local lastMove = meta:get_string("lastMove")
+ local turnBlack = minetest.colorize("#000001", (lastMove == "white" and playerBlack ~= "") and
+ playerBlack .. "..." or playerBlack)
+ local turnWhite = minetest.colorize("#000001", (lastMove == "black" and playerWhite ~= "") and
+ playerWhite .. "..." or playerWhite)
+ local check_s = minetest.colorize("#FF0000", "\\[check\\]")
+
+ local formspec = fs ..
+ "label[1.9,0.3;" .. turnBlack .. (black_king_attacked and " " .. check_s or "") .. "]" ..
+ "label[1.9,9.15;" .. turnWhite .. (white_king_attacked and " " .. check_s or "") .. "]" ..
+ "table[8.9,1.05;5.07,3.75;moves;" .. moves:sub(1,-2) .. ";1]" ..
+ eaten_img
+
+ meta:set_string("formspec", formspec)
+
+ return false
+end
+