Add uppercase letters, and add support for coloured stone bricks

This commit breaks nodes from the previous commits. As I haven't released it officially yet, I have not made allaises. You have been warned!
This commit is contained in:
Amaz 2014-12-23 21:02:20 +00:00
parent 2c4199488b
commit ec4e03a727
29 changed files with 263 additions and 82 deletions

View File

@ -1,2 +1,3 @@
default
darkage?
colouredstonebricks?

327
init.lua
View File

@ -1,30 +1,30 @@
letters = {
{"a", "al"},
{"b", "bl"},
{"c", "cl"},
{"d", "dl"},
{"e", "el"},
{"f", "fl"},
{"g", "gl"},
{"h", "hl"},
{"i", "il"},
{"j", "jl"},
{"k", "kl"},
{"l", "ll"},
{"m", "ml"},
{"n", "nl"},
{"o", "ol"},
{"p", "pl"},
{"q", "ql"},
{"r", "rl"},
{"s", "sl"},
{"t", "tl"},
{"u", "ul"},
{"v", "vl"},
{"w", "wl"},
{"x", "xl"},
{"y", "yl"},
{"z", "zl"},
{"al", "au", "a", "A"},
{"bl", "bu", "b", "B"},
{"cl", "cu", "c", "C"},
{"dl", "du", "d", "D"},
{"el", "eu", "e", "E"},
{"fl", "fu", "f", "F"},
{"gl", "gu", "g", "G"},
{"hl", "hu", "h", "H"},
{"il", "iu", "i", "I"},
{"jl", "ju", "j", "J"},
{"kl", "ku", "k", "K"},
{"ll", "lu", "l", "L"},
{"ml", "mu", "m", "M"},
{"nl", "nu", "n", "N"},
{"ol", "ou", "o", "O"},
{"pl", "pu", "p", "P"},
{"ql", "qu", "q", "Q"},
{"rl", "ru", "r", "R"},
{"sl", "su", "s", "S"},
{"tl", "tu", "t", "T"},
{"ul", "uu", "u", "U"},
{"vl", "vu", "v", "V"},
{"wl", "wu", "w", "W"},
{"xl", "xu", "x", "X"},
{"yl", "yu", "y", "Y"},
{"zl", "zu", "z", "Z"},
}
letter_cutter = {}
@ -32,16 +32,39 @@ letter_cutter.known_nodes = {}
function letters.register_letters(modname, subname, from_node, description, tiles)
for _, row in ipairs(letters) do
local name = subname.. "_letter_" ..row[1]
local desc = description.. " " ..row[1]
local tiles = tiles.. "^letters_" ..row[2].. "_overlay.png^[makealpha:255,126,126"
local namel = subname.. "_letter_" ..row[1]
local nameu = subname.. "_letter_" ..row[2]
local descl = description.. " " ..row[3]
local descu = description.. " " ..row[4]
local tilesl = tiles.. "^letters_" ..row[1].. "_overlay.png^[makealpha:255,126,126"
local tilesu = tiles.. "^letters_" ..row[2].. "_overlay.png^[makealpha:255,126,126"
local groups = {not_in_creative_inventory=1, not_in_craft_guide=1, oddly_breakable_by_hand=1, attached_node=1}
minetest.register_node(":" ..modname..":"..name, {
description = desc,
minetest.register_node(":" ..modname..":"..namel, {
description = descl,
drawtype = "signlike",
tiles = {tiles},
inventory_image = tiles,
wield_image = tiles,
tiles = {tilesl},
inventory_image = tilesl,
wield_image = tilesl,
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
is_ground_content = false,
walkable = false,
selection_box = {
type = "wallmounted",
--wall_top = <default>
--wall_bottom = <default>
--wall_side = <default>
},
groups = groups,
legacy_wallmounted = false,
})
minetest.register_node(":" ..modname..":"..nameu, {
description = descu,
drawtype = "signlike",
tiles = {tilesu},
inventory_image = tilesu,
wield_image = tilesu,
paramtype = "light",
paramtype2 = "wallmounted",
sunlight_propagates = true,
@ -70,43 +93,86 @@ end
cost = 0.110
letter_cutter.names = {
{"letter_a"},
{"letter_b"},
{"letter_c"},
{"letter_d"},
{"letter_e"},
{"letter_f"},
{"letter_g"},
{"letter_h"},
{"letter_i"},
{"letter_j"},
{"letter_k"},
{"letter_l"},
{"letter_m"},
{"letter_n"},
{"letter_o"},
{"letter_p"},
{"letter_q"},
{"letter_r"},
{"letter_s"},
{"letter_t"},
{"letter_u"},
{"letter_v"},
{"letter_w"},
{"letter_x"},
{"letter_y"},
{"letter_z"},
letter_cutter.names_lower = {
{"letter_al"},
{"letter_bl"},
{"letter_cl"},
{"letter_dl"},
{"letter_el"},
{"letter_fl"},
{"letter_gl"},
{"letter_hl"},
{"letter_il"},
{"letter_jl"},
{"letter_kl"},
{"letter_ll"},
{"letter_ml"},
{"letter_nl"},
{"letter_ol"},
{"letter_pl"},
{"letter_ql"},
{"letter_rl"},
{"letter_sl"},
{"letter_tl"},
{"letter_ul"},
{"letter_vl"},
{"letter_wl"},
{"letter_xl"},
{"letter_yl"},
{"letter_zl"},
}
function letter_cutter:get_output_inv(modname, subname, amount, max)
letter_cutter.names_upper = {
{"letter_au"},
{"letter_bu"},
{"letter_cu"},
{"letter_du"},
{"letter_eu"},
{"letter_fu"},
{"letter_gu"},
{"letter_hu"},
{"letter_iu"},
{"letter_ju"},
{"letter_ku"},
{"letter_lu"},
{"letter_mu"},
{"letter_nu"},
{"letter_ou"},
{"letter_pu"},
{"letter_qu"},
{"letter_ru"},
{"letter_su"},
{"letter_tu"},
{"letter_uu"},
{"letter_vu"},
{"letter_wu"},
{"letter_xu"},
{"letter_yu"},
{"letter_zu"},
}
function letter_cutter:get_output_inv_lower(modname, subname, amount, max)
local list = {}
if amount < 1 then
return list
end
for i, t in ipairs(letter_cutter.names) do
for i, t in ipairs(letter_cutter.names_lower) do
table.insert(list, modname .. ":" .. subname .. "_" .. t[1]
.. " " .. math.min(math.floor(amount/cost), max))
end
return list
end
function letter_cutter:get_output_inv_upper(modname, subname, amount, max)
local list = {}
if amount < 1 then
return list
end
for i, t in ipairs(letter_cutter.names_upper) do
table.insert(list, modname .. ":" .. subname .. "_" .. t[1]
.. " " .. math.min(math.floor(amount/cost), max))
end
@ -126,7 +192,7 @@ function letter_cutter:reset(pos)
meta:get_string("owner")..")")
end
function letter_cutter:update_inventory(pos, amount)
function letter_cutter:update_inventory_lower(pos, amount)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -154,7 +220,7 @@ function letter_cutter:update_inventory(pos, amount)
-- Display:
inv:set_list("output",
self:get_output_inv(modname, material, amount,
self:get_output_inv_lower(modname, material, amount,
meta:get_int("max_offered")))
-- Store how many microblocks are available:
meta:set_int("anz", amount)
@ -164,17 +230,43 @@ function letter_cutter:update_inventory(pos, amount)
meta:get_string("owner")..")")
end
function letter_cutter:update_inventory_upper(pos, amount)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
--[[ The amount of items offered per shape can be configured:
function letter_cutter.on_receive_fields(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
local max = tonumber(fields.max_offered)
if max and max > 0 then
meta:set_string("max_offered", max)
-- Update to show the correct number of items:
letter_cutter:update_inventory(pos, 0)
amount = meta:get_int("anz") + amount
if amount < 1 then -- If the last block is taken out.
self:reset(pos)
return
end
end]]
local stack = inv:get_stack("input", 1)
if stack:is_empty() then
self:reset(pos)
return
end
local node_name = stack:get_name() or ""
local name_parts = letter_cutter.known_nodes[node_name] or ""
local modname = name_parts[1] or ""
local material = name_parts[2] or ""
inv:set_list("input", {
node_name.. " " .. math.floor(amount)
})
-- Display:
inv:set_list("output",
self:get_output_inv_upper(modname, material, amount,
meta:get_int("max_offered")))
-- Store how many microblocks are available:
meta:set_int("anz", amount)
meta:set_string("infotext",
"Letter Cutter is working (owned by "..
meta:get_string("owner")..")")
end
function letter_cutter.allow_metadata_inventory_move(
@ -211,7 +303,7 @@ function letter_cutter.allow_metadata_inventory_put(
end
end
function letter_cutter.on_metadata_inventory_put(
function letter_cutter.on_metadata_inventory_put_lower(
pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
@ -219,18 +311,42 @@ function letter_cutter.on_metadata_inventory_put(
local count = stack:get_count()
if listname == "input" then
letter_cutter:update_inventory(pos, count)
letter_cutter:update_inventory_lower(pos, count)
end
end
function letter_cutter.on_metadata_inventory_take(
function letter_cutter.on_metadata_inventory_put_upper(
pos, listname, index, stack, player)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local stackname = stack:get_name()
local count = stack:get_count()
if listname == "input" then
letter_cutter:update_inventory_upper(pos, count)
end
end
function letter_cutter.on_metadata_inventory_take_lower(
pos, listname, index, stack, player)
if listname == "output" then
-- We do know how much each block at each position costs:
letter_cutter:update_inventory(pos, 8 * -cost)
letter_cutter:update_inventory_lower(pos, 8 * -cost)
elseif listname == "input" then
-- Each normal (= full) block taken costs 8 microblocks:
letter_cutter:update_inventory(pos, 8 * -stack:get_count())
letter_cutter:update_inventory_lower(pos, 8 * -stack:get_count())
end
-- The recycle field plays no role here since it is processed immediately.
end
function letter_cutter.on_metadata_inventory_take_upper(
pos, listname, index, stack, player)
if listname == "output" then
-- We do know how much each block at each position costs:
letter_cutter:update_inventory_upper(pos, 8 * -cost)
elseif listname == "input" then
-- Each normal (= full) block taken costs 8 microblocks:
letter_cutter:update_inventory_upper(pos, 8 * -stack:get_count())
end
-- The recycle field plays no role here since it is processed immediately.
end
@ -266,7 +382,7 @@ function letter_cutter.can_dig(pos,player)
return true
end
minetest.register_node("letters:letter_cutter", {
minetest.register_node("letters:letter_cutter_lower", {
description = "Leter Cutter",
drawtype = "nodebox",
node_box = {
@ -309,8 +425,55 @@ minetest.register_node("letters:letter_cutter", {
allow_metadata_inventory_put = letter_cutter.allow_metadata_inventory_put,
-- Taking is allowed from all slots (even the internal microblock slot). Moving is forbidden.
-- Putting something in is slightly more complicated than taking anything because we have to make sure it is of a suitable material:
on_metadata_inventory_put = letter_cutter.on_metadata_inventory_put,
on_metadata_inventory_take = letter_cutter.on_metadata_inventory_take,
on_metadata_inventory_put = letter_cutter.on_metadata_inventory_put_lower,
on_metadata_inventory_take = letter_cutter.on_metadata_inventory_take_lower,
})
minetest.register_node("letters:letter_cutter_upper", {
description = "Leter Cutter",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.4375, -0.5, -0.4375, -0.3125, 0.125, -0.3125}, -- NodeBox1
{-0.4375, -0.5, 0.3125, -0.3125, 0.125, 0.4375}, -- NodeBox2
{0.3125, -0.5, 0.3125, 0.4375, 0.125, 0.4375}, -- NodeBox3
{0.3125, -0.5, -0.4375, 0.4375, 0.125, -0.3125}, -- NodeBox4
{-0.5, 0.0625, -0.5, 0.5, 0.25, 0.5}, -- NodeBox5
{0.125, 0.25, -0.1875, 0.3125, 0.3125, -0.125}, -- NodeBox6
{-0.125, 0.25, -0.125, 0.125, 0.3125, -0.0625}, -- NodeBox7
{-0.3125, 0.25, -0.0625, -0.0625, 0.3125, 0.0625}, -- NodeBox8
{-0.125, 0.25, 0.0625, 0.125, 0.3125, 0.125}, -- NodeBox9
{0.125, 0.25, 0.125, 0.3125, 0.3125, 0.1875}, -- NodeBox10
{0.125, 0.25, -0.125, 0.1875, 0.3125, 0.125}, -- NodeBox11
},
},
tiles = {"letters_letter_cutter_top.png",
"default_tree.png",
"letters_letter_cutter_side.png"},
paramtype = "light",
sunlight_propagates = true,
paramtype2 = "facedir",
groups = {choppy = 2,oddly_breakable_by_hand = 2},
sounds = default.node_sound_wood_defaults(),
on_construct = letter_cutter.on_construct,
can_dig = letter_cutter.can_dig,
-- Set the owner of this circular saw.
after_place_node = function(pos, placer)
local meta = minetest.get_meta(pos)
local owner = placer and placer:get_player_name() or ""
meta:set_string("owner", owner)
meta:set_string("infotext",
"Letter Cutter is empty (owned by "
..meta:get_string("owner")..")")
end,
allow_metadata_inventory_move = letter_cutter.allow_metadata_inventory_move,
-- Only input- and recycle-slot are intended as input slots:
allow_metadata_inventory_put = letter_cutter.allow_metadata_inventory_put,
-- Taking is allowed from all slots (even the internal microblock slot). Moving is forbidden.
-- Putting something in is slightly more complicated than taking anything because we have to make sure it is of a suitable material:
on_metadata_inventory_put = letter_cutter.on_metadata_inventory_put_upper,
on_metadata_inventory_take = letter_cutter.on_metadata_inventory_take_upper,
})

View File

@ -17,3 +17,20 @@ if minetest.get_modpath("darkage") then
letters.register_letters("darkage", "marble_tile", "darkage:marble_tile", "Marble Tile", "darkage_marble_tile.png")
letters.register_letters("darkage", "slate_tile", "darkage:slate_tile", "Slate Tile", "darkage_slate_tile.png")
end
if minetest.get_modpath("colouredstonebricks") then
letters.register_letters("colouredstonebricks", "black", "colouredstonebricks:black", "Black", "colouredstonebricks_black.png")
letters.register_letters("colouredstonebricks", "cyan", "colouredstonebricks:cyan", "Cyan", "colouredstonebricks_cyan.png")
letters.register_letters("colouredstonebricks", "brown", "colouredstonebricks:brown", "Brown", "colouredstonebricks_brown.png")
letters.register_letters("colouredstonebricks", "dark_blue", "colouredstonebricks:dark_blue", "Dark Blue", "colouredstonebricks_dark_blue.png")
letters.register_letters("colouredstonebricks", "dark_green", "colouredstonebricks:dark_green", "Dark Green", "colouredstonebricks_dark_green.png")
letters.register_letters("colouredstonebricks", "dark_grey", "colouredstonebricks:dark_grey", "Dark Gey", "colouredstonebricks_dark_grey.png")
letters.register_letters("colouredstonebricks", "dark_pink", "colouredstonebricks:dark_pink", "Dark Pink", "colouredstonebricks_dark_pink.png")
letters.register_letters("colouredstonebricks", "green", "colouredstonebricks:green", "Green", "colouredstonebricks_green.png")
letters.register_letters("colouredstonebricks", "grey", "colouredstonebricks:grey", "Grey", "colouredstonebricks_grey.png")
letters.register_letters("colouredstonebricks", "orange", "colouredstonebricks:orange", "Orange", "colouredstonebricks_orange.png")
letters.register_letters("colouredstonebricks", "pink", "colouredstonebricks:pink", "Pink", "colouredstonebricks_pink.png")
letters.register_letters("colouredstonebricks", "purple", "colouredstonebricks:purple", "Purple", "colouredstonebricks_purple.png")
letters.register_letters("colouredstonebricks", "red", "colouredstonebricks:red", "Red", "colouredstonebricks_red.png")
letters.register_letters("colouredstonebricks", "white", "colouredstonebricks:white", "White", "colouredstonebricks_white.png")
letters.register_letters("colouredstonebricks", "yellow", "colouredstonebricks:yellow", "Yellow", "colouredstonebricks_yellow.png")
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B