Construction ingame menu script

Forum Archive - from http://theuniversal.net
Locked
User avatar
matias
World Owner
World Owner
Posts: 46
Joined: Wed Apr 24, 2013 7:37 pm

Construction ingame menu script

Post 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
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post 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 ) 
} 
User avatar
matias
World Owner
World Owner
Posts: 46
Joined: Wed Apr 24, 2013 7:37 pm

Post 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
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post 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 ) 
} 
User avatar
matias
World Owner
World Owner
Posts: 46
Joined: Wed Apr 24, 2013 7:37 pm

Post by matias »

Nop it doesnt work it makes a building error and i have to re import an old save to correct the error
User avatar
Mit
Staff
Staff
Posts: 3551
Joined: Sun Sep 21, 2003 10:14 pm
Location: Unknown

Post 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)
Locked