Teleportation problem [Solved]
Moderator: Moderators
- jangoisbaddest
- Lieutenant General

- Posts: 661
- Joined: Mon Feb 27, 2006 12:10 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: All Along The Watchtower
Teleportation problem [Solved]
somen00b suggested that I start a new thread on this, so I will. I tested the functionality of an OnEnterRegion trigger to teleport a unit to a path node, but it didn't work. The modtools log gave me nothing. Mainly, though, I think this is because I'm so lacking in knowledge of the programming of the scripts - I probably put the function in the wrong place. Does it need to go into ScriptPostLoad, ScriptInt....? Cause the space LUAs are different than the land ones, but they share those functions....
-
archer01
RE: Teleportation
I just tested it by copying it straight out of the thread where I posted it (in case I made a mistake in the post). I only changed the region and path names, and it worked fine for me.
All listeners (things beginning with "On") should go into the ScriptPostLoad() function. I've never seen them used in ScriptInit() so I'm assuming they won't function there. Also make sure you have activated the region using ActivateRegion(). Regions that aren't activated won't throw the EnterRegion event.
If none of that works, post the lua where you use it so we can try to see what the problem might be.
All listeners (things beginning with "On") should go into the ScriptPostLoad() function. I've never seen them used in ScriptInit() so I'm assuming they won't function there. Also make sure you have activated the region using ActivateRegion(). Regions that aren't activated won't throw the EnterRegion event.
If none of that works, post the lua where you use it so we can try to see what the problem might be.
- jangoisbaddest
- Lieutenant General

- Posts: 661
- Joined: Mon Feb 27, 2006 12:10 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: All Along The Watchtower
Re: RE: Teleportation
I've done several variations on this, so I don't know what's up with it. This is the Space Assault LUA for my map:
One thing - do I have to choose a specific Region type, or am I okay if I just make a new one and name it?
Hidden/Spoiler:
-
archer01
RE: Re: RE: Teleportation
That might be your problem actually. I've found that the game uses the region's type as it's "name"... I have no idea why...
Try setting both the editor name and the region's type to the same thing and try it again.
Also, where is the "MoveEntityToNode()" function? It was also in the other thread and is needed for the OnEnterRegion listener to work (it calls it).
Try setting both the editor name and the region's type to the same thing and try it again.
Also, where is the "MoveEntityToNode()" function? It was also in the other thread and is needed for the OnEnterRegion listener to work (it calls it).
- Karnage
- Commander Randomtoast
- Posts: 947
- Joined: Sun Oct 23, 2005 9:17 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Wherever there is shenanigannery.
This is what i'm getting from this:
Place a region in a map, leaving it as it's original name.
Place a node with a specific name.
Enter...
If this is completely wrong, could you type out some sort of a tutorial on how to do this?
Place a region in a map, leaving it as it's original name.
Place a node with a specific name.
Enter...
this into the LUA of the map (replacing *** with the name of region and/or node), and you can teleport people?OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"***")
end,
"***"
)
ActivateRegion("***")
end
If this is completely wrong, could you type out some sort of a tutorial on how to do this?
- jangoisbaddest
- Lieutenant General

- Posts: 661
- Joined: Mon Feb 27, 2006 12:10 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: All Along The Watchtower
Re: RE: Re: RE: Teleportation
AHA! The BFlog is finally useful now.
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `MoveEntityToNode' (a nil value)
stack traceback:
(none): in function <(none):28>
I thought I put it in the ScriptPostLoad function....it's right there in the LUA.
Maybe do you have to specify the specific node IN the path..?
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `MoveEntityToNode' (a nil value)
stack traceback:
(none): in function <(none):28>
I thought I put it in the ScriptPostLoad function....it's right there in the LUA.
Maybe do you have to specify the specific node IN the path..?
-
archer01
RE: Re: RE: Re: RE: Teleportation
What you have in your lua is just the "call" to the function. The function itself also has to be defined somewhere in your script (it is NOT one of the game's functions).
Here it is from the other thread:
Just paste that at the very end of your lua script.
Here it is from the other thread:
Code: Select all
function MoveEntityToNode(entIn,pathIn,nodeIn)
if not entIn then
print("Warning!: Entity not specified for move")
return false
elseif not pathIn then
print("Warning!: Path not specified for Entity " .. entIn .. " move")
return false
end
local node
if nodeIn then
node = nodeIn
else
node = 0
end
local locDest = GetPathPoint(pathIn,node)
local charUnit = GetCharacterUnit(entIn)
if charUnit then
SetEntityMatrix(charUnit,locDest)
return true
end
return false
end- jangoisbaddest
- Lieutenant General

- Posts: 661
- Joined: Mon Feb 27, 2006 12:10 am
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: All Along The Watchtower
