nc_cats-cd2025/names.lua
Aaron Suen 5f379fe71a Better distribute cat names
When cat names are used, they become
less favored compared to other less-used
names, to prevent any one name from being
overused when there are lots of cats.
2022-01-15 20:46:44 -05:00

128 lines
1.7 KiB
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore, pairs
= minetest, nodecore, pairs
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
local myapi = _G[modname]
local modstore = minetest.get_mod_storage()
local names = {
"Abby",
"Apple Jack",
"Archie",
"Ash",
"Bear",
"Bella",
"Belle",
"Binx",
"Blossom",
"Bob",
"Boo",
"Boots",
"Bubbles",
"Buddy",
"Buttercup",
"Calvin",
"Charlie",
"Chloe",
"Cleo",
"Clover",
"Clyde",
"Coco",
"Cricket",
"Daisy",
"Dottie",
"Ducky",
"Emma",
"Fluffy",
"Frank",
"Frankie",
"Ginger",
"Gizmo",
"Gus",
"Hazel",
"Iris",
"Jack",
"Jackson",
"Jax",
"Joey",
"Kiki",
"Kitty",
"Koosh",
"Leo",
"Lily",
"Loki",
"Lola",
"Louie",
"Lucky",
"Lucy",
"Luigi",
"Lulu",
"Maggie",
"Marley",
"Midnight",
"Millie",
"Milo",
"Minnie",
"Mittens",
"Mochi",
"Moose",
"Murphy",
"Nala",
"Olivia",
"Ollie",
"Oreo",
"Oscar",
"Peanut",
"Penny",
"Pepper",
"Piper",
"Pixie",
"Polly",
"Poppy",
"Princess",
"Pumpkin",
"Riley",
"Rocky",
"Romeo",
"Rose",
"Rosie",
"Ruby",
"Salem",
"Sam",
"Scout",
"Simba",
"Sophie",
"Sunny",
"Sunshine",
"Teddy",
"Thor",
"Tiger",
"Tigger",
"Toby",
"Tucker",
"Willow",
}
local nameidx = {}
for _, v in pairs(names) do
nodecore.translate_inform(v)
nameidx[v] = modstore:get_int(v) or 0
end
local desc = "description"
myapi.setname = function(meta)
local name = meta:get_string(desc)
if (not name) or name == "" then
local _
_, name = nodecore.pickrand(nameidx, function(v) return 1 / (1 + v) end)
nameidx[name] = nameidx[name] + 1
modstore:set_int(name, nameidx[name])
meta:set_string(desc, name)
end
return name
end