LuaAPI.wiki
changeset 940 8c4a529edddb
parent 936 14d3c48a8913
child 942 cca9e43e9d72
equal deleted inserted replaced
939:39ed0b23ef49 940:8c4a529edddb
   353 `spriteID` is the type of the sprite, you find a list at [Sprites Sprites]. `centerX` and `centerY` are the coordinates of the center of the sprite.
   353 `spriteID` is the type of the sprite, you find a list at [Sprites Sprites]. `centerX` and `centerY` are the coordinates of the center of the sprite.
   354 
   354 
   355 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) ===
   355 === <tt>onGirderPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) ===
   356 This function is called when a girder has been placed.
   356 This function is called when a girder has been placed.
   357 
   357 
   358 `frameIdx` is an integer and declares the length and orientation of the girder:
   358 `frameIdx` is used for the length and orientation of the girder. The possible values are explained in `PlaceGirder`. `centerX` and `centerY` are the coordinates of the girder’s center.
   359 || *`frameIdx`* || *Length* || *Orientation* ||
       
   360 || 0 || short || horizontal ||
       
   361 || 1 || short || decreasing right ||
       
   362 || 2 || short || vertical ||
       
   363 || 3 || short || increasing right ||
       
   364 || 4 || long || horizontal ||
       
   365 || 5 || long || decreasing right ||
       
   366 || 6 || long || vertical ||
       
   367 || 7 || long || increasing right ||
       
   368 
       
   369 `centerX` and `centerY` are the coordinates of the girder’s center.
       
   370 
   359 
   371 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) ===
   360 === <tt>onRubberPlacement(frameIdx, centerX, centerY)</tt> (0.9.21) ===
   372 This function is called when a rubber has been placed.
   361 This function is called when a rubber has been placed.
   373 
   362 
   374 `frameIdx` is an integer which stands for the orientation of the rubber.
   363 `frameIdx` is used for the rubber orientation. The possible values are explained in `PlaceRubber`. `centerX` and `centerY` are the coordinates of the rubber’s center.
   375 
       
   376 || *`frameIdx`* || *Orientation* ||
       
   377 || 0 || horizontal ||
       
   378 || 1 || decreasing right ||
       
   379 || 2 || vertical ||
       
   380 || 3 || increasing right ||
       
   381 
       
   382 `centerX` and `centerY` are the coordinates of the rubber’s center.
       
   383 
   364 
   384 == Functions for creating gears ==
   365 == Functions for creating gears ==
   385 
   366 
   386 === <tt>!AddGear(x, y, gearType, state, dx, dy, timer)</tt> ===
   367 === <tt>!AddGear(x, y, gearType, state, dx, dy, timer)</tt> ===
   387 This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]). The initial velocities are `dx` and `dy`. All arguments are numbers. The function returns the `uid` of the gear created. Gears can have multple states at once: `state` is a bitmask, the flag variables can be found in [States].
   368 This creates a new gear at position x,y (measured from top left) of kind `gearType` (see [GearTypes Gear Types]). The initial velocities are `dx` and `dy`. All arguments are numbers. The function returns the `uid` of the gear created. Gears can have multple states at once: `state` is a bitmask, the flag variables can be found in [States].
   989 Returns `true`/`false` if the map has a border or not.
   970 Returns `true`/`false` if the map has a border or not.
   990 
   971 
   991 ==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ====
   972 ==== <tt>!TestRectForObstacle(x1, y1, x2, y2, landOnly) (0.9.16) </tt> ====
   992 Checks the rectangle between the given coordinates for possible collisions. Set `landOnly` to `true` if you don’t want to check for collisions with gears (hedgehogs, etc.).
   973 Checks the rectangle between the given coordinates for possible collisions. Set `landOnly` to `true` if you don’t want to check for collisions with gears (hedgehogs, etc.).
   993 
   974 
   994 ==== <tt>!PlaceGirder(x, y, state)</tt> (0.9.16) ====
   975 ==== <tt>!PlaceGirder(x, y, frameIdx)</tt> (0.9.16) ====
   995 Attempts to place girder with centre points `x`, `y` and a certain length and orientation, specified by `state`. The girder can only be placed in open space and must not collide with anything so this function may fail. It will return `true` on successful placement and `false` on failure.
   976 Attempts to place a girder with centre points `x`, `y` and a certain length and orientation, specified by `frameIdx`. The girder can only be placed in open space and must not collide with anything so this function may fail. It will return `true` on successful placement and `false` on failure.
   996 
   977 
   997 These are the accepted states:
   978 These are the accepted values for `frameIdx`:
   998 
   979 
   999 || *`state`* || *Length* || *Orientation* ||
   980 || *`frameIdx`* || *Length* || *Orientation* ||
  1000 || 0 || short || horizontal ||
   981 || 0 || short || horizontal ||
  1001 || 1 || short || decreasing right ||
   982 || 1 || short || decreasing right ||
  1002 || 2 || short || vertical ||
   983 || 2 || short || vertical ||
  1003 || 3 || short || increasing right ||
   984 || 3 || short || increasing right ||
  1004 || 4 || long || horizontal ||
   985 || 4 || long || horizontal ||
  1005 || 5 || long || decreasing right ||
   986 || 5 || long || decreasing right ||
  1006 || 6 || long || vertical ||
   987 || 6 || long || vertical ||
  1007 || 7 || long || increasing right ||
   988 || 7 || long || increasing right ||
       
   989 
       
   990 ==== <tt>!PlaceRubber(x, y, frameIdx)</tt> (0.9.23) ====
       
   991 Attempts to place a rubber with centre points `x`, `y` and a certain orientation, specified by `frameIdx`. The rubber can only be placed in open space and must not collide with anything so this function may fail. It will return `true` on successful placement and `false` on failure.
       
   992 
       
   993 These are the accepted values for `frameIdx`:
       
   994 
       
   995 || *`frameIdx`* || *Orientation* ||
       
   996 || 0 || horizontal ||
       
   997 || 1 || decreasing right ||
       
   998 || 2 || vertical ||
       
   999 || 3 || increasing right ||
  1008 
  1000 
  1009 ==== <tt>!PlaceSprite(x, y, sprite, frameIdx, tint, behind, flipHoriz, flipVert, [, landFlag, ...])</tt> ====
  1001 ==== <tt>!PlaceSprite(x, y, sprite, frameIdx, tint, behind, flipHoriz, flipVert, [, landFlag, ...])</tt> ====
  1010 Places a [Sprites sprite] at the specified position (`x`, `y`) on the map, it behaves like terrain then. Unlike `PlaceGirder`, this function does not check for collisions, so the sprite can be placed anywhere within map boundaries. The function returns `true` if the placement was successful, `false` otherwise. `frameIdx` is the frame index starting by 0. `frameIdx` is used if the sprite consists of several sub-images. Only a subset of the sprites is currently supported by this function:
  1002 Places a [Sprites sprite] at the specified position (`x`, `y`) on the map, it behaves like terrain then. Unlike `PlaceGirder`, this function does not check for collisions, so the sprite can be placed anywhere within map boundaries. The function returns `true` if the placement was successful, `false` otherwise. `frameIdx` is the frame index starting by 0. `frameIdx` is used if the sprite consists of several sub-images. Only a subset of the sprites is currently supported by this function:
  1011 
  1003 
  1012  * `sprAmGirder`
  1004  * `sprAmGirder`