From 1ebb87301b22989ab3ff1e2badc3df3c7444e55f Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 7 Aug 2017 04:27:19 +0100 Subject: [PATCH] Player API: Integrate settable player step height Split some long lines. Some nearby code cleanup. --- api.lua | 6 ++++-- init.lua | 22 ++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/api.lua b/api.lua index 00fa2ae..c79aedc 100644 --- a/api.lua +++ b/api.lua @@ -44,15 +44,17 @@ function player_api.set_model(player, model_name) mesh = model_name, textures = player_textures[name] or model.textures, visual = "mesh", - visual_size = model.visual_size or {x=1, y=1}, + visual_size = model.visual_size or {x = 1, y = 1}, collisionbox = model.collisionbox or {-0.3, 0.0, -0.3, 0.3, 1.77, 0.3}, + stepheight = model.stepheight or 0.6, }) player_api.set_animation(player, "stand") else player:set_properties({ - textures = { "player.png", "player_back.png", }, + textures = {"player.png", "player_back.png"}, visual = "upright_sprite", collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.75, 0.3}, + stepheight = 0.6, }) end player_model[name] = model_name diff --git a/init.lua b/init.lua index 61d43bd..203f60e 100644 --- a/init.lua +++ b/init.lua @@ -6,22 +6,28 @@ player_api.register_model("character.b3d", { textures = {"character.png", }, animations = { -- Standard animations. - stand = { x= 0, y= 79, }, - lay = { x=162, y=166, }, - walk = { x=168, y=187, }, - mine = { x=189, y=198, }, - walk_mine = { x=200, y=219, }, - sit = { x= 81, y=160, }, + stand = {x = 0, y = 79}, + lay = {x = 162, y = 166}, + walk = {x = 168, y = 187}, + mine = {x = 189, y = 198}, + walk_mine = {x = 200, y = 219}, + sit = {x = 81, y = 160}, }, collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.77, 0.3}, + stepheight = 0.6, }) -- Update appearance when the player joins minetest.register_on_joinplayer(function(player) player_api.player_attached[player:get_player_name()] = false player_api.set_model(player, "character.b3d") - player:set_local_animation({x=0, y=79}, {x=168, y=187}, {x=189, y=198}, {x=200, y=219}, 30) - + player:set_local_animation( + {x = 0, y = 79}, + {x = 168, y = 187}, + {x = 189, y = 198}, + {x = 200, y = 219}, + 30 + ) player:hud_set_hotbar_image("gui_hotbar.png") player:hud_set_hotbar_selected_image("gui_hotbar_selected.png") end)