104 lines
No EOL
2.8 KiB
Lua
104 lines
No EOL
2.8 KiB
Lua
rgt_cosmetics = {
|
|
characters = {}
|
|
}
|
|
local ns = rgt_cosmetics
|
|
|
|
--[[
|
|
{
|
|
name = "", -- Technical name
|
|
label = "", -- Displayed name
|
|
texture = "",
|
|
scale = 0.88, -- Amount by which to scale visual_size for this character
|
|
eye_height = 1.6, -- For use with `scale`
|
|
}
|
|
]]
|
|
function ns.register_character(def)
|
|
ns.characters[def.name] = def
|
|
end
|
|
|
|
function ns.set_character(m, chr)
|
|
if type(chr) == "string" then
|
|
chr = ns.characters[chr]
|
|
end
|
|
m.object:set_properties {
|
|
visual = "mesh",
|
|
mesh = "rgt_character.gltf",
|
|
textures = {chr.texture},
|
|
visual_size = vector.new(1,1,1) *chr.scale,
|
|
eye_height = chr.eye_height,
|
|
shaded = false,
|
|
}
|
|
m.object:get_inventory():set_stack("hand", 1, ItemStack("red_glazed_terracotta:_hand_"..chr.name))
|
|
end
|
|
|
|
minetest.register_on_joinplayer(function(p)
|
|
local m = rgt.players[p:get_player_name()]
|
|
ns.set_character(m, m.object:get_meta():get("character") or "key")
|
|
end)
|
|
|
|
minetest.register_chatcommand("character", {
|
|
func = function(name, args)
|
|
local m = rgt.players[name]
|
|
if ns.characters[args] then
|
|
m.object:get_meta():set_string("character", args)
|
|
ns.set_character(m, args)
|
|
else
|
|
tell(name, "That character does not exist.")
|
|
end
|
|
end
|
|
})
|
|
|
|
local _hand = minetest.registered_items[""]
|
|
function rgt.register_hand(name, caps, realname)
|
|
rgt.register_node("_hand_"..name, {
|
|
description = "",
|
|
paramtype = "light",
|
|
drawtype = "mesh",
|
|
mesh = "rgt_hand.gltf",
|
|
tiles = {"rgt_base_"..(realname or name or "placeholder")..".png"},
|
|
use_texture_alpha = "opaque",
|
|
visual_scale = 1,
|
|
wield_scale = vector.new(2,2,2),
|
|
node_placement_prediction = "",
|
|
on_construct = function(pos)
|
|
minetest.remove_node(pos)
|
|
end,
|
|
drop = "",
|
|
on_drop = function()
|
|
return ""
|
|
end,
|
|
range = _hand.range,
|
|
pointabilities = caps and caps.pointabilities or {},
|
|
tool_capabilities = caps or {
|
|
full_punch_interval = 0,
|
|
max_drop_level = 0,
|
|
groupcaps = {
|
|
-- dig_immediate = {times = {0}, uses = 0, maxlevel = 5},
|
|
hand_breakable = {times = {0.3, 0.5, 0.7}, uses = 0, maxlevel = 5}
|
|
},
|
|
damage_groups = {fleshy=1},
|
|
},
|
|
groups = {not_in_creative_inventory = 1, dig_immediate = 1}
|
|
})
|
|
end
|
|
|
|
rgt.register_hand("key")
|
|
rgt.register_hand("vix")
|
|
|
|
-- Builtin characters
|
|
|
|
ns.register_character {
|
|
name = "key",
|
|
label = "Key",
|
|
texture = "rgt_base_key.png",
|
|
scale = 0.88,
|
|
eye_height = 1.6
|
|
}
|
|
|
|
ns.register_character {
|
|
name = "vix",
|
|
label = "Vix",
|
|
texture = "rgt_base_vix.png",
|
|
scale = 0.8,
|
|
eye_height = 1.5
|
|
} |