Colored cardtable works
This commit is contained in:
parent
7929e019d9
commit
5295e23e74
41
init.lua
41
init.lua
@ -585,6 +585,15 @@ local function inventory_to_cardtable(list,pos,sender,which)
|
||||
return false
|
||||
end
|
||||
|
||||
local function is_cardtable(pos)
|
||||
local prefix="deck:cardtable_"
|
||||
local n=minetest.get_node(pos)
|
||||
if string.sub(n.name,1,string.len(prefix)) == prefix then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- return true if pos is deal position
|
||||
local function is_deal_position(pos)
|
||||
local around={
|
||||
@ -594,8 +603,7 @@ local function is_deal_position(pos)
|
||||
}
|
||||
local tablenodes=0
|
||||
for key,p in ipairs(around) do
|
||||
local n=minetest.get_node(p)
|
||||
if n.name == "deck:cardtable" then
|
||||
if is_cardtable(p) then
|
||||
tablenodes=tablenodes+1
|
||||
end
|
||||
end
|
||||
@ -619,9 +627,8 @@ end
|
||||
local function deal_card_to_table(pos,formname,fields,sender)
|
||||
log("deal cards at "..minetest.pos_to_string(pos))
|
||||
local below={x=pos.x,y=pos.y-1,z=pos.z}
|
||||
local belownode=minetest.get_node(below)
|
||||
local dp
|
||||
if belownode.name == "deck:cardtable" then
|
||||
if is_cardtable(below) then
|
||||
log("below is cardtable")
|
||||
local from_pile_meta=minetest.get_meta(pos)
|
||||
local from_pile_inv=from_pile_meta:get_inventory()
|
||||
@ -648,9 +655,8 @@ end
|
||||
local function deal_cards(pos,formname,fields,sender)
|
||||
log("deal cards at "..minetest.pos_to_string(pos))
|
||||
local below={x=pos.x,y=pos.y-1,z=pos.z}
|
||||
local belownode=minetest.get_node(below)
|
||||
local dp
|
||||
if belownode.name == "deck:cardtable" then
|
||||
if is_cardtable(below) then
|
||||
log("below is cardtable")
|
||||
dp=cardtable_get_deal_positions(below)
|
||||
else
|
||||
@ -846,8 +852,7 @@ local function on_construct_cardtable(pos)
|
||||
|
||||
)
|
||||
for key,p in ipairs(around) do
|
||||
local n=minetest.get_node(p)
|
||||
if n.name == "deck:cardtable" then
|
||||
if is_cardtable(p) then
|
||||
add_node_to_cardtable(cardtable_get_main_pos(p),pos)
|
||||
return
|
||||
end
|
||||
@ -945,16 +950,16 @@ for _, row in ipairs(dye.dyes) do
|
||||
local name = "deck:cardtable_"..color
|
||||
local colorize = tablecolorize[color]
|
||||
if colorize == nil then colorize = color end
|
||||
local tile = "deck_table_g.png^[colorize:"..colorize..":alpha"
|
||||
log(name..": "..tile)
|
||||
minetest.register_node(name, {
|
||||
description = "Table where cards can be easily dealt",
|
||||
tiles = { tile },
|
||||
on_construct = on_construct_cardtable,
|
||||
groups = {cracky=3, cardtable=1},
|
||||
after_dig_node = after_dig_cardtable,
|
||||
on_receive_fields = fields_cardtable,
|
||||
})
|
||||
local tile = "deck_table_g.png^[colorize:"..colorize..":127"
|
||||
log(name..": "..tile)
|
||||
minetest.register_node(name, {
|
||||
description = "Table where cards can be easily dealt",
|
||||
tiles = { tile },
|
||||
on_construct = on_construct_cardtable,
|
||||
groups = {cracky=3, cardtable=1},
|
||||
after_dig_node = after_dig_cardtable,
|
||||
on_receive_fields = fields_cardtable,
|
||||
})
|
||||
end
|
||||
|
||||
-- ABM enables adding cards to a pile by placing card on the pile.
|
||||
|
Loading…
x
Reference in New Issue
Block a user