From 543cd1abc0b061cb7d437b5973b95dd516296661 Mon Sep 17 00:00:00 2001 From: Bas Date: Tue, 21 Aug 2012 05:48:57 +0200 Subject: [PATCH] Remove chessboard on node dig and added the punch node function to chess box. Still have to program the replace the pieces. I'll wait till i have the pieces before i do that --- init.lua | 38 +++++++++++++++++++++++++++++++------- pieces.lua | 28 ++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/init.lua b/init.lua index 4ca3920..8d6cbef 100644 --- a/init.lua +++ b/init.lua @@ -21,22 +21,46 @@ minetest.register_node(":chess:spawn",{ 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 = 8 + local size = 10 local alternate = true for i = size, 1, -1 do for ii = size, 1, -1 do - - local p = {x=pos.x+i+1, y=pos.y, z=pos.z+ii+1} - if alternate then + + 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"}) - alternate = false else - minetest.env:add_node(p, {name="chess:board_white"}) - alternate = true + + + 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 diff --git a/pieces.lua b/pieces.lua index d93564f..096d4ca 100644 --- a/pieces.lua +++ b/pieces.lua @@ -19,8 +19,8 @@ for color = 1, 2 do node_box = { type = "fixed", fixed = { - {-0.2, -0.5, -0.3, 0.2, -0.4, 0.3}, - {-0.3, -0.5, -0.2, 0.2, -0.4, 0.3}, + {-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}, @@ -40,6 +40,30 @@ for color = 1, 2 do --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