Page 1 of 1
PlaceObject ?
Posted: Fri May 06, 2011 7:49 pm
by Merr
Pip,
I was hoping to write a script for a random map but I can't understand how to make the PlaceObject function to work.
The parameters look like something for SpotAnimation and there are no parameters for tile coordinates.
Got an example that this could be used for?
Thanks.
Posted: Fri May 06, 2011 8:50 pm
by pipfromslitherine
wow - pretty ambitious! But would be supercool if you could make it happen

.
PlaceObject takes the coordinates in 100ths, so to place it at the center of tile 0,0 you would use the coordinates 50,50.
The set and object entries are basically the folder and filename (minus the type) of the object you want to place.
A working example would be:
PlaceObject(1850, 2050, "bulge", "dragons_teeth_snow") ;
which would place the teeth in the middle of the tile at 18,20
Hope that helps - any more questions feel free to ask
Cheers
Pip
Posted: Fri May 06, 2011 9:25 pm
by Merr
pipfromslitherine wrote:wow - pretty ambitious! But would be supercool if you could make it happen

.
PlaceObject takes the coordinates in 100ths, so to place it at the center of tile 0,0 you would use the coordinates 50,50.
The set and object entries are basically the folder and filename (minus the type) of the object you want to place.
A working example would be:
PlaceObject(1850, 2050, "bulge", "dragons_teeth_snow") ;
which would place the teeth in the middle of the tile at 18,20
Hope that helps - any more questions feel free to ask
Cheers
Pip
Wicked! .... Ok, I knew it was 100dth's but didn't get that far last night... I had the 50,50 but didn't think to add the tiles coord's to make it read 1850,2050 ...
Now ... the comments say that it returns an ID .... well, my next question is how to remove an object, I'll need an ID for that.... where does the ID come from?
Finally ... there are some functions that need an index number, showing it as [0,3] ... Whats an index number and why are there 4 values (I assume 0,1,2,3).
Thanks alot Pip !... I was disappointed last night writing my outline for a random map and it was a major road block.
Rob
Posted: Fri May 06, 2011 9:33 pm
by pipfromslitherine
The PlaceObject command returns an ID which you can use to rotate, etc - basically any of the SetObject commands, or the DeleteObject command.
You can get the ids of existing objects using the GetObjectFromName or GetTileObject commands. IDs are unique per object, but can change across runs of the game.
When you ask about index numbers, I assume you mean the Get/SetTileData commands? The index is basically telling the command which of the 4 data entries you want to operate on (index 0 is used by the carryover system). You probably don't need to use these commands unless you are looking to store some data as part of your map generation process?
Any other questions, let me know
Cheers
Pip
Posted: Mon May 09, 2011 4:01 am
by Merr
pipfromslitherine wrote:The PlaceObject command returns an ID which you can use to rotate, etc - basically any of the SetObject commands, or the DeleteObject command.
You can get the ids of existing objects using the GetObjectFromName or GetTileObject commands. IDs are unique per object, but can change across runs of the game.
I'm having trouble getting the ID which results in me not being able to rotate, etc. Wouldn't it have been easier to add the rotation and scale parameters to the PlaceObject function? Can you post a little script that places an object, then gets the ID then rotates it? I do much better with an example because most of the time I'm running trial and error runs.
Thanks.
Posted: Wed May 11, 2011 3:15 pm
by pipfromslitherine
This is a quick example
// place the object and get the id
id = PlaceObject(1850, 2050, "bulge", "dragons_teeth_snow") ;
// set scale to be 2x
SetObjectScale(id, 200);
// rotate by 45 degrees
SetObjectRotation(id, 4500) ;
I broke it out because this way you can alter the various params over time as you like (e.g. to have a rotating object, or one that moves) without having to constantly create and destroy them.
Hope that helps - let me know if anything else needs clarification
Cheers
Pip
Posted: Wed May 11, 2011 6:59 pm
by Merr
Pip,
I thought you were OOO

... No matter, thank you for your example, it works, but ... There's a problem with ROTATION ...
The value of 4500 works, but that's the only one (coincidence?) .... Rotation may indeed be in 100th's, but it's not in degrees.
I found that the Rotation value is the same value used by the BAM, but in 100ths ... example ;
Clockwise Rotation from default facing ... (from BAM)
0 = default facing
90 = 1.570796 (use 157 in SetObjectRotation)
180 = 3.141593 (use 314 in SetObjectRotation)
270 = 4.712389 (use 471 in SetObjectRotation)
I have more questions but I'll post them seperately ... Thanks!
Posted: Wed May 11, 2011 9:31 pm
by pipfromslitherine
Gah - looks like I have left it in radians - not what I intended. It's a simple fix - although it would then break anything you write now. Perhaps put in a function for now which converts degrees to radians (basically rads = (deg * PI)/180 ) and if I fix it you can then just alter that function to do nothing (pass back your degrees).
Or just use radians - but that feels like we get less accuracy.
Thanks for spotting that - I imagine I wasn't actually trying specific angles when I tested it.
Cheers
Pip