User Tools

Site Tools


request_coordinate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
request_coordinate [2022/03/14 21:23] justinrequest_coordinate [2022/03/14 21:43] (current) justin
Line 10: Line 10:
  
 ^Argument^Description^Type^Required^ ^Argument^Description^Type^Required^
-|start_z|Initial Z coordinate of the selection cursor.|[[Number]]|Yes| +|start_z|Initial Z [[coordinate]] of the selection cursor.|[[Number]]|Yes| 
-|min_z|Minimum Z coordinate allowed.|[[Number]]|Yes| +|min_z|Minimum Z [[coordinate]] allowed.|[[Number]]|Yes| 
-|max_z|Maximum Z coordinate allowed.|[[Number]]|Yes| +|max_z|Maximum Z [[coordinate]] allowed.|[[Number]]|Yes| 
-|step_z|Amount to change the Z coordinate by when adjusting up/down.|[[Number]]|Yes|+|step_z|Amount to change the Z [[coordinate]] by when adjusting up/down.|[[Number]]|Yes|
 |validation_func|Name of custom function that is called to validate the [[coordinate]] at the current cursor location. If supplied, this function should have one input argument, into which the current [[coordinate]] will be passed.|[[String]]|No| |validation_func|Name of custom function that is called to validate the [[coordinate]] at the current cursor location. If supplied, this function should have one input argument, into which the current [[coordinate]] will be passed.|[[String]]|No|
  
 ====Example:==== ====Example:====
 <code bauxite> <code bauxite>
-request_coordinate(0, -64, 64, 16, "validate_coord");+function validate_coord($selected) begin 
 +  if tile[$selected.x, $selected.y, $selected.z] != null then 
 +    return false; 
 +  end; 
 +  $valid_coords = array[coord[7, 6, 0], coord[7, 5, 0], coord[7, 4, 0]]; 
 +  return $valid_coords contains $selected; 
 +end; 
 +$result = request_coordinate(0, -64, 64, 16, "validate_coord");
 </code> </code>
 //Results:// //Results://
-Prompts the player for a [[tile]] [[coordinate]], with a starting Z value of zero, a minimum of -64, a maximum of 64, and increments of 16. The custom "validate_coord" function is called to validate whether or not the [[coordinate]] at the current cursor location is valid.+Prompts the player for a [[tile]] [[coordinate]], with a starting Z value of zero, a minimum Z value of -64, a maximum Z value of 64, and increments of 16. The custom "validate_coord" function is called to check if the [[coordinate]] at the current cursor location is valid (in this case, it's ensuring that there isn't an existing [[tile]] at that location and that the [[coordinate]] is one of three allowed locations in the $valid_coords [[array]] variable). Once the player selects a valid [[coordinate]], it will be stored into the $result variable.
  
 <WRAP center round tip 100%> <WRAP center round tip 100%>
-Use the **Request Coordinate** function as a way for the player to dynamically place tiles into the world, for example to build walls, bridges, or even houses!+Use the **Request Coordinate** function as a way for the player to dynamically place tiles into the world, for example to build walls, bridges, or even houses.
 </WRAP> </WRAP>
  
request_coordinate.1647318209.txt.gz · Last modified: 2022/03/14 21:23 by justin