123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- local ModularTextureHandler =
- dofile(minetest.get_modpath("dwarf_characters") .. "/modular_texture_api.lua")
- ModularTextureHandler("skin")
- ModularTextureHandler("beard")
- ModularTextureHandler("hair")
- ModularTextureHandler("armor")
- ModularTextureHandler("helmet")
- do --Skins
- local apply_color = function(self, mod)
- return self[1] .. mod
- end
- local normal_skin = {"dwarf_characters_skin.png", process = apply_color}
- dwarf_characters.register_skin("normal",
- {
- arm_skin_left = normal_skin,
- arm_skin_right = normal_skin,
- leg_skin_left = normal_skin,
- leg_skin_right = normal_skin,
- head =
- {
- "dwarf_characters_skin.png",
- process =
- function(self, colormod)
- return "(" .. self[1]..colormod .. ")^dwarf_characters_eyes.png"
- end
- },
- torso_skin =
- {
- "dwarf_characters_skin.png^dwarf_characters_torso_defined.png",
- process = apply_color
- },
- })
- end
- do --Beards
- --[[
- For dwarves, female beards are softer and don't grow as big as
- male beards so we need a distinction.
- ]]
- local oldregb = dwarf_characters.register_beard
- local oldgetrb = dwarf_characters.get_random_beard
- local masculinebeards = {}
- local femininebeards = {}
- function dwarf_characters.register_beard(name, def)
- local sex = def.sex
- if sex == "m"
- then
- table.insert(masculinebeards, name)
- elseif sex == "f"
- then
- table.insert(femininebeards, name)
- else
- table.insert(masculinebeards, name)
- table.insert(femininebeards, name)
- end
- def.sex = nil --save a little memory
- oldregb(name, def)
- end
- function dwarf_characters.get_random_beard(sex)
- if sex == "m"
- then
- return masculinebeards[math.random(#masculinebeards)]
- elseif sex == "f"
- then
- return femininebeards[math.random(#femininebeards)]
- else
- return oldgetrb()
- end
- end
- dwarf_characters.register_beard("masc_long",
- {
- hair = {"dwarf_characters_beard.png"},
- sex = "m"
- })
- dwarf_characters.register_beard("gerold",
- {
- hair = {"dwarf_characters_gerold_beard.png"}
- })
- end
- do --Hair
- dwarf_characters.register_hair("short_ponytail",
- {
- hair = {"dwarf_characters_hair_short_ponytail.png"}
- })
- end
- do --Armors
- dwarf_characters.register_armor("berserker_pants",
- {
- leg_armor_left = {"dwarf_characters_armor_legs.png"},
- leg_armor_right = {"dwarf_characters_armor_legs.png"},
- torso_armor = {"dwarf_characters_armor.png"}
- })
- end
- do --Helmets
- dwarf_characters.register_helmet("cockatoo_helmet",
- {
- helmet = {"dwarf_characters_helmet.png"},
- })
- dwarf_characters.register_helmet("nothing",
- {
- helmet = {"dwarf_characters_blank.png"},
- })
- end
- do --Models
- dwarf_characters.register_model(
- "dwarf_characters_masc.b3d", "Masculine Dwarf", "m")
- dwarf_characters.register_model(
- "dwarf_characters_fem.b3d", "Feminine Dwarf", "f")
- end
|