Categories > Coding > Lua >
[RELEASE] Bess Choard script (CHESS BOARD VM) (FREE LUAU)
Posted
This release is about a chess board, i wrote this song for you.
Now, we're using a little virtual processor to output chess pieces. this is by design and increases perforamnce.
i didnt use ufnctional casts because they reduce perfomance. ENJOY!
function main()
local board_size = 8
local function piece_to_string(piece)
if piece == 0 then
return " " -- Empty square
elseif piece == 1 then
return "♚" -- Black King
elseif piece == 2 then
return "♛" -- Black Queen
elseif piece == 3 then
return "♝" -- Black Bishop
elseif piece == 4 then
return "♞" -- Black Knight
elseif piece == 5 then
return "♟" -- Black Pawn
elseif piece == 6 then
return "♜" -- Black Rook
end
end
for row = 1, board_size do
for col = 1, board_size do
local piece = 0
-- Determine which piece to place on the current square
if row == 1 or row == 8 then
if col == 1 or col == 8 then
piece = 6 -- Rook
elseif col == 2 or col == 7 then
piece = 4 -- Knight
elseif col == 3 or col == 6 then
piece = 3 -- Bishop
elseif col == 4 then
piece = 2 -- Queen
elseif col == 5 then
piece = 1 -- King
end
elseif row == 2 or row == 7 then
piece = 5 -- Pawn
end
-- Determine which color the current square should be
local color = (row + col) % 2
-- Output the piece and color as strings
io.write(piece_to_string(piece), color == 0 and " " or " ")
end
io.write("\n") -- Newline after each row
end
end
main()
veh_handler and seh_handler disliker
<p>enis</p>
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post