Attach player in MineClone2-derived games

This commit is contained in:
Nils Dagsson Moskopp 2021-08-26 04:34:35 +02:00
parent 84f98b788c
commit 6adc3faad0
Signed by: erlehmann
GPG Key ID: A3BC671C35191080
2 changed files with 12 additions and 5 deletions

View File

@ -2,5 +2,6 @@ default?
mcl_colorblocks?
mcl_core?
mcl_formspec?
mcl_player?
wordedit?
intllib?

View File

@ -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()