added chess
parent
250020c4e4
commit
960a5ea898
|
@ -0,0 +1,4 @@
|
|||
chess
|
||||
=====
|
||||
|
||||
Chess mod for minetest
|
|
@ -0,0 +1,103 @@
|
|||
-- CHESS MOD
|
||||
-- ======================================
|
||||
-- chess/init.lua
|
||||
-- ======================================
|
||||
-- Registers the basic chess stuff
|
||||
--
|
||||
-- Contents:
|
||||
--
|
||||
-- [regis] Spawn Block
|
||||
-- [craft] Spawn Block
|
||||
-- [regis] board_black
|
||||
-- [regis] board_white
|
||||
-- ======================================
|
||||
|
||||
dofile(minetest.get_modpath("chess").."/pieces.lua")
|
||||
dofile(minetest.get_modpath("chess").."/rules.lua")
|
||||
|
||||
-- Register the spawn block
|
||||
minetest.register_node(":chess:spawn",{
|
||||
description = "Chess Board",
|
||||
tile_images = {"chess_spawn.png"},
|
||||
inventory_image = "chess_spawn.png",
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
after_dig_node = function(pos, node, digger)
|
||||
|
||||
local size = 10
|
||||
|
||||
for i = size, 1, -1 do
|
||||
for ii = size, 1, -1 do
|
||||
local p = {x=pos.x+i, y=pos.y, z=pos.z+ii}
|
||||
minetest.env:remove_node(p)
|
||||
end
|
||||
end
|
||||
|
||||
end,
|
||||
on_punch = function(pos)
|
||||
|
||||
--reset the pieces
|
||||
|
||||
end,
|
||||
after_place_node = function(pos)
|
||||
|
||||
local size = 10
|
||||
local alternate = true
|
||||
|
||||
for i = size, 1, -1 do
|
||||
for ii = size, 1, -1 do
|
||||
|
||||
|
||||
local p = {x=pos.x+i, y=pos.y, z=pos.z+ii}
|
||||
if (ii == 1) or (ii == 10) or (i ==1) or (i == 10) then--create border
|
||||
minetest.env:add_node(p, {name="chess:board_black"})
|
||||
else
|
||||
|
||||
|
||||
if alternate then
|
||||
minetest.env:add_node(p, {name="chess:board_black"})
|
||||
alternate = false
|
||||
else
|
||||
minetest.env:add_node(p, {name="chess:board_white"})
|
||||
alternate = true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if (math.floor(size/2) == size/2) then
|
||||
if alternate then
|
||||
alternate = false
|
||||
else
|
||||
alternate = true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Add crafting for the spawn block
|
||||
minetest.register_craft({
|
||||
output="chess:spawn",
|
||||
recipe = {
|
||||
{'default:mese','default:mese','default:mese'},
|
||||
{'default:mese','default:mese','default:mese'},
|
||||
{'default:mese','default:mese','default:mese'},
|
||||
}
|
||||
})
|
||||
|
||||
--Register the Board Blocks: white
|
||||
minetest.register_node(":chess:board_white",{
|
||||
description = "White Chess Board Piece",
|
||||
tile_images = {"chess_board_white.png"},
|
||||
inventory_image = "chess_white.png",
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
})
|
||||
|
||||
--Register the Board Blocks: black
|
||||
minetest.register_node(":chess:board_black",{
|
||||
description = "Black Chess Board Piece",
|
||||
tile_images = {"chess_board_black.png"},
|
||||
inventory_image = "chess_black.png",
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
})
|
|
@ -0,0 +1,72 @@
|
|||
--This file declares all the pieces for the game
|
||||
|
||||
local colors = {"black", "white",}
|
||||
|
||||
--make a loop which makes the black and white nodes and crafting recipes
|
||||
|
||||
for color = 1, 2 do
|
||||
--Pawn
|
||||
minetest.register_node(":chess:pawn_"..colors[color],
|
||||
{
|
||||
description = 'pawn',
|
||||
groups = {snappy = 2},
|
||||
tiles = {"chess_piece_"..colors[color]..".png"},
|
||||
drawtype = "nodebox",
|
||||
sunlight_propagates = true,
|
||||
paramtype = 'light',
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8, --max light is 18
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.3, -0.5, -0.3, 0.2, -0.4, 0.3},
|
||||
{-0.3, -0.5, -0.3, 0.2, -0.4, 0.3},
|
||||
{-0.1, -0.4, -0.2, 0.1, -0.3, 0.2},
|
||||
{-0.2, -0.4, -0.1, 0.2, -0.3, 0.1},
|
||||
{-0.1, -0.3, -0.1, 0.1, 0.2, 0.1},
|
||||
{-0.2, -0.1, -0.1, 0.2, 0.1, 0.1},
|
||||
{-0.1, -0.1, -0.2, 0.1, 0.1, 0.2},
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.2, 0.3},
|
||||
},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
|
||||
})
|
||||
|
||||
--Rook
|
||||
|
||||
--Knight
|
||||
|
||||
--Bishop
|
||||
|
||||
minetest.register_node(":chess:bishop_"..colors[color],
|
||||
{
|
||||
description = 'bishop',
|
||||
groups = {snappy = 2},
|
||||
tiles = {"chess_piece_"..colors[color]..".png"},
|
||||
drawtype = "nodebox",
|
||||
sunlight_propagates = true,
|
||||
paramtype = 'light',
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8, --max light is 18
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
{-0.2, -0.8, -0.3, 0.2, -0.4, 0.3},
|
||||
|
||||
},
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-0.3, -0.5, -0.3, 0.3, 0.2, 0.3},
|
||||
},
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}
|
||||
})
|
||||
|
||||
--Queen
|
||||
|
||||
--King
|
||||
|
||||
end
|
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue