Custom tile data
by Drew -Gaiiden- Sikora · in Torque Game Builder · 12/15/2005 (8:12 pm) · 8 replies
If I did this:
%tileInfo = new ScriptObject(TileInfo); %tileInfo.type = 1; %tileInfo.player = 2; %tileLayer.setTileCustomData(%tileXY, %tileInfo);Would that save properly in the map file?
#2
- Melv.
12/16/2005 (12:22 am)
I'll just add that I gave some thought on how people can save associated script data/objects alongside the standard load/save stuff and there are a number of ways to potentially achieve this but it wasn't something that I got around to doing.- Melv.
#3
12/16/2005 (9:15 am)
Thanks Melv. Well then, I suppose I'll just have to do something like%tileInfo = %tileType SPC %tilePlayer; %tileLayer.setTileCustomData(%tileXY, %tileInfo);and then be like
%tileInfo = %tileLayer.getTileCustomData(%tileXY); %tileType = getWord(%tileInfo, $TILE_INFO_TYPE); %tilePlayer = getWord(%tileInfo, $TILE_INFO_PLAYER);right?
#4
Make sense or have I missed what you're really asking? I do that. ;)
- Melv.
12/16/2005 (11:39 am)
I'm not sure what the info is that you're saving here. All I'm really saying is that this option saves a string, not objects as you assigned them in your first post. All you'll end up saving in that case is the object id, not its number. You certainly won't get a new ScriptObject constructed when you retrieve the data, just the old object ID which probably won't exist when you do.Make sense or have I missed what you're really asking? I do that. ;)
- Melv.
#5
12/16/2005 (3:41 pm)
No I understand what you're saying Melv, the solution I gave in my second post is different, I'm now saving a vector and using the getWord() function to access the data. That's fine right?
#6
- Melv.
12/17/2005 (10:16 am)
As long as you understand that saving an object ID doesn't save the object, you're fine. Encode anything you like as the string and it should work.- Melv.
#7
12/17/2005 (1:21 pm)
K thx for the help. I'm just saving a string now, no more objects :)
#8
12/18/2005 (12:48 am)
Cool. :)
Employee Melv May
Objects in TGE are just numbers, the ones you can get explcitly in script using something like "%tileInfo.getId()".
- Melv.