PDA

View Full Version : Moving Platform can't locate TAG



Pleng
12-12-2010, 11:26 AM
I've copied a moving platform from the Treeworld example and also two waypoints.
If I hard code the names of the waypoints into the platform's script, it works as expected. However I'm going to need several platforms on each level so I'd like to make use of the platform's Data() to control where it is moving from and to.

This is my code:



function OnMapInsert() //run as the entity is placed on an actual map, but before OnPostInit()
GetWatchManager:Add(this, C_TIME_FOREVER); //always function offscreen
this:SetDensity(1.8); //make smaller for more floaty
this:SetGravityOverride(0);
end

function OnInit() //run upon initialization

//hint to the path-finding system that it can ignore this while computing paths if it needs to
this:SetIsCreature(true);

end

function OnPostInit() //run after being placed on a map

this:SetCollisionCategory(C_CATEGORY_TILEPIC, false); //allow this to move through static tilepic things
this:GetBrainManager():Add("StandardBase","");
m_PointA=this:Data():Get("PointA");
m_PointB=this:Data():Get("PointB");
m_PointA="Plat1A";
m_PointB="Plat1C";
AddPatrolGoals();

end

function OnKill() //run when removed

end

function AddPatrolGoals()

//let the platform move between the checkpoints

this:GetGoalManager():AddMoveToPosition(GetTagMana ger:GetPosFromName(m_PointA));
this:GetGoalManager():AddMoveToPosition(GetTagMana ger:GetPosFromName(m_PointB));
//when complete, do it again
this:GetGoalManager():AddRunScriptString("AddPatrolGoals()");

end



As you can see the variables holding the waypoint names are initialized to this:Data():Get(....) then over written with static values. If I remove the code

m_PointA="Plat1A";
m_PointB="Plat1C";

so that the script relies on the data stored within the object I get the following error message repeated over and over in the console:

TagManager::GetPosFromName: Can't locate TAG , sending back 0.0

The platform still kind of moves in the right way, though sometimes a bit further up, sometimes a bit further down than it is supposed to.

Any ideas why this isn't working correctly?

Seth
12-13-2010, 01:05 PM
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0

This error message specifies which tag after the TAG word, there is none, so you can assume m_PointB is a blank string.

maybe m_PointB="Plat1C" should be m_PointB="Plat1B"? I'd take a close look at the data, do a LogMsg(m_PointB); etc right after reading from it to verify what's in it.

Pleng
12-13-2010, 04:38 PM
Hi Seth

This is just.... strange!

I've adapted the AddPatrolGoals() to display the values of the variables as you suggested:



function AddPatrolGoals()

//let the platform move between the checkpoints
LogMsg("Setting Platform Targets");
LogMsg(m_PointA);
LogMsg(m_PointB);
this:GetGoalManager():AddMoveToPosition(GetTagMana ger:GetPosFromName(m_PointA));
this:GetGoalManager():AddMoveToPosition(GetTagMana ger:GetPosFromName(m_PointB));
//when complete, do it again
this:GetGoalManager():AddRunScriptString("AddPatrolGoals()");

end


And the engine appears to sometimes acknowledge the values, and sometimes not. I've attached the output log for your viewing pleasure!

And yes, if I hard code the variable values the LogMsg always displays them.

Oh and yes, Plat1C is intentional.



Initializing GameLogic...
Clanlib Sound System Initialized
Mounting world path worlds/Elevation.
Updated binary version of worlds/Elevation/script/misc\ent_platform.lua
Novashell V0.81 and Lua 5.13 RT Edition Initted.
Initting world
Initting intro menu
Loaded map Intro at tick 14175. 12 non-empty chunks, size is 2 by 5.
Initting coins..
Resetting!
Clearing all maps
User profile path now D:\Dropbox\My Dropbox\Development\Novashell/profiles/Player/Elevation
Running our custom tree world game start code.
Setting game defaults
Map Inside not found
Loaded map Main at tick 0. 79 non-empty chunks, size is 12 by 7.
Inserting interface..
Initting interface
Setting up overlays..
Loaded map System Palette at tick 0. 4 non-empty chunks, size is 1 by 1.
New Intromenu! Found player in Main Inside at X:2351.00 Y: -58.00
Loaded map Main Inside at tick 0. 18 non-empty chunks, size is 6 by 2.
Setting up platform paths


Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting up platform paths
Plat1A
Plat1C
Setting Platform Targets
Plat1A
Plat1C
Initializing the player entity.
Am I even Being triggered
X:2079.00 Y: -476.00
X:2300.00 Y: -600.00
Setting Platform Targets
Plat1A
Plat1C
Setting Platform Targets
Plat1A
Plat1C
Editor opened up
Setting retail to false
Editor closed
Setting Platform Targets
Plat1A
Plat1C
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets
Plat1A
Plat1C
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets
Plat1A
Plat1C
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets
Plat1A
Plat1C
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets
Plat1A
Plat1C
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Setting Platform Targets


TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
TagManager::GetPosFromName: Can't locate TAG , sending back 0.0
Editor opened up
Setting retail to false
Toggling windowed mode

Seth
12-15-2010, 12:27 AM
Yeah, that is weird. I can't see any reason in the script you've posted why the script variable m_PointA would sometimes be set and sometimes be nil/blank. :confused:

Pleng
12-15-2010, 11:59 AM
Especially as when you initialize then with literals at exactly the same place in the code the problem doesn't occur.

It just doesn't make any sense at all :(