vp_terrain_node_set
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
- Upon successfully replacing a node,
VP_EVENT_TERRAIN_NODE_CHANGED
is triggered for any user subscribed to it. Seevp_event_set()
.
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);
}