Difference between revisions of "Functions"

From The Powder Toy
Jump to: navigation, search
m (info on using 0 for flags parameter)
(update for tpt++)
Line 1: Line 1:
 
This is list of functions with their variables, every function is described. There is recommended to read article [[Hotkeys]], it's helpful to understand description of some functions.
 
This is list of functions with their variables, every function is described. There is recommended to read article [[Hotkeys]], it's helpful to understand description of some functions.
  
'''''clear_area(int area_x, int area_y, int area_w, int area_h)''''' - (like CTRL-Erase) Clears the area with height '''h''' and width '''w'''.  ('''x''','''y''') is the top left corner.
+
'''''sim->clear_area(int area_x, int area_y, int area_w, int area_h)''''' - (like CTRL-Erase) Clears the area with height '''h''' and width '''w'''.  ('''x''','''y''') is the top left corner.
  
'''''create_part(int p, int x, int y, int t)''''' - Creates particle which type is '''t''' at ['''x''','''y''']. For '''p''' use -1.
+
'''''sim->create_part(int p, int x, int y, int t)''''' - Creates particle which type is '''t''' at ['''x''','''y''']. For '''p''' use -1.
  
'''''create_box(int x1, int y1, int x2, int y2, int c)''''' - Creates rectangle (like CTRL in PT).
+
'''''sim->CreateBox(int x1, int y1, int x2, int y2, int c, int flags)''''' - Creates rectangle (like CTRL in PT).
'''''x1''''', '''''y1''''' is first corner position, '''''x2''''','''''y2''''' is second corner position, '''c''' is particle type.
+
'''''x1''''', '''''y1''''' is first corner position, '''''x2''''','''''y2''''' is second corner position, '''c''' is particle type. Use 0 for flags.
  
'''''create_line(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags)''''' - Like '''''create_box''''', but '''''x1''''','''''y1''''','''''x2''''','''''y2''''' are line ends position. c is the particle to create. Use 0 for flags.
+
'''''sim->CreateLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags)''''' - Like '''''create_box''''', but '''''x1''''','''''y1''''','''''x2''''','''''y2''''' are line ends position. c is the particle to create. Use 0 for flags.
  
'''''delete_part(int x, int y, int flags)''''' - Deletes part at defined position. Use 0 for flags.
+
'''''sim->delete_part(int x, int y, int flags)''''' - Deletes part at defined position. Use 0 for flags.
  
'''''flood_parts(int x, int y, int fullc, int cm, int bm, int flags)''''' - Flood fill. ('''''x''''','''''y''''') is the location to start the fill. '''''fullc&0xFF''''' is the particle type to fill(not the particle itself but the number ex. PT_DUST). set '''''cm''''' and '''''bm''''' to -1, and '''''flags''''' to 0
+
'''''sim->FloodParts(int x, int y, int fullc, int cm, int bm, int flags)''''' - Flood fill. ('''''x''''','''''y''''') is the location to start the fill. '''''fullc&0xFF''''' is the particle type to fill(not the particle itself but the number ex. PT_DUST). set '''''cm''''' and '''''bm''''' to -1, and '''''flags''''' to 0
  
'''''kill_part(int i)''''' - Deletes particle 'with index ''''i'''''.(Does not use x,y location like delete_part)
+
'''''sim->flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype)''''' - Property flood. '''''X''''' and '''''Y''''' are the coordinates to flood at. For '''''propoffset''''', use '''''offsetof(Particle, tmp)''''', replacing tmp with the property you want to use. Declare a variable holding the value you want to use (Ex. int tempvalue = 2) and pass it into '''''propvalue''''' like '''''&tempvalue'''''. For the last argument, use '''''StructProperty::Integer''''', '''''StructProperty::Float''''', or '''''StructProperty::Uinteger''''', depending on what type the property is.
  
'''''nearest_part(int ci,int t, int max_d)''''' - Returns nearest particle of type '''''t'''''. '''''ci''''' is current particle. If '''''max_d''''' is not -1, it limits how far away the particle can be. It returns -1 if nothing was found.
+
'''''sim->kill_part(int i)''''' - Deletes particle 'with index ''''i'''''.(Does not use x,y location like delete_part)
  
'''''parts_avg(int ci, int ni, int t)''''' - Returns if t is directly in between the particles with indexes '''''ci''''' and '''''ni''''', or, if '''''t''''' is PT_INSL, if their is a particle directly in between them.
+
'''''sim->nearest_part(int ci,int t, int max_d)''''' - Returns nearest particle of type '''''t'''''. '''''ci''''' is current particle. If '''''max_d''''' is not -1, it limits how far away the particle can be. It returns -1 if nothing was found.
  
'''''part_change_type(int i, int x, int y, int t)''''' - Changes type of particle '''''i'''''. '''''t''''' is new type, '''''x''''' is the x location of the particle, '''''y''''' is the y location of the particle.
+
'''''sim->parts_avg(int ci, int ni, int t)''''' - Returns if t is directly in between the particles with indexes '''''ci''''' and '''''ni''''', or, if '''''t''''' is PT_INSL, if their is a particle directly in between them.
 +
 
 +
'''''sim->part_change_type(int i, int x, int y, int t)''''' - Changes type of particle '''''i'''''. '''''t''''' is new type, '''''x''''' is the x location of the particle, '''''y''''' is the y location of the particle.

Revision as of 23:54, 4 November 2012

This is list of functions with their variables, every function is described. There is recommended to read article Hotkeys, it's helpful to understand description of some functions.

sim->clear_area(int area_x, int area_y, int area_w, int area_h) - (like CTRL-Erase) Clears the area with height h and width w. (x,y) is the top left corner.

sim->create_part(int p, int x, int y, int t) - Creates particle which type is t at [x,y]. For p use -1.

sim->CreateBox(int x1, int y1, int x2, int y2, int c, int flags) - Creates rectangle (like CTRL in PT). x1, y1 is first corner position, x2,y2 is second corner position, c is particle type. Use 0 for flags.

sim->CreateLine(int x1, int y1, int x2, int y2, int rx, int ry, int c, int flags) - Like create_box, but x1,y1,x2,y2 are line ends position. c is the particle to create. Use 0 for flags.

sim->delete_part(int x, int y, int flags) - Deletes part at defined position. Use 0 for flags.

sim->FloodParts(int x, int y, int fullc, int cm, int bm, int flags) - Flood fill. (x,y) is the location to start the fill. fullc&0xFF is the particle type to fill(not the particle itself but the number ex. PT_DUST). set cm and bm to -1, and flags to 0

sim->flood_prop(int x, int y, size_t propoffset, void * propvalue, StructProperty::PropertyType proptype) - Property flood. X and Y are the coordinates to flood at. For propoffset, use offsetof(Particle, tmp), replacing tmp with the property you want to use. Declare a variable holding the value you want to use (Ex. int tempvalue = 2) and pass it into propvalue like &tempvalue. For the last argument, use StructProperty::Integer, StructProperty::Float, or StructProperty::Uinteger, depending on what type the property is.

sim->kill_part(int i) - Deletes particle 'with index 'i.(Does not use x,y location like delete_part)

sim->nearest_part(int ci,int t, int max_d) - Returns nearest particle of type t. ci is current particle. If max_d is not -1, it limits how far away the particle can be. It returns -1 if nothing was found.

sim->parts_avg(int ci, int ni, int t) - Returns if t is directly in between the particles with indexes ci and ni, or, if t is PT_INSL, if their is a particle directly in between them.

sim->part_change_type(int i, int x, int y, int t) - Changes type of particle i. t is new type, x is the x location of the particle, y is the y location of the particle.