diff --git a/mods/beds/functions.lua b/mods/beds/functions.lua index 97f372c14..34c42558d 100644 --- a/mods/beds/functions.lua +++ b/mods/beds/functions.lua @@ -65,10 +65,10 @@ local function lay_down(player, pos, bed_pos, state, skip) -- physics, eye_offset, etc player:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) player:set_look_yaw(math.random(1, 180)/100) - default.player_attached[name] = false + player_api.player_attached[name] = false player:set_physics_override(1, 1, 1) hud_flags.wielditem = true - default.player_set_animation(player, "stand" , 30) + player_api.set_animation(player, "stand" , 30) -- lay down else @@ -84,9 +84,9 @@ local function lay_down(player, pos, bed_pos, state, skip) local p = {x=bed_pos.x+dir.x/2,y=bed_pos.y,z=bed_pos.z+dir.z/2} player:set_physics_override(0, 0, 1) player:setpos(p) - default.player_attached[name] = true + player_api.player_attached[name] = true hud_flags.wielditem = false - default.player_set_animation(player, "lay" , 0) + player_api.set_animation(player, "lay" , 0) end player:hud_set_flags(hud_flags) diff --git a/mods/boats/init.lua b/mods/boats/init.lua index 6f24c91e2..e93d636dd 100644 --- a/mods/boats/init.lua +++ b/mods/boats/init.lua @@ -50,14 +50,14 @@ function row_boat.on_rightclick(self, clicker) if self.driver and clicker == self.driver then self.driver = nil clicker:set_detach() - default.player_attached[name] = false - default.player_set_animation(clicker, "stand" , 30) + player_api.player_attached[name] = false + player_api.set_animation(clicker, "stand" , 30) elseif not self.driver then self.driver = clicker - clicker:set_attach(self.object, "", {x=0,y=11,z=0}, {x=0,y=0,z=0}) - default.player_attached[name] = true + clicker:set_attach(self.object, "", {x=0,y=3,z=-4}, {x=0,y=0,z=0}) + player_api.player_attached[name] = true minetest.after(0.2, function() - default.player_set_animation(clicker, "sit" , 30) + player_api.set_animation(clicker, "sit" , 30) end) self.object:setyaw(clicker:get_look_yaw() - math.pi / 2) end @@ -80,7 +80,7 @@ function row_boat.on_punch(self, puncher, time_from_last_punch, tool_capabilitie return end puncher:set_detach() - default.player_attached[puncher:get_player_name()] = false + player_api.player_attached[puncher:get_player_name()] = false self.removed = true -- delay remove to ensure player is detached @@ -232,14 +232,14 @@ function sail_boat.on_rightclick(self, clicker) if self.driver and clicker == self.driver then self.driver = nil clicker:set_detach() - default.player_attached[name] = false - default.player_set_animation(clicker, "stand" , 30) + player_api.player_attached[name] = false + player_api.set_animation(clicker, "stand" , 30) elseif not self.driver then self.driver = clicker clicker:set_attach(self.object, "", {x=0,y=11,z=0}, {x=0,y=0,z=0}) - default.player_attached[name] = true + player_api.player_attached[name] = true minetest.after(0.2, function() - default.player_set_animation(clicker, "sit" , 30) + player_api.set_animation(clicker, "sit" , 30) end) self.object:setyaw(clicker:get_look_yaw() - math.pi / 2) end @@ -262,7 +262,7 @@ function sail_boat.on_punch(self, puncher, time_from_last_punch, tool_capabiliti return end puncher:set_detach() - default.player_attached[puncher:get_player_name()] = false + player_api.player_attached[puncher:get_player_name()] = false self.removed = true -- delay remove to ensure player is detached diff --git a/mods/default/player.lua b/mods/default/player.lua index 541033d3b..dcaf8cc41 100644 --- a/mods/default/player.lua +++ b/mods/default/player.lua @@ -3,136 +3,136 @@ -- Player animation blending -- Note: This is currently broken due to a bug in Irrlicht, leave at 0 -local animation_blend = 0 +--local animation_blend = 0 -default.registered_player_models = { } +--default.registered_player_models = { } -- Local for speed. -local models = default.registered_player_models +--local models = default.registered_player_models -function default.player_register_model(name, def) - models[name] = def -end +--function default.player_register_model(name, def) +-- models[name] = def +--end -- Player stats and animations -local player_model = {} -local player_textures = {} -local player_anim = {} -local player_sneak = {} -default.player_attached = {} - -function default.player_get_animation(player) - local name = player:get_player_name() - return { - model = player_model[name], - textures = player_textures[name], - animation = player_anim[name], - } -end +--local player_model = {} +--local player_textures = {} +--local player_anim = {} +--local player_sneak = {} +--default.player_attached = {} + +--function default.player_get_animation(player) +-- local name = player:get_player_name() +-- return { +-- model = player_model[name], +-- textures = player_textures[name], +-- animation = player_anim[name], +-- } +--end -- Called when a player's appearance needs to be updated -function default.player_set_model(player, model_name) - local name = player:get_player_name() - local model = models[model_name] - if model then - if player_model[name] == model_name then - return - end - player:set_properties({ - mesh = model_name, - textures = player_textures[name] or model.textures, - visual = "mesh", - visual_size = model.visual_size or {x = 1, y = 1}, - collisionbox = model.collisionbox or {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, - stepheight = model.stepheight or 0.6, - eye_height = model.eye_height or 1.47, - }) - default.player_set_animation(player, "stand") - else - player:set_properties({ - 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, - eye_height = 1.625, - }) - end - player_model[name] = model_name -end - -function default.player_set_textures(player, textures) - local name = player:get_player_name() - local model = models[player_model[name]] - local model_textures = model and model.textures or nil - player_textures[name] = textures or model_textures - player:set_properties({textures = textures or model_textures,}) -end - -function default.player_set_animation(player, anim_name, speed) - local name = player:get_player_name() - if player_anim[name] == anim_name then - return - end - local model = player_model[name] and models[player_model[name]] - if not (model and model.animations[anim_name]) then - return - end - local anim = model.animations[anim_name] - player_anim[name] = anim_name - player:set_animation(anim, speed or model.animation_speed, animation_blend) -end - -minetest.register_on_leaveplayer(function(player) - local name = player:get_player_name() - player_model[name] = nil - player_anim[name] = nil - player_textures[name] = nil -end) +--function default.player_set_model(player, model_name) +-- local name = player:get_player_name() +-- local model = models[model_name] +-- if model then +-- if player_model[name] == model_name then +-- return +-- end +-- player:set_properties({ +-- mesh = model_name, +-- textures = player_textures[name] or model.textures, +-- visual = "mesh", +-- visual_size = model.visual_size or {x = 1, y = 1}, +-- collisionbox = model.collisionbox or {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3}, +-- stepheight = model.stepheight or 0.6, +-- eye_height = model.eye_height or 1.47, +-- }) +-- default.player_set_animation(player, "stand") +-- else +-- player:set_properties({ +-- 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, +-- eye_height = 1.625, +-- }) +-- end +-- player_model[name] = model_name +--end + +--function default.player_set_textures(player, textures) +-- local name = player:get_player_name() +-- local model = models[player_model[name]] +-- local model_textures = model and model.textures or nil +-- player_textures[name] = textures or model_textures +-- player:set_properties({textures = textures or model_textures,}) +--end + +--function default.player_set_animation(player, anim_name, speed) +-- local name = player:get_player_name() +-- if player_anim[name] == anim_name then +-- return +-- end +-- local model = player_model[name] and models[player_model[name]] +-- if not (model and model.animations[anim_name]) then +-- return +-- end +-- local anim = model.animations[anim_name] +-- player_anim[name] = anim_name +-- player:set_animation(anim, speed or model.animation_speed, animation_blend) +--end + +--minetest.register_on_leaveplayer(function(player) +-- local name = player:get_player_name() +-- player_model[name] = nil +-- player_anim[name] = nil +-- player_textures[name] = nil +--end) -- Localize for better performance. -local player_set_animation = default.player_set_animation -local player_attached = default.player_attached +--local player_set_animation = player_api.set_animation +--local player_attached = player_api.player_attached -- Check each player and apply animations -minetest.register_globalstep(function(dtime) - for _, player in pairs(minetest.get_connected_players()) do - local name = player:get_player_name() - local model_name = player_model[name] - local model = model_name and models[model_name] - if model and not player_attached[name] then - local controls = player:get_player_control() - local walking = false - local animation_speed_mod = model.animation_speed or 30 - - -- Determine if the player is walking - if controls.up or controls.down or controls.left or controls.right then - walking = true - end - - -- Determine if the player is sneaking, and reduce animation speed if so - if controls.sneak then - animation_speed_mod = animation_speed_mod / 2 - end +--minetest.register_globalstep(function(dtime) +-- for _, player in pairs(minetest.get_connected_players()) do +-- local name = player:get_player_name() +-- local model_name = player_model[name] +-- local model = model_name and models[model_name] +-- if model and not player_attached[name] then +-- local controls = player:get_player_control() +-- local walking = false +-- local animation_speed_mod = model.animation_speed or 30 +--- +-- -- Determine if the player is walking +-- if controls.up or controls.down or controls.left or controls.right then +-- walking = true +-- end +-- +-- -- Determine if the player is sneaking, and reduce animation speed if so +-- if controls.sneak then +-- animation_speed_mod = animation_speed_mod / 2 +-- end -- Apply animations based on what the player is doing - if player:get_hp() == 0 then - player_set_animation(player, "lay") - elseif walking then - if player_sneak[name] ~= controls.sneak then - player_anim[name] = nil - player_sneak[name] = controls.sneak - end - if controls.LMB then - player_set_animation(player, "walk_mine", animation_speed_mod) - else - player_set_animation(player, "walk", animation_speed_mod) - end - elseif controls.LMB then - player_set_animation(player, "mine") - else - player_set_animation(player, "stand", animation_speed_mod) - end - end - end -end) +-- if player:get_hp() == 0 then +-- player_set_animation(player, "lay") +-- elseif walking then +-- if player_sneak[name] ~= controls.sneak then +-- player_anim[name] = nil +-- player_sneak[name] = controls.sneak +-- end +-- if controls.LMB then +-- player_set_animation(player, "walk_mine", animation_speed_mod) +-- else +-- player_set_animation(player, "walk", animation_speed_mod) +-- end +-- elseif controls.LMB then +-- player_set_animation(player, "mine") +-- else +-- player_set_animation(player, "stand", animation_speed_mod) +-- end +-- end +-- end +--end) diff --git a/mods/lord_homedecor/handlers/sit.lua b/mods/lord_homedecor/handlers/sit.lua index 42be1abed..222c01b29 100644 --- a/mods/lord_homedecor/handlers/sit.lua +++ b/mods/lord_homedecor/handlers/sit.lua @@ -5,22 +5,22 @@ function lord_homedecor.sit(pos, node, clicker) local meta = minetest.get_meta(pos) local param2 = node.param2 local name = clicker:get_player_name() - +print("Вызов функции lord_homedecor.sit") if name == meta:get_string("is_sit") then meta:set_string("is_sit", "") pos.y = pos.y-0.5 clicker:setpos(pos) clicker:set_eye_offset({x=0,y=0,z=0}, {x=0,y=0,z=0}) clicker:set_physics_override(1, 1, 1) - default.player_attached[name] = false - default.player_set_animation(clicker, "stand", 30) + player_api.player_attached[name] = false + player_api.set_animation(clicker, "stand", 30) else meta:set_string("is_sit", clicker:get_player_name()) clicker:set_eye_offset({x=0,y=-7,z=2}, {x=0,y=0,z=0}) clicker:set_physics_override(0, 0, 0) clicker:setpos(pos) - default.player_attached[name] = true - default.player_set_animation(clicker, "sit", 30) + player_api.player_attached[name] = true + player_api.set_animation(clicker, "sit", 30) if param2 == 0 then clicker:set_look_yaw(3.15) elseif param2 == 1 then diff --git a/mods/lottarmor/multiskin.lua b/mods/lottarmor/multiskin.lua index 8a30a122e..4878c7a55 100644 --- a/mods/lottarmor/multiskin.lua +++ b/mods/lottarmor/multiskin.lua @@ -15,7 +15,7 @@ elseif minetest.get_modpath("wardrobe") then end function multiskin:init(player) - default.player_set_model(player, "lottarmor_character.b3d") + player_api.set_model(player, "lottarmor_character.b3d") local name = player:get_player_name() multiskin[name] = { skin = MULTISKIN_DEFAULT_SKIN, @@ -60,7 +60,7 @@ function multiskin:update_player_visuals(player) end local name = player:get_player_name() if multiskin[name] then - default.player_set_textures(player, { + player_api.set_textures(player, { multiskin[name].skin, multiskin[name].armor, multiskin[name].wielditem, @@ -102,7 +102,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end) -default.player_register_model("lottarmor_character.b3d", { +player_api.register_model("lottarmor_character.b3d", { animation_speed = 30, textures = { MULTISKIN_DEFAULT_SKIN, diff --git a/mods/lottarmor/wieldview.lua b/mods/lottarmor/wieldview.lua index 596dda75f..e491b35f8 100644 --- a/mods/lottarmor/wieldview.lua +++ b/mods/lottarmor/wieldview.lua @@ -31,6 +31,7 @@ lottarmor.get_item_texture = function(self, item) texture = texture.."^[transform"..lottarmor.transform[item] end end + --print(dump(texture)) return texture end @@ -48,7 +49,9 @@ lottarmor.update_wielded_item = function(self, player) if self.wielded_item[name] == item then return end - armor.textures[name].wielditem = self:get_item_texture(item) + --print(dump( + --armor.textures[name].wielditem = self:get_item_texture(item) + multiskin[name].wielditem = self:get_item_texture(item) armor:update_player_visuals(player) end self.wielded_item[name] = item diff --git a/mods/lottclothes/clothing.lua b/mods/lottclothes/clothing.lua index cc2a4733f..08931ab0f 100644 --- a/mods/lottclothes/clothing.lua +++ b/mods/lottclothes/clothing.lua @@ -31,7 +31,9 @@ clothing.set_player_clothing = function(self, player) end end if #textures > 0 then + --print(dump(textures)) clothing_texture = table.concat(textures, "^") + --print(dump(clothing_texture)) end self.textures[name].clothing = clothing_texture self.textures[name].preview = preview diff --git a/mods/lottmobs/horse.lua b/mods/lottmobs/horse.lua index 0c3990b7f..8a24c6a9b 100644 --- a/mods/lottmobs/horse.lua +++ b/mods/lottmobs/horse.lua @@ -214,11 +214,11 @@ function lottmobs.register_horse(name, craftitem, horse) self.driver = nil self.ridername = nil clicker:set_detach() - default.player_attached[clicker:get_player_name()] = false + player_api.player_attached[clicker:get_player_name()] = false if self.offset == true then clicker:set_eye_offset({ x = 0, y = 0, z = 0 }, { x = 0, y = 0, z = 0 }) end - elseif not self.driver and not default.player_attached[player] then + elseif not self.driver and not player_api.player_attached[player] then for no = 1, #self.riders do -- who can drive if self.riders[no] == races.get_race_and_gender(player)[1] or @@ -229,7 +229,7 @@ function lottmobs.register_horse(name, craftitem, horse) local attach_r = self.attach_r or 90 clicker:set_attach(self.object, "", { x = 0, y = attach_h, z = 0 }, { x = 0, y = attach_r, z = 0 }) - default.player_attached[clicker:get_player_name()] = true + player_api.player_attached[clicker:get_player_name()] = true self.object:setyaw(clicker:get_look_yaw()) self.ridername = clicker:get_player_name() @@ -241,7 +241,7 @@ function lottmobs.register_horse(name, craftitem, horse) end end end - if not default.player_attached[clicker:get_player_name()] then + if not player_api.player_attached[clicker:get_player_name()] then minetest.chat_send_player(player, core.colorize("#ff8ea1", SL("You can't ride this beast!!!"))) end end @@ -271,7 +271,7 @@ function lottmobs.register_horse(name, craftitem, horse) if puncher and puncher:is_player() then if puncher:get_player_name() == ridername then puncher:get_inventory():add_item("main", name) - default.player_attached[puncher:get_player_name()] = false + player_api.player_attached[puncher:get_player_name()] = false puncher:set_detach() self.object:remove() if self.offset == true then @@ -315,8 +315,8 @@ function lottmobs.register_horse(name, craftitem, horse) end end - if self.object:get_hp() <= 0 and default.player_attached[ridername] then - default.player_attached[ridername] = false + if self.object:get_hp() <= 0 and player_api.player_attached[ridername] then + player_api.player_attached[ridername] = false rider:set_detach() self.object:remove() if self.offset == true then