Fix attachment test script and unregistered entities. Thanks jin_xi for this

This commit is contained in:
MirceaKitsune 2012-11-03 13:17:13 +02:00 committed by Perttu Ahola
parent 24781813fa
commit 04d40a5ce4
1 changed files with 3 additions and 25 deletions

View File

@ -24,7 +24,6 @@ end
minetest.after(1.0, switch_player_visual) 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 -- 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 = { test2 = {
collisionbox = { 0, 0, 0, 0, 0, 0 }, collisionbox = { 0, 0, 0, 0, 0, 0 },
visual = "cube" visual = "cube"
@ -32,11 +31,6 @@ test2 = {
minetest.register_entity("default:test2", test2) minetest.register_entity("default:test2", test2)
function detachments(newobject)
newobject:set_detach()
print ("Detached test object")
end
function attachments() function attachments()
prop = { prop = {
mesh = "player.x", mesh = "player.x",
@ -47,13 +41,13 @@ function attachments()
} }
local pos={x=0,y=0,z=0} 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_properties(prop)
newobject:set_animation({x=1, y=50}, 35, 0) newobject:set_animation({x=1, y=50}, 35, 0)
print ("Spawned test object") print ("Spawned test object")
for _, obj in pairs(minetest.get_connected_players()) do 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}) 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()) print ("Attached test object to "..obj:get_player_name())
end end
@ -61,24 +55,8 @@ function attachments()
minetest.after(5.0, function() detachments(newobject) end) minetest.after(5.0, function() detachments(newobject) end)
end end
minetest.after(15.0, attachments)]]
-- Test case for player to player attachments minetest.after(10.0, 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)
-- Definitions made by this mod that other mods can use too -- Definitions made by this mod that other mods can use too
default = {} default = {}