vp_terrain_node_set

From Virtual Paradise Wiki
Revision as of 20:40, 13 December 2016 by Sleepy E (talk | contribs) (Basic layout)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Method call snippet vp_terrain_node_set(instance, tile_x, tile_z, node_x, node_z, cells);

Replace terrain node data.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
int
tile_x
Tile X coordinate (with no terrain scaling, divide coordinates in decameter by 32 to get tile coordinates)
int
tile_z
Tile Z coordinate
int
node_x
Node X coordinate (within tile, 0 to 3)
int
node_z
Node Z coordinate
vp_terrain_cell_t*
cells
Pointer to 64 cells (8x8: cells[z*8+x])

Returns

This method returns a return code integer, which indicates whether the call was successful or errored for any reason:

Return code Cause
VP_RC_SUCCESS Successful call (for methods that have a registered callback, it only means the request has been sent)
VP_RC_NOT_IN_WORLD Bot is not currently in a world

Behavior

Examples

/*
 * Set the height of the terrain node containing the terrain cell coordinate x, z (Note: it will reset the texture, rotation and hole flag!)
 */

void set_terrain_node_height(VPInstance sdk, int x, int z, float height)
{
  int tile_x, tile_z;

  tile_x = x / 32;
  tile_z = z / 32;

  int node_x, node_z;

  node_x = (x % 32) / 8;
  node_z = (z % 32) / 8;

  struct vp_terrain_cell_t cells[64];

  memset(cells, 0, sizeof(cells));

  for (int i = 0; i < 64; i++)
    cells[i].height = height;

  vp_terrain_node_set(sdk, tile_x, tile_z, node_x, node_z, cells);
}

See also