From 6adc3faad0227238cca32d169df0d61c85afd322 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 26 Aug 2021 04:34:35 +0200 Subject: [PATCH] Attach player in MineClone2-derived games --- depends.txt | 1 + init.lua | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/depends.txt b/depends.txt index b366a89..824f07d 100644 --- a/depends.txt +++ b/depends.txt @@ -2,5 +2,6 @@ default? mcl_colorblocks? mcl_core? mcl_formspec? +mcl_player? wordedit? intllib? diff --git a/init.lua b/init.lua index cb0648c..fe3b52e 100644 --- a/init.lua +++ b/init.lua @@ -14,7 +14,8 @@ end local has_default = mod_loaded("default") local has_mcl = mod_loaded("mcl_core") and mod_loaded("mcl_colorblocks") and - mod_loaded("mcl_formspec") + mod_loaded("mcl_formspec") and + mod_loaded("mcl_player") if not (has_default or has_mcl) then error( @@ -28,6 +29,11 @@ if not (has_default or has_mcl) then ) end +local player_mod = default +if has_mcl then + player_mod = mcl_player +end + dofile(minetest.get_modpath(minetest.get_current_modname()).."/api.lua") local ctrl_groups = {choppy=2, oddly_breakable_by_hand=2} @@ -528,22 +534,22 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) player:set_attach(entity.object, "", {x=0, y=5, z=0}, {x=0, y=0, z=0}) entity.player = player entity.object:set_animation({x=0, y=0}, 15) - default.player_attached[name] = true + player_mod.player_attached[name] = true elseif fields.detach and entity.player == player then player:set_detach() entity.player = nil entity.animation = "stand" entity.object:set_animation({x=20, y=100}, 15) - default.player_attached[name] = false + player_mod.player_attached[name] = false local p = player:getpos() minetest.after(0.1, function() player:setpos({x=p.x, y=p.y + 1, z=p.z}) end) elseif fields.animation_sit then - default.player_set_animation(player, "sit", 30) + player_mod.player_set_animation(player, "sit", 30) entity.animation = "sit" elseif fields.animation_stand then - default.player_set_animation(player, "stand", 30) + player_mod.player_set_animation(player, "stand", 30) entity.animation = "stand" elseif fields.align then entity:set_alignment()