|
|
@ -11,27 +11,61 @@ local modname = minetest.get_current_modname() |
|
|
|
|
|
|
|
|
|
|
|
local cache = {} |
|
|
|
local cache = {} |
|
|
|
|
|
|
|
|
|
|
|
local relativeNeighbors = { |
|
|
|
local relative_neighbors = { |
|
|
|
vector.new(1, 0, 0), |
|
|
|
vector.new(1, 0, 0), |
|
|
|
vector.new(0, 0, 1), |
|
|
|
vector.new(0, 0, 1), |
|
|
|
vector.new(-1, 0, 0), |
|
|
|
vector.new(-1, 0, 0), |
|
|
|
vector.new(0, 0, -1) |
|
|
|
vector.new(0, 0, -1) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local solid_drawtypes = { |
|
|
|
|
|
|
|
normal = true, |
|
|
|
|
|
|
|
glasslike_framed = true, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--[[ |
|
|
|
|
|
|
|
E: empty |
|
|
|
|
|
|
|
Stype: a go stone of some type |
|
|
|
|
|
|
|
W: full block wall |
|
|
|
|
|
|
|
WE0-WE3: edge concrete |
|
|
|
|
|
|
|
WC0-WC3: corner concrete |
|
|
|
|
|
|
|
--]] |
|
|
|
function check_position(pos) |
|
|
|
function check_position(pos) |
|
|
|
local hash = minetest.hash_node_position(pos) |
|
|
|
local hash = minetest.hash_node_position(pos) |
|
|
|
if cache[hash] then |
|
|
|
if cache[hash] then |
|
|
|
return cache[hash] |
|
|
|
return cache[hash] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
local ret = minetest.get_node(pos) |
|
|
|
local ret = _check_position_uncached(pos) |
|
|
|
print_r(ret) |
|
|
|
print(ret) -- todo: remove this |
|
|
|
print_r(minetest.registered_items[ret.name]) |
|
|
|
|
|
|
|
print(pos) |
|
|
|
|
|
|
|
cache[hash] = ret |
|
|
|
cache[hash] = ret |
|
|
|
return ret |
|
|
|
return ret |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _check_position_uncached(pos) |
|
|
|
|
|
|
|
local node = minetest.get_node(pos) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local reg_item = minetest.registered_items[node.name] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if reg_item.groups and reg_item.groups.go_stone then |
|
|
|
|
|
|
|
return "S" .. reg_item.go_team |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if reg_item.pattern_def then |
|
|
|
|
|
|
|
if reg_item.pattern_def.name == "edgy" then |
|
|
|
|
|
|
|
return "WE" .. node.param2 |
|
|
|
|
|
|
|
elseif reg_item.pattern_def.name == "corny" then |
|
|
|
|
|
|
|
return "WC" .. node.param2 |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if solid_drawtypes[reg_item.drawtype] then |
|
|
|
|
|
|
|
return "W" |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
return "E" |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
function check_captures(pos) |
|
|
|
function check_captures(pos) |
|
|
|
minetest.chat_send_all(tostring(pos)) |
|
|
|
minetest.chat_send_all(tostring(pos)) |
|
|
|
nodecore.node_sound(pos, "dug") |
|
|
|
nodecore.node_sound(pos, "dug") |
|
|
@ -40,7 +74,7 @@ function check_captures(pos) |
|
|
|
|
|
|
|
|
|
|
|
local neighbors = {} |
|
|
|
local neighbors = {} |
|
|
|
|
|
|
|
|
|
|
|
for i,v in ipairs(relativeNeighbors) do |
|
|
|
for i,v in ipairs(relative_neighbors) do |
|
|
|
neighbors[i] = pos + v |
|
|
|
neighbors[i] = pos + v |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|