Fix attachment test script and unregistered entities. Thanks jin_xi for this
This commit is contained in:
parent
24781813fa
commit
04d40a5ce4
@ -24,7 +24,6 @@ end
|
||||
minetest.after(1.0, switch_player_visual)
|
||||
|
||||
-- Test case for attachments: An object is spawned and attached to the player with the specified name (use your own playername there) 10 seconds after the server starts
|
||||
|
||||
test2 = {
|
||||
collisionbox = { 0, 0, 0, 0, 0, 0 },
|
||||
visual = "cube"
|
||||
@ -32,11 +31,6 @@ test2 = {
|
||||
|
||||
minetest.register_entity("default:test2", test2)
|
||||
|
||||
function detachments(newobject)
|
||||
newobject:set_detach()
|
||||
print ("Detached test object")
|
||||
end
|
||||
|
||||
function attachments()
|
||||
prop = {
|
||||
mesh = "player.x",
|
||||
@ -47,13 +41,13 @@ function attachments()
|
||||
}
|
||||
|
||||
local pos={x=0,y=0,z=0}
|
||||
local newobject=minetest.env:add_entity(pos, "test:test2")
|
||||
local newobject=minetest.env:add_entity(pos, "default:test2")
|
||||
newobject:set_properties(prop)
|
||||
newobject:set_animation({x=1, y=50}, 35, 0)
|
||||
print ("Spawned test object")
|
||||
|
||||
for _, obj in pairs(minetest.get_connected_players()) do
|
||||
if(obj:get_player_name() == "MirceaKitsune") then
|
||||
if(obj:get_player_name() == "some_nick") then
|
||||
newobject:set_attach(obj, "Bone.001", {x=0,y=3,z=0}, {x=0,y=45,z=0})
|
||||
print ("Attached test object to "..obj:get_player_name())
|
||||
end
|
||||
@ -61,24 +55,8 @@ function attachments()
|
||||
|
||||
minetest.after(5.0, function() detachments(newobject) end)
|
||||
end
|
||||
minetest.after(15.0, attachments)]]
|
||||
|
||||
-- Test case for player to player attachments
|
||||
|
||||
function attachments_player()
|
||||
for _, obj in pairs(minetest.get_connected_players()) do
|
||||
if(obj:get_player_name() == "MirceaKitsune") then
|
||||
for _, obj2 in pairs(minetest.get_connected_players()) do
|
||||
if(obj2:get_player_name() == "MirceaKitsune1") then
|
||||
obj2:set_attach(obj, "Bone.001", {x=0,y=6,z=0}, {x=0,y=45,z=0})
|
||||
print ("Attached player "..obj2:get_player_name().." to player "..obj:get_player_name())
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.after(10.0, attachments_player)
|
||||
minetest.after(10.0, attachments)
|
||||
|
||||
-- Definitions made by this mod that other mods can use too
|
||||
default = {}
|
||||
|
Loading…
Reference in New Issue
Block a user