Start to add colored table pieces

This commit is contained in:
Mikko Tuumanen 2023-10-27 23:26:01 +03:00
parent 3946a82f73
commit 7929e019d9
2 changed files with 39 additions and 10 deletions

View File

@ -1,10 +1,11 @@
local debug_enabled=minetest.settings:get('deck_debugmessages')
-- output to minetest.log if debug messages are enabled in settings
local function log(txt)
if debug_enabled==true then
if debug_enabled then
minetest.log(txt)
end
end
-- describe contents of an unknown something. Used for learning minetest lua api.
local function describe(prefix,stuff)
local t=type(stuff)
@ -37,6 +38,8 @@ local suitcolorizeindex={ 2,1,1,2}
-- Colorize rules for red and black card textures.
local suitcolorize = { "\\^[colorize\\:#ff0000\\:alpha","\\^[colorize\\:#000000\\:alpha" }
-- Dye colors that are not accepted by colorize must be set explicitly
local tablecolorize = { dark_grey="#222222",dark_green="#002200" }
-- Names of card ranks. These are used in descriptions of cards in inventory.
local rank = { "Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten",
@ -118,6 +121,7 @@ local function generate_descriptions()
end
textures[i]=textures[i]..
":3,28=deck_"..rank_short[r]..".png"..suitcolorize[suitcolorizeindex[s]]
log(i.." "..textures[i])
i=i+1
end
end
@ -935,14 +939,23 @@ minetest.register_node("deck:stockpile", {
-- Cardtable is a table building block that should make handling
-- multiple cards easier.
minetest.register_node("deck:cardtable", {
description = "Table where cards can be easily dealt",
tiles = { "deck_table.png" },
on_construct = on_construct_cardtable,
groups = {cracky=3},
after_dig_node = after_dig_cardtable,
on_receive_fields = fields_cardtable,
})
log(table.getn(dye.dyes).." cardtable colors")
for _, row in ipairs(dye.dyes) do
local color = row[1]
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,
})
end
-- ABM enables adding cards to a pile by placing card on the pile.
minetest.register_abm({
@ -996,10 +1009,23 @@ minetest.register_craft({
-- card table pieces can be crafted from 2x2 grid of wood
minetest.register_craft({
output = "deck:cardtable 99",
output = "deck:cardtable_white 99",
recipe = {{ "group:wood", "group:wood"},{"group:wood","group:wood"}}
})
for _, row in ipairs(dye.dyes) do
local color = row[1]
local name = "deck:cardtable_"..color
local outputstring = name.." 99"
local dyetype = "group:dye,color_white"
log("registering craft for '"..outputstring.."' and dyetype "..dyetype)
minetest.register_craft({
type = "shapeless",
output = outputstring,
recipe = { "group:dye,color_" .. color, "group:cardtable" }
})
end
-- Card turns into chestpile or stockpile depending on
-- the place in the craft grid.
-- Card deck from paper need to be filled with cards here.

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = deck
description = Card deck
depends = default, dye