Add support for visual_size and add fallback name support
parent
f91f6296f1
commit
5be8a61cec
1
API.md
1
API.md
|
@ -74,6 +74,7 @@ The next metadata keys are filled or/and used interally in chchar framework, som
|
|||
- animation_speed* - How many frames per second the animations play. Default: 30
|
||||
- textures - A list of all textures that the model uses. It is possible to leave this field blank, but the model will then not have an optimal appearance.
|
||||
- animations* - A list of animations that the model will use on certain actions.
|
||||
- visual_size* - A list of 3 points in XYZ order. The Z axis is optional. It allows scaling of models to different sizes other than their original.
|
||||
- collisionbox* - A list of 2 XYZ coordinates (6 points) in meters relative from the origin of the model.
|
||||
- stepheight* - How fast this model moves on the ground. Default: 0.6
|
||||
- eye_height* - How far up the Y-axis in meters the camera will be, in 1st-person view. Default: 1.47
|
||||
|
|
|
@ -23,6 +23,8 @@ walk_mine = {x = 200, y = 219}
|
|||
sit = {x = 81, y = 160}
|
||||
Formatted version would be: stand:0,79;lay:162,166;walk:168,187;mine:189,198;walk_mine:200,219;sit:81,160
|
||||
|
||||
- Visual Size* - A list of 3 points in XYZ order. The Z axis is optional. It allows scaling of models to different sizes other than their original. If this is not specified, models will be displayed at their original size.
|
||||
|
||||
- Collision Box* - A list of 2 XYZ coordinates (6 points) in meters relative from the origin of the model. It creates a cube or prism depending on the location of the coordinates. Format is {X1,Y1,Z1,X2,Y2,Z2} Default: {-0.3,0.0,-0.3,0.3,1.7,0.3} (without braces)
|
||||
|
||||
- Stepheight* - How fast this model moves on the ground. Default: 0.6
|
||||
|
|
|
@ -4,6 +4,7 @@ license = CC BY-SA 3.0
|
|||
animation_speed = 30
|
||||
textures = character.png,character_eyes.png
|
||||
animations => stand:0,79;lay:162,166;walk:168,187;mine:189,198;walk_mine:200,219;sit:81,160
|
||||
visual_size = 1,1
|
||||
collisionbox = -0.3,0.0,-0.3,0.3,1.7,0.3
|
||||
stepheight = 0.6
|
||||
eye_height = 1.47
|
||||
|
|
|
@ -65,26 +65,28 @@ for _, fn in pairs(models_dir_list) do
|
|||
print("Found meta file for "..fn)
|
||||
for line in file:lines() do
|
||||
if line:find("name = ") ~= nil then
|
||||
local data = line:split(" = ")
|
||||
model_obj:set_meta("name", data[2])
|
||||
model_obj:set_meta("name", line:split(" = ")[2])
|
||||
elseif line:find("author = ") ~= nil then
|
||||
local data = line:split(" = ")
|
||||
model_obj:set_meta("author", data[2])
|
||||
model_obj:set_meta("author", line:split(" = ")[2])
|
||||
elseif line:find("license = ") ~= nil then
|
||||
local data = line:split(" = ")
|
||||
model_obj:set_meta("license", data[2])
|
||||
model_obj:set_meta("license", line:split(" = ")[2])
|
||||
elseif line:find("animation_speed = ") ~= nil then
|
||||
local data = line:split(" = ")
|
||||
model_obj:set_meta("animation_speed", data[2])
|
||||
model_obj:set_meta("animation_speed", line:split(" = ")[2])
|
||||
elseif line:find("stepheight = ") ~= nil then
|
||||
local data = line:split(" = ")
|
||||
model_obj:set_meta("stepheight", data[2])
|
||||
model_obj:set_meta("stepheight", line:split(" = ")[2])
|
||||
elseif line:find("eye_height = ") ~= nil then
|
||||
local data = line:split(" = ")
|
||||
model_obj:set_meta("eye_height", data[2])
|
||||
model_obj:set_meta("eye_height", line:split(" = ")[2])
|
||||
elseif line:find("collisionbox = ") ~= nil then
|
||||
local data = line:split(" = ")
|
||||
model_obj:set_meta("collisionbox", data[2]:split())
|
||||
model_obj:set_meta("collisionbox", line:split(" = ")[2]:split())
|
||||
elseif line:find("visual_size = ") ~= nil then
|
||||
local data = line:split(" = ")[2]:split()
|
||||
if #data == 3 then
|
||||
model_obj:set_meta("visual_size", {x = data[1], y = data[2], z = data[3]})
|
||||
elseif #data == 2 then
|
||||
model_obj:set_meta("visual_size", {x = data[1], y = data[2], z = data[2]})
|
||||
elseif #data == 1 then
|
||||
model_obj:set_meta("visual_size", {x = data[1], y = data[1], z = data[1]})
|
||||
end
|
||||
elseif line:find("textures = ") ~= nil then
|
||||
local data = line:split(" = ")[2]:split()
|
||||
if #data < 2 then
|
||||
|
@ -114,12 +116,18 @@ for _, fn in pairs(models_dir_list) do
|
|||
model_obj:set_meta("name", table.concat(nameparts, ' '))
|
||||
end
|
||||
|
||||
-- If no name was found, substitute it with the code name
|
||||
if model_obj:get_meta("name") == nil then
|
||||
model_obj:set_meta("name", name)
|
||||
end
|
||||
|
||||
-- Register model with player_api, excluding the default model
|
||||
if fn ~= "character.b3d" then
|
||||
player_api.register_model(fn, {
|
||||
animation_speed = model_obj:get_meta("animation_speed") or 30,
|
||||
textures = model_obj:get_meta("textures") or {"blank.png"},
|
||||
animations = model_obj:get_meta("animations") or {},
|
||||
visual_size = model_obj:get_meta("visual_size") or {x = 1, y = 1},
|
||||
collisionbox = model_obj:get_meta("collisionbox") or {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
|
||||
stepheight = model_obj:get_meta("stepheight") or 0.6,
|
||||
eye_height = model_obj:get_meta("eye_height") or 1.47,
|
||||
|
|
Loading…
Reference in New Issue