Attach player in MineClone2-derived games
This commit is contained in:
parent
84f98b788c
commit
6adc3faad0
|
@ -2,5 +2,6 @@ default?
|
||||||
mcl_colorblocks?
|
mcl_colorblocks?
|
||||||
mcl_core?
|
mcl_core?
|
||||||
mcl_formspec?
|
mcl_formspec?
|
||||||
|
mcl_player?
|
||||||
wordedit?
|
wordedit?
|
||||||
intllib?
|
intllib?
|
||||||
|
|
16
init.lua
16
init.lua
|
@ -14,7 +14,8 @@ end
|
||||||
local has_default = mod_loaded("default")
|
local has_default = mod_loaded("default")
|
||||||
local has_mcl = mod_loaded("mcl_core") and
|
local has_mcl = mod_loaded("mcl_core") and
|
||||||
mod_loaded("mcl_colorblocks") 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
|
if not (has_default or has_mcl) then
|
||||||
error(
|
error(
|
||||||
|
@ -28,6 +29,11 @@ if not (has_default or has_mcl) then
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local player_mod = default
|
||||||
|
if has_mcl then
|
||||||
|
player_mod = mcl_player
|
||||||
|
end
|
||||||
|
|
||||||
dofile(minetest.get_modpath(minetest.get_current_modname()).."/api.lua")
|
dofile(minetest.get_modpath(minetest.get_current_modname()).."/api.lua")
|
||||||
|
|
||||||
local ctrl_groups = {choppy=2, oddly_breakable_by_hand=2}
|
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})
|
player:set_attach(entity.object, "", {x=0, y=5, z=0}, {x=0, y=0, z=0})
|
||||||
entity.player = player
|
entity.player = player
|
||||||
entity.object:set_animation({x=0, y=0}, 15)
|
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
|
elseif fields.detach and entity.player == player then
|
||||||
player:set_detach()
|
player:set_detach()
|
||||||
entity.player = nil
|
entity.player = nil
|
||||||
entity.animation = "stand"
|
entity.animation = "stand"
|
||||||
entity.object:set_animation({x=20, y=100}, 15)
|
entity.object:set_animation({x=20, y=100}, 15)
|
||||||
default.player_attached[name] = false
|
player_mod.player_attached[name] = false
|
||||||
local p = player:getpos()
|
local p = player:getpos()
|
||||||
minetest.after(0.1, function()
|
minetest.after(0.1, function()
|
||||||
player:setpos({x=p.x, y=p.y + 1, z=p.z})
|
player:setpos({x=p.x, y=p.y + 1, z=p.z})
|
||||||
end)
|
end)
|
||||||
elseif fields.animation_sit then
|
elseif fields.animation_sit then
|
||||||
default.player_set_animation(player, "sit", 30)
|
player_mod.player_set_animation(player, "sit", 30)
|
||||||
entity.animation = "sit"
|
entity.animation = "sit"
|
||||||
elseif fields.animation_stand then
|
elseif fields.animation_stand then
|
||||||
default.player_set_animation(player, "stand", 30)
|
player_mod.player_set_animation(player, "stand", 30)
|
||||||
entity.animation = "stand"
|
entity.animation = "stand"
|
||||||
elseif fields.align then
|
elseif fields.align then
|
||||||
entity:set_alignment()
|
entity:set_alignment()
|
||||||
|
|
Loading…
Reference in New Issue