Titleize displayed egg names

master
Jordan Irwin 2021-05-05 10:21:03 -07:00
parent 407eff6196
commit 7139c627d2
2 changed files with 18 additions and 1 deletions

View File

@ -1,4 +1,8 @@
1.1
- Egg names are titleized & underscores are replaced with space.
1.0
- Made independent of any other mods or games.
- Renamed to "asm_spawneggs" (Another Spawneggs Mod).

15
api.lua
View File

@ -53,6 +53,19 @@ end
asm.addEggRecipe = asm.registerEggRecipe
local function formatTitle(s)
s = s:gsub("_", " ")
local t = {}
for m in (s .. " "):gmatch("(.-) ") do
local v = m:gsub("^%l", string.upper)
table.insert(t, v)
end
return table.concat(t, " ") .. " Spawn Egg"
end
--- Registers new egg in game.
--
-- Alias: *asm.addEgg*
@ -66,7 +79,7 @@ asm.registerEgg = function(def)
end
core.register_craftitem(":spawneggs:" .. def.name:lower(), {
description = def.name:gsub("^%l", string.upper) .. " Spawn Egg",
description = formatTitle(def.name),
inventory_image = img,
on_place = function(itemstack, placer, target)