2018-03-29 14:48:09 -07:00
|
|
|
|
local digits = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}
|
|
|
|
|
local base_chars = {
|
|
|
|
|
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
|
|
|
|
|
"P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
|
|
|
|
|
}
|
|
|
|
|
local special_chars = {
|
|
|
|
|
"!", "#", "$", "%", "&", "(", ")", "*", "+", ",", "-", ".", "/", ":", ";",
|
|
|
|
|
"<", "=", ">", "?", "@", "'", '"'
|
|
|
|
|
}
|
2018-03-31 12:32:15 -07:00
|
|
|
|
local german_chars = {"Ä", "Ö", "Ü", "ß"}
|
2018-03-29 14:48:09 -07:00
|
|
|
|
local cyrillic_chars = {
|
|
|
|
|
"А", "Б", "В", "Г", "Д", "Е", "Ё", "Ж", "З", "И", "Й", "К", "Л", "М", "Н",
|
|
|
|
|
"О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ъ", "Ы", "Ь",
|
|
|
|
|
"Э", "Ю", "Я"
|
|
|
|
|
}
|
2019-03-01 10:55:30 -08:00
|
|
|
|
local greek_chars = {
|
|
|
|
|
"Α", "Β", "Γ", "Δ", "Ε", "Ζ", "Η", "Θ", "Ι", "Κ", "Λ", "Μ", "Ν", "Ξ", "Ο",
|
|
|
|
|
"Π", "Ρ", "Σ", "Τ", "Υ", "Φ", "Χ", "Ψ", "Ω"
|
|
|
|
|
}
|
|
|
|
|
local additional_chars = {
|
2019-05-23 08:14:14 -07:00
|
|
|
|
"猫","北","东","東","南","西","站",
|
2019-03-01 10:55:30 -08:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-29 14:48:09 -07:00
|
|
|
|
local characters = {}
|
|
|
|
|
|
|
|
|
|
ehlphabet = {}
|
|
|
|
|
ehlphabet.path = minetest.get_modpath(minetest.get_current_modname())
|
|
|
|
|
|
2018-03-31 15:24:40 -07:00
|
|
|
|
-- Intllib
|
|
|
|
|
local S, NS = dofile(ehlphabet.path .. "/intllib.lua")
|
|
|
|
|
ehlphabet.intllib = S
|
|
|
|
|
|
2018-03-29 14:48:09 -07:00
|
|
|
|
local function table_merge(t1, t2)
|
|
|
|
|
for k, v in ipairs(t2) do
|
|
|
|
|
table.insert(t1, v)
|
|
|
|
|
end
|
|
|
|
|
return t1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function is_multibyte(ch)
|
|
|
|
|
local byte = ch:byte()
|
2019-03-01 10:55:30 -08:00
|
|
|
|
-- return (195 == byte) or (208 == byte) or (209 == byte)
|
2019-03-22 06:40:05 -07:00
|
|
|
|
if not byte then
|
|
|
|
|
return false
|
|
|
|
|
else
|
|
|
|
|
return (byte > 191)
|
|
|
|
|
end
|
2018-03-29 14:48:09 -07:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
table_merge(characters, base_chars)
|
|
|
|
|
table_merge(characters, digits)
|
|
|
|
|
table_merge(characters, special_chars)
|
2018-03-31 12:32:15 -07:00
|
|
|
|
table_merge(characters, german_chars)
|
2018-03-29 14:48:09 -07:00
|
|
|
|
table_merge(characters, cyrillic_chars)
|
2019-03-01 10:55:30 -08:00
|
|
|
|
table_merge(characters, greek_chars)
|
|
|
|
|
table_merge(characters, additional_chars)
|
2018-03-29 14:48:09 -07:00
|
|
|
|
|
|
|
|
|
local create_alias = true
|
|
|
|
|
|
|
|
|
|
-- generate all available blocks
|
|
|
|
|
for _, name in ipairs(characters) do
|
2018-03-31 15:24:40 -07:00
|
|
|
|
local desc = S("Ehlphabet Block '@1'", name)
|
2018-03-29 14:48:09 -07:00
|
|
|
|
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,
|
|
|
|
|
{
|
2018-03-31 15:24:40 -07:00
|
|
|
|
description = desc,
|
2018-03-29 14:48:09 -07:00
|
|
|
|
tiles = {"ehlphabet_" .. file .. ".png"},
|
2018-05-03 09:05:50 -07:00
|
|
|
|
paramtype2 = "facedir", -- neu
|
|
|
|
|
on_rotate = screwdriver.rotate_simple , -- neu
|
|
|
|
|
is_ground_content = false, --neu
|
2018-03-29 14:48:09 -07:00
|
|
|
|
groups = {cracky = 3, not_in_creative_inventory = 1, not_in_crafting_guide = 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
|
2017-12-13 20:37:51 -08:00
|
|
|
|
end
|
|
|
|
|
|
2018-03-29 14:48:09 -07:00
|
|
|
|
minetest.register_node(
|
|
|
|
|
"ehlphabet:machine",
|
|
|
|
|
{
|
2018-03-31 15:24:40 -07:00
|
|
|
|
description = S("Letter Machine"),
|
2018-03-29 14:48:09 -07:00
|
|
|
|
tiles = {
|
|
|
|
|
"ehlphabet_machine_top.png",
|
|
|
|
|
"ehlphabet_machine_bottom.png",
|
|
|
|
|
"ehlphabet_machine_side.png",
|
|
|
|
|
"ehlphabet_machine_side.png",
|
|
|
|
|
"ehlphabet_machine_back.png",
|
|
|
|
|
"ehlphabet_machine_front.png"
|
|
|
|
|
},
|
|
|
|
|
paramtype = "light",
|
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
|
groups = {cracky = 2},
|
|
|
|
|
|
|
|
|
|
-- "Can you dig it?" -Cyrus
|
|
|
|
|
can_dig = function(pos, player)
|
|
|
|
|
local meta = minetest.env:get_meta(pos)
|
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
|
if not inv:is_empty("input") or not inv:is_empty("output") then
|
|
|
|
|
if player then
|
|
|
|
|
minetest.chat_send_player(
|
|
|
|
|
player:get_player_name(),
|
2018-03-31 15:24:40 -07:00
|
|
|
|
S("You cannot dig the @1 with blocks inside", S("Letter Machine"))
|
2018-03-29 14:48:09 -07:00
|
|
|
|
)
|
|
|
|
|
end -- end if player
|
|
|
|
|
return false
|
|
|
|
|
end -- end if not empty
|
|
|
|
|
return true
|
|
|
|
|
end, -- end can_dig function
|
|
|
|
|
|
|
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
|
local meta = minetest.env:get_meta(pos)
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
on_construct = function(pos)
|
|
|
|
|
local meta = minetest.env:get_meta(pos)
|
|
|
|
|
meta:set_string(
|
|
|
|
|
"formspec",
|
|
|
|
|
"invsize[8,6;]" ..
|
2018-03-31 15:24:40 -07:00
|
|
|
|
"field[3.8,.5;1,1;lettername;" .. S("Letter") .. ";]" ..
|
2018-03-29 14:48:09 -07:00
|
|
|
|
"list[current_name;input;2.5,0.2;1,1;]" ..
|
|
|
|
|
"list[current_name;output;4.5,0.2;1,1;]" ..
|
|
|
|
|
"list[current_player;main;0,2;8,4;]" ..
|
2018-03-31 15:24:40 -07:00
|
|
|
|
"button[2.54,-0.25;3,4;name;" .. S("Blank -> Letter") .. "]"
|
2018-03-29 14:48:09 -07:00
|
|
|
|
)
|
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
|
inv:set_size("input", 1)
|
|
|
|
|
inv:set_size("output", 1)
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
|
|
on_receive_fields = function(pos, formname, fields, sender)
|
|
|
|
|
local meta = minetest.env:get_meta(pos)
|
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
|
local inputstack = inv:get_stack("input", 1)
|
|
|
|
|
local ch = fields.lettername
|
|
|
|
|
|
|
|
|
|
if ch ~= nil and inputstack:get_name() == "ehlphabet:block" then
|
|
|
|
|
local mb = is_multibyte(ch)
|
|
|
|
|
local key = mb and (ch:byte(1) .. ch:byte(2)) or ch:byte()
|
|
|
|
|
for _, v in pairs(characters) do
|
2018-03-31 12:32:15 -07:00
|
|
|
|
if v == ch then
|
2018-03-29 14:48:09 -07:00
|
|
|
|
local give = {}
|
|
|
|
|
give[1] = inv:add_item("output", "ehlphabet:" .. key)
|
|
|
|
|
inputstack:take_item()
|
|
|
|
|
inv:set_stack("input", 1, inputstack)
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
2017-12-13 20:37:51 -08:00
|
|
|
|
end
|
2018-03-29 14:48:09 -07:00
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
)
|
2017-12-13 20:37:51 -08:00
|
|
|
|
|
2018-03-29 14:48:09 -07:00
|
|
|
|
-- Alias (Och_Noe 20180124)
|
|
|
|
|
minetest.register_alias("abjphabet:machine", "ehlphabet:machine")
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
minetest.register_node(
|
|
|
|
|
"ehlphabet:block",
|
|
|
|
|
{
|
2018-03-31 15:24:40 -07:00
|
|
|
|
description = S("Ehlphabet Block (blank)"),
|
2018-03-29 14:48:09 -07:00
|
|
|
|
tiles = {"ehlphabet_000.png"},
|
|
|
|
|
groups = {cracky = 3}
|
|
|
|
|
}
|
|
|
|
|
)
|
2017-12-13 20:37:51 -08:00
|
|
|
|
|
|
|
|
|
--RECIPE: blank blocks
|
2018-03-29 14:48:09 -07:00
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:block 8",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"default:paper", "default:paper", "default:paper"},
|
|
|
|
|
{"default:paper", "", "default:paper"},
|
|
|
|
|
{"default:paper", "default:paper", "default:paper"}
|
|
|
|
|
}
|
2017-12-13 20:37:51 -08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
--RECIPE: build the machine!
|
2018-03-29 14:48:09 -07:00
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:machine",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"default:stick", "default:coal_lump", "default:stick"},
|
|
|
|
|
{"default:coal_lump", "ehlphabet:block", "default:coal_lump"},
|
|
|
|
|
{"default:stick", "default:coal_lump", "default:stick"}
|
|
|
|
|
}
|
2017-12-13 20:37:51 -08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
--RECIPE: craft unused blocks back into paper
|
2018-03-29 14:48:09 -07:00
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "default:paper",
|
|
|
|
|
recipe = {"ehlphabet:block"},
|
|
|
|
|
type = "shapeless"
|
2017-12-13 20:37:51 -08:00
|
|
|
|
})
|
2018-03-31 15:24:40 -07:00
|
|
|
|
|
2019-04-30 21:23:44 -07:00
|
|
|
|
-- Chinese Characters - craft from latin characters
|
2019-03-01 10:55:30 -08:00
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:231140 4",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"", "", ""},
|
|
|
|
|
{"ehlphabet:78", "", ""},
|
|
|
|
|
{"ehlphabet:69", "ehlphabet:75", "ehlphabet:79"}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2019-04-30 21:23:44 -07:00
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:229140 5",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"ehlphabet:78", "ehlphabet:79", "ehlphabet:82"},
|
|
|
|
|
{"ehlphabet:84", "ehlphabet:72", ""},
|
|
|
|
|
{"", "", ""},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:228184 5",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"ehlphabet:69", "ehlphabet:65", "ehlphabet:83"},
|
|
|
|
|
{"ehlphabet:84", "", "ehlphabet:83"},
|
|
|
|
|
{"", "", ""},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:230157 5",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"ehlphabet:69", "ehlphabet:65", "ehlphabet:83"},
|
|
|
|
|
{"ehlphabet:84", "", "ehlphabet:84"},
|
|
|
|
|
{"", "", ""},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:229141 5",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"ehlphabet:83", "ehlphabet:79", "ehlphabet:85"},
|
|
|
|
|
{"ehlphabet:84", "ehlphabet:72", ""},
|
|
|
|
|
{"", "", ""},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
|
output = "ehlphabet:232165 4",
|
|
|
|
|
recipe = {
|
|
|
|
|
{"ehlphabet:87", "ehlphabet:69", "ehlphabet:83"},
|
|
|
|
|
{"ehlphabet:84", "", ""},
|
|
|
|
|
{"", "", ""},
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-01 10:55:30 -08:00
|
|
|
|
|
|
|
|
|
|
2018-03-31 15:24:40 -07:00
|
|
|
|
-- print(S("[MOD] Elphabet is loaded"))
|