Configuration

master
Lars Mueller 2020-09-20 17:22:10 +02:00
parent 3c66406bdc
commit e44571d5ae
4 changed files with 51 additions and 3 deletions

34
conf.lua Normal file
View File

@ -0,0 +1,34 @@
local angle = { type = "number", range = { -180, 180 } }
local range = {
type = "table",
children = { angle, angle },
func = function(range)
if range[2] < range[1] then return "First range value is not <= second range value" end
end
}
local model = {
type = "table",
children = {
body = {
type = "table",
children = { turn_speed = { type = "number", range = { 0, 1e3 } } }
},
head = {
type = "table",
children = {
pitch = range,
yaw = range,
yaw_restricted = range,
yaw_restriction = angle
}
},
arm_right = {
type = "table",
children = { radius = angle, speed = { type = "number", range = { 0, 1e4 } }, yaw = range }
}
}
}
conf = modlib.conf.import(minetest.get_current_modname(), {
default = model,
models = { type = "table", keys = { type = "string" }, values = model }
})

11
default_config.json Normal file
View File

@ -0,0 +1,11 @@
{
"body": { "turn_speed": 0.2 },
"head": {
"pitch": [ -60, 80 ],
"yaw": [ -90, 90 ],
"yaw_restricted": [ 0, 45 ],
"yaw_restriction": 60
},
"arm_right": { "radius": 10, "speed": 1e3, "yaw": [ -30, 160 ] },
"models": {}
}

View File

@ -3,5 +3,6 @@ local namespace = create_namespace()
local quaternion = setmetatable({}, {__index = namespace})
include_env(get_resource"quaternion.lua", quaternion)
namespace.quaternion = quaternion
extend"conf"
extend"importer"
extend"main"

View File

@ -89,7 +89,7 @@ local function normalize_rotation(euler_rotation)
return vector.apply(euler_rotation, function(x) return (x % 360) - 180 end)
end
local conf = {
--[[local conf = {
body = {
turn_speed = 1/5
},
@ -104,12 +104,14 @@ local conf = {
speed = 1000,
yaw = {-30, 160}
}
}
}]]
local function handle_player_animations(dtime, player)
local modeldata = modeldata[player:get_properties().mesh]
local mesh = player:get_properties().mesh
local modeldata = modeldata[mesh]
if not modeldata then
return
end
local conf = conf.models[mesh] or conf
local name = player:get_player_name()
local range, frame_speed, frame_blend, frame_loop = player:get_animation()
disable_animation(player)