commit
7cd53d2e89
10 changed files with 212 additions and 0 deletions
@ -0,0 +1 @@ |
||||
/.idea |
@ -0,0 +1,15 @@ |
||||
-- LUALOCALS < --------------------------------------------------------- |
||||
local include, nodecore |
||||
= include, nodecore |
||||
-- LUALOCALS > --------------------------------------------------------- |
||||
|
||||
nodecore.register_concrete_pattern({description = "Crossy"}) |
||||
nodecore.register_concrete_pattern({description = "Starcrossy"}) |
||||
nodecore.register_concrete_pattern({description = "Edgy", paramtype2 = "4dir"}) |
||||
nodecore.register_concrete_pattern({description = "Corny", paramtype2 = "4dir"}) |
||||
|
||||
|
||||
--nodecore.register_concrete_pattern({description = "Crossy", groups = {goban = 1}}) |
||||
--nodecore.register_concrete_pattern({description = "Starcrossy", groups = {goban = 1}}) |
||||
--nodecore.register_concrete_pattern({description = "Edgy", paramtype2 = "4dir", groups = {goban = 1}}) |
||||
--nodecore.register_concrete_pattern({description = "Corny", paramtype2 = "4dir", groups = {goban = 1}}) |
@ -0,0 +1,9 @@ |
||||
-- LUALOCALS < --------------------------------------------------------- |
||||
local include, nodecore |
||||
= include, nodecore |
||||
-- LUALOCALS > --------------------------------------------------------- |
||||
|
||||
|
||||
include("goban") |
||||
include("rules") |
||||
include("stones") |
@ -0,0 +1,3 @@ |
||||
name = lc_liberties |
||||
description = A minimalistic approach to enabling the game of go. |
||||
depends = nc_api_all, nc_concrete |
@ -0,0 +1,81 @@ |
||||
-- LUALOCALS < --------------------------------------------------------- |
||||
local include, nodecore, pairs, string, table |
||||
= include, nodecore, pairs, string, table |
||||
local string_lower |
||||
= string.lower |
||||
|
||||
-- LUALOCALS > --------------------------------------------------------- |
||||
local modname = minetest.get_current_modname() |
||||
|
||||
--nodecore.gametime |
||||
|
||||
local cache = {} |
||||
|
||||
local relativeNeighbors = { |
||||
vector.new(1, 0, 0), |
||||
vector.new(0, 0, 1), |
||||
vector.new(-1, 0, 0), |
||||
vector.new(0, 0, -1) |
||||
} |
||||
|
||||
function check_position(pos) |
||||
local hash = minetest.hash_node_position(pos) |
||||
if cache[hash] then |
||||
return cache[hash] |
||||
end |
||||
|
||||
local ret = minetest.get_node(pos) |
||||
print_r(ret) |
||||
print_r(minetest.registered_items[ret.name]) |
||||
print(pos) |
||||
cache[hash] = ret |
||||
return ret |
||||
end |
||||
|
||||
function check_captures(pos) |
||||
minetest.chat_send_all(tostring(pos)) |
||||
nodecore.node_sound(pos, "dug") |
||||
|
||||
check_position(pos + vector.new(0, -1, 0)) |
||||
|
||||
local neighbors = {} |
||||
|
||||
for i,v in ipairs(relativeNeighbors) do |
||||
neighbors[i] = pos + v |
||||
end |
||||
|
||||
end |
||||
|
||||
function surrounded_group(pos) |
||||
local group = {} |
||||
local queue = {} |
||||
end |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function print_r ( t ) |
||||
local print_r_cache={} |
||||
local function sub_print_r(t,indent) |
||||
if (print_r_cache[tostring(t)]) then |
||||
print(indent.."*"..tostring(t)) |
||||
else |
||||
print_r_cache[tostring(t)]=true |
||||
if (type(t)=="table") then |
||||
for pos,val in pairs(t) do |
||||
if (type(val)=="table") then |
||||
print(indent.."["..pos.."] => "..tostring(t).." {") |
||||
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8)) |
||||
print(indent..string.rep(" ",string.len(pos)+6).."}") |
||||
else |
||||
print(indent.."["..pos.."] => "..tostring(val)) |
||||
end |
||||
end |
||||
else |
||||
print(indent..tostring(t)) |
||||
end |
||||
end |
||||
end |
||||
sub_print_r(t," ") |
||||
end |
@ -0,0 +1,103 @@ |
||||
-- LUALOCALS < --------------------------------------------------------- |
||||
local include, nodecore, pairs, string |
||||
= include, nodecore, pairs, string |
||||
local string_lower |
||||
= string.lower |
||||
-- LUALOCALS > --------------------------------------------------------- |
||||
|
||||
include("rules") |
||||
|
||||
local modname = minetest.get_current_modname() |
||||
|
||||
local function reg(name, basename, basedef) |
||||
local piecename = modname .. ":stone_" .. string_lower(name) |
||||
if minetest.registered_nodes[piecename] then return end |
||||
local desc = basedef.description or name |
||||
|
||||
local nodeDesc |
||||
|
||||
local nameStone = string.match(desc, "(.*)stone$") |
||||
if nameStone then |
||||
nodeDesc = nameStone |
||||
elseif desc == "Stone" then |
||||
nodeDesc = "Go" |
||||
else |
||||
nodeDesc = desc |
||||
end |
||||
nodeDesc = nodeDesc .. " Stone" |
||||
|
||||
minetest.register_node(":" .. piecename, { |
||||
description = nodeDesc, |
||||
drawtype = "nodebox", |
||||
|
||||
node_box = { |
||||
type = "fixed", |
||||
fixed = { |
||||
{-3/16, -8/16, -3/16, 3/16, -7/16, 3/16}, |
||||
{-5/16, -7/16, -5/16, 5/16, -6/16, 5/16}, |
||||
{-6/16, -6/16, -6/16, 6/16, -4/16, 6/16}, |
||||
{-7/16, -4/16, -7/16, 7/16, -2/16, 7/16}, |
||||
{-6/16, -2/16, -6/16, 6/16, 0/16, 6/16}, |
||||
{-5/16, 0/16, -5/16, 5/16, 1/16, 5/16}, |
||||
{-3/16, 1/16, -3/16, 3/16, 2/16, 3/16}, |
||||
} |
||||
}, |
||||
|
||||
selection_box = { |
||||
type = "fixed", |
||||
fixed = {-7/16, -8/16, -7/16, 7/16, 2/16, 7/16} |
||||
}, |
||||
|
||||
|
||||
tiles = { |
||||
basedef.tiles[1] |
||||
}, |
||||
|
||||
paramtype = "light", |
||||
sunlight_propagates = true, |
||||
groups = { |
||||
snappy = 1, |
||||
falling_node = 1, |
||||
falling_repose = 1, |
||||
}, |
||||
sounds = basedef.sounds, |
||||
|
||||
on_construct = check_captures |
||||
}) |
||||
|
||||
nodecore.register_craft({ |
||||
label = "shave " .. string_lower(desc) .. " into stones", |
||||
action = "pummel", |
||||
toolgroups = {choppy = 3}, |
||||
nodes = { |
||||
{ |
||||
match = "nc_concrete:" .. name .. "_starcrossy_ply", |
||||
--match = {groups = {goban = 1}}, |
||||
replace = "air" |
||||
} |
||||
}, |
||||
items = {{name = piecename, count = 3, scatter = 4}}, |
||||
}) |
||||
end |
||||
|
||||
local function buildall() |
||||
for _, v in ipairs(nodecore.registered_concrete_etchables) do |
||||
local basedef = v.name and v.basename and minetest.registered_nodes[v.basename] |
||||
if basedef then |
||||
reg(v.name, v.basename, basedef) |
||||
end |
||||
end |
||||
end |
||||
|
||||
do |
||||
local old_reg_etch = nodecore.register_concrete_etchable |
||||
local function helper(...) |
||||
buildall() |
||||
return ... |
||||
end |
||||
nodecore.register_concrete_etchable = function(...) |
||||
return helper(old_reg_etch(...)) |
||||
end |
||||
end |
||||
|
||||
buildall() |
After Width: | Height: | Size: 112 B |
After Width: | Height: | Size: 118 B |
After Width: | Height: | Size: 109 B |
After Width: | Height: | Size: 117 B |
Loading…
Reference in new issue