View Full Version : Creating Entity on different map

07-19-2011, 12:23 AM
CreateEntity(Map:test(), Vector2( 900, 560 ), "weapons/dagger/daggerI.lua");

im trying to create an entity with the script daggerI.lua on map test but the code above isnt working....i dont know why, any help?

07-19-2011, 12:55 AM
Hmm, what is Map:test()? I don't think you can do it that way..

Instead, try this:

//first, remember the currently active map so we can switch back to it
originalMapName = nill

if (GetMapManager:GetActiveMap() != nil) then
originalMapName = GetMapManager:GetActiveMap():GetName();

GetMapManager:SetActiveMapByName("Test"); //Assuming test is the name of the map
CreateEntity(GetMapManager:GetActiveMap(), Vector2( 900, 560 ), "weapons/dagger/daggerI.lua");

//now switch back if we can
if (originalMapName != nil) then

Untested code above, may have errors.

I'm kind of puzzled why I don't have a GetMapManager:GetMapByName("test") function. Strange, but this work around should do it.

07-19-2011, 02:04 AM
thanks that works but i also found another way around it, instead i put an invisible entity on the map and named it something like "test" then i used the code...

ent = GetEntityByName("test");
CreateEntity(ent:GetMap(), Vector2( 375, 75 ), "weapons/dagger/daggerI.lua");

so it looks for that entity, gets the map that entity is one and then creates the entity i wanted it to there, and it seems to be working fine for now :P