Skip to content

Commit

Permalink
Unified inventory compat (#4)
Browse files Browse the repository at this point in the history
* add mandarin stickers

I'm aware that this is just a mirror repo. The upstream repo does not offer method of submitting PR so I'm posting here for them to pull from.

* make additional chars available for crafting

* add support for unified_inventory

* remove debug print

* don't add to guides if unified_inventory isn't on

for backward compatibility

* machine and block aren't ground content

essentially PR #3
  • Loading branch information
SwissalpS authored Dec 14, 2024
1 parent 989ecff commit 9cd3c6c
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 70 deletions.
2 changes: 2 additions & 0 deletions depends.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
default
intllib?
unified_inventory?

239 changes: 169 additions & 70 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,81 +54,115 @@ table_merge(characters, special_chars)
table_merge(characters, german_chars)
table_merge(characters, cyrillic_chars)
table_merge(characters, greek_chars)
table_merge(characters, additional_chars)

table_merge(characters_sticker, characters)
table_merge(characters_sticker, additional_chars)
table.insert(characters_sticker, " ")

local create_alias = true

local ui = minetest.get_modpath("unified_inventory")
and minetest.global_exists("unified_inventory") and unified_inventory
local add_to_guides = ui and true or false

if ui then
ui.register_craft_type("ehlphabet", {
description = "Printing",
icon = 'ehlphabet_machine_front.png',
width = 1,
height = 1
})
end

-- generate all available blocks
for _, name in ipairs(characters) do
local desc = S("Ehlphabet Block '@1'", name)
local byte = name:byte()
local mb = is_multibyte(name)
local file, key

if mb then
mb = byte
byte = name:byte(2)
key = "ehlphabet:" .. mb .. byte
file = ("%03d_%03d"):format(mb, byte)
else
key = "ehlphabet:" .. byte
file = ("%03d"):format(byte)
end
local function generate(characters, craftable)
for _, name in ipairs(characters) do
local desc = S("Ehlphabet Block '@1'", name)
local byte = name:byte()
local mb = is_multibyte(name)
local file, key

if mb then
mb = byte
byte = name:byte(2)
key = "ehlphabet:" .. mb .. byte
file = ("%03d_%03d"):format(mb, byte)
else
key = "ehlphabet:" .. byte
file = ("%03d"):format(byte)
end

minetest.register_node(
key,
{
description = desc,
tiles = {"ehlphabet_" .. file .. ".png"},
paramtype2 = "facedir", -- neu
on_rotate = screwdriver.rotate_simple , -- neu
is_ground_content = false, --neu
groups = {cracky = 3, not_in_creative_inventory = 1, not_in_crafting_guide = 1, ehlphabet_block = 1}
}
)
-- minetest.register_craft({type = "shapeless", output = "ehlphabet:block", recipe = {key}})

if create_alias then
minetest.register_alias("abjphabet:" .. name, key)
end
minetest.register_node(
key,
{
description = desc,
tiles = {"ehlphabet_" .. file .. ".png"},
paramtype2 = "facedir", -- neu
on_rotate = screwdriver.rotate_simple , -- neu
is_ground_content = false, --neu
groups = {
cracky = 3,
not_in_creative_inventory = craftable and 0 or 1,
not_in_crafting_guide = craftable and 0 or 1,
ehlphabet_block = 1
}
}
)
-- minetest.register_craft({type = "shapeless", output = "ehlphabet:block", recipe = {key}})

if create_alias then
minetest.register_alias("abjphabet:" .. name, key)
end

-- deactivate alias creation on last latin character
if name == "Z" then
create_alias = false
end
-- deactivate alias creation on last latin character
if name == "Z" then
create_alias = false
end

minetest.register_node(
key.."_sticker",
{
description = desc.."Sticker",
tiles = { "ehlphabet_" .. file .. ".png",
"ehlphabet_" .. file .. ".png^[transformR180" },
inventory_image = "ehlphabet_" .. file .. ".png",
paramtype = "light",
paramtype2 = "wallmounted", -- "colorwallmounted",
on_rotate = screwdriver.rotate_simple ,
drawtype = "nodebox",
is_ground_content = false,
drop = "", -- new
node_box = {
type = "wallmounted",
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -0.49, 0.5},
wall_top = {-0.5, 0.49, -0.5, 0.5, 0.5, 0.5},
wall_side = {-0.5, -0.5, -0.5, -0.49, 0.5, 0.5},
minetest.register_node(
key.."_sticker",
{
description = desc.."Sticker",
tiles = {"ehlphabet_" .. file .. ".png"},
paramtype = "light",
paramtype2 = "wallmounted", -- "colorwallmounted",
on_rotate = screwdriver.rotate_simple ,
drawtype = "nodebox",
is_ground_content = false,
drop = "", -- new
node_box = {
type = "wallmounted",
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -0.49, 0.5},
wall_top = {-0.5, 0.49, -0.5, 0.5, 0.5, 0.5},
wall_side = {-0.5, -0.5, -0.5, -0.49, 0.5, 0.5},
},
groups = {
attached_node = 1,
dig_immediate = 2,
not_in_creative_inventory = craftable and 0 or 1,
not_in_crafting_guide = craftable and 0 or 1,
not_blocking_trains = 1,
},
groups = {attached_node = 1, dig_immediate = 2,
not_in_creative_inventory = 1,
not_blocking_trains = 1 },
}
)


}
)

if ui then
ui.register_craft({
type = "ehlphabet",
items = { "ehlphabet:block" },
output = key
})
ui.register_craft({
type = "ehlphabet",
items = { "default:paper" },
output = key .. "_sticker"
})
end

end
end

generate(characters, add_to_guides)
generate(additional_chars, true)
minetest.register_craft({type = "shapeless", output = "ehlphabet:block", recipe = {"group:ehlphabet_block"}})


Expand All @@ -145,19 +179,19 @@ minetest.register_node(
description = desc.."Sticker",
tiles = {"ehlphabet_000.png"},
paramtype = "light",
paramtype2 = "wallmounted", -- "colorwallmounted",
on_rotate = screwdriver.rotate_simple ,
paramtype2 = "wallmounted", -- "colorwallmounted",
on_rotate = screwdriver.rotate_simple ,
drawtype = "nodebox",
is_ground_content = false,
is_ground_content = false,
drop = "", -- new
node_box = {
type = "wallmounted",
wall_bottom = {-0.5, -0.5, -0.5, 0.5, -0.49, 0.5},
wall_top = {-0.5, 0.49, -0.5, 0.5, 0.5, 0.5},
wall_side = {-0.5, -0.5, -0.5, -0.49, 0.5, 0.5},
},
groups = {attached_node = 1, dig_immediate = 2,
not_in_creative_inventory = 1,
groups = {attached_node = 1, dig_immediate = 2,
not_in_creative_inventory = 1,
not_blocking_trains = 1 },
}
)
Expand All @@ -179,6 +213,7 @@ minetest.register_node(
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 2},
is_ground_content = false,

-- "Can you dig it?" -Cyrus
can_dig = function(pos, player)
Expand Down Expand Up @@ -224,7 +259,7 @@ minetest.register_node(
local ch = fields.lettername

if ch ~= nil and ch ~= "" then
if inputstack:get_name() == "ehlphabet:block"
if inputstack:get_name() == "ehlphabet:block"
or inputstack:get_name() == "default:paper" then
local ost = outputstack:get_name()
local mb = is_multibyte(ch)
Expand All @@ -233,7 +268,7 @@ minetest.register_node(
if ost ~= "" and
ost ~= "ehlphabet:"..key then
-- other type in output slot -> abort
return
return
end
local clist = characters
if inputstack:get_name() == "default:paper" then
Expand Down Expand Up @@ -263,6 +298,7 @@ minetest.register_node(
{
description = S("Ehlphabet Block (blank)"),
tiles = {"ehlphabet_000.png"},
is_ground_content = false,
groups = {cracky = 3}
}
)
Expand Down Expand Up @@ -358,9 +394,72 @@ minetest.register_craft({
}
})

-- stickers
minetest.register_craft({
output = "ehlphabet:231140_sticker 4",
recipe = {
{"", "", ""},
{"ehlphabet:78_sticker", "", ""},
{"ehlphabet:69_sticker", "ehlphabet:75_sticker", "ehlphabet:79_sticker"}
}
})

minetest.register_craft({
output = "ehlphabet:229140_sticker 5",
recipe = {
{"ehlphabet:78_sticker", "ehlphabet:79_sticker", "ehlphabet:82_sticker"},
{"ehlphabet:84_sticker", "ehlphabet:72_sticker", ""},
{"", "", ""},
}
})

minetest.register_craft({
output = "ehlphabet:228184_sticker 5",
recipe = {
{"ehlphabet:69_sticker", "ehlphabet:65_sticker", "ehlphabet:83_sticker"},
{"ehlphabet:84_sticker", "", "ehlphabet:83_sticker"},
{"", "", ""},
}
})

minetest.register_craft({
output = "ehlphabet:230157_sticker 5",
recipe = {
{"ehlphabet:69_sticker", "ehlphabet:65_sticker", "ehlphabet:83_sticker"},
{"ehlphabet:84_sticker", "", "ehlphabet:84_sticker"},
{"", "", ""},
}
})

minetest.register_craft({
output = "ehlphabet:229141_sticker 5",
recipe = {
{"ehlphabet:83_sticker", "ehlphabet:79_sticker", "ehlphabet:85_sticker"},
{"ehlphabet:84_sticker", "ehlphabet:72_sticker", ""},
{"", "", ""},
}
})

minetest.register_craft({
output = "ehlphabet:232165_sticker 4",
recipe = {
{"ehlphabet:87_sticker", "ehlphabet:69_sticker", "ehlphabet:83_sticker"},
{"ehlphabet:84_sticker", "", ""},
{"", "", ""},
}
})

minetest.register_craft({
output = "ehlphabet:231171_sticker 7",
recipe = {
{"ehlphabet:83_sticker", "ehlphabet:84_sticker", "ehlphabet:65_sticker"},
{"ehlphabet:84_sticker", "ehlphabet:73_sticker", "ehlphabet:79_sticker"},
{"ehlphabet:78_sticker", "", ""},
}
})




print("[ehlphabet] loaded")

-- print(S("[MOD] Elphabet is loaded"))

0 comments on commit 9cd3c6c

Please sign in to comment.