Page 1 of 1

Construction ingame menu script

Posted: Tue Jun 04, 2013 6:49 pm
by matias
When i use

EVENT("OSDSELECT","BuildOSD:001")
{
*buildingconstruct %PLAYER% 3 Tower
}

EVENT("PlaceBuilding","3")
{
$newBuildingID = sysAddBuilding( 3,$gPlayerID,$gPlayerX,$gPlayerY,Tower,25,75 )
}

A ghost model appears in the center of the tile but when i place the building its placed in the corner... how can i make it to be placed where the ghost model is?


I use placeing mode 1 in game settings

Posted: Tue Jun 04, 2013 8:29 pm
by Mit
sysAddBuilding uses map coordinates, what you're looking for is 'sysAddBuildingWorld' and you'll need the player's world rather than their map coordinate.
e.g.

Code: Select all

EVENT("PlaceBuilding","3") 
{ 
$newBuildingID = sysAddBuildingWorld( 3,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,Tower,25,75 ) 
} 

Posted: Tue Jun 04, 2013 8:46 pm
by matias
but that places the model where the player is not where the ghost model is i need to place the building in the center of the tile

I searched in forum and found the sysGetTileCenter( $worldX, $worldY ) but nobody used it yet or posted a script example

Posted: Tue Jun 04, 2013 10:03 pm
by Mit
ah ok.. that sounds like a bug which i'll need to look in to.. the sysAddBuilding should match the placing when in positioning mode 1.

Meanwhile, i think you can get the same effect by using the world coordinates and calculating the tile center as shown..

Code: Select all

EVENT("PlaceBuilding","3") 
{ 
$worldX = sysGetTileCenter( $gPlayerX )
$worldY = sysGetTileCenter( $gPlayerY )
$newBuildingID = sysAddBuildingWorld( 3,$gPlayerID,$worldX,$worldY,Tower,25,75 ) 
} 

Posted: Tue Jun 04, 2013 10:42 pm
by matias
Nop it doesnt work it makes a building error and i have to re import an old save to correct the error

Posted: Sat Jun 08, 2013 11:26 pm
by Mit
mm.. looks good to me and is used on aramathea to place towns without problems.
try replacing the 'sysAddBuildingWorld' with a

Code: Select all

*say Coord: $worldX , $worldY
to see if the variables are being set correctly? (I presume the error is comin from having a building at 0,0)