-- Player animation speed animation_speed = 30 -- Player animation blending -- Note: This is currently broken due to a bug in Irrlicht, leave at 0 animation_blend = 0 -- Default player appearance default_model = "character.x" default_textures = {"character.png", } -- Frame ranges for each player model function player_get_animations(model) if model == "character.x" then return { stand_START = 0, stand_END = 79, sit_START = 81, sit_END = 160, lay_START = 162, lay_END = 166, walk_START = 168, walk_END = 187, mine_START = 189, mine_END = 198, walk_mine_START = 200, walk_mine_END = 219 } end end local player_model = {} local player_anim = {} local player_sneak = {} local ANIM_STAND = 1 local ANIM_SIT = 2 local ANIM_LAY = 3 local ANIM_WALK = 4 local ANIM_WALK_MINE = 5 local ANIM_MINE = 6 function player_update_visuals(self) --local name = get_player_name() visual = default_model player_anim = 0 -- Animation will be set further below immediately --player_sneak[name] = false prop = { mesh = default_model, textures = default_textures, visual = "mesh", visual_size = {x=1, y=1}, } self.object:set_properties(prop) end BOAT_ENTITY = { physical = true, collisionbox = {-0.5,-1.0,-0.5, 0.5,0.4,0.5}, visual = "mesh", mesh = "character.x", textures = {"character.png"}, player_anim = 0, timer = 0, } BOAT_ENTITY.on_activate = function(self) player_update_visuals(self) local anim = player_get_animations(visual) self.object:set_animation({x=anim.walk_mine_START,y=anim.walk_mine_END}, animation_speed_mod, animation_blend) player_anim = ANIM_WALK_MINE self.object:setacceleration({x=0,y=-10,z=0}) end BOAT_ENTITY.on_step = function(self, dtime) self.timer = self.timer + 1 --self.object:setacceleration({x=0,y=-10,z=0}) check = minetest.env:find_node_near(self.object:getpos(), 2, {"default:stone","default:dirt","default:dirt_with_grass"}) if check ~= nil then minetest.env:remove_node(check) end if self.timer > 50 then --self.object:setacceleration({x=0,y=-10,z=0}) self.timer = 0 self.yaw = math.random() * 360 self.object:setyaw(self.yaw) self.object:set_properties({automatic_rotate = 0}) self.direction = {x = math.cos(self.yaw)*2, y = -10, z = math.sin(self.yaw)*2} self.object:setacceleration(self.direction) end end minetest.register_entity("npc:npc", BOAT_ENTITY)