LuaAPI.wiki
changeset 688 d9fc58ac04f2
parent 685 06cd9e0842e4
child 689 e919bdf895f7
equal deleted inserted replaced
687:fe70504acfc2 688:d9fc58ac04f2
   551 === <tt>!GetGearValues(gearUid)</tt> (0.9.22) ===
   551 === <tt>!GetGearValues(gearUid)</tt> (0.9.22) ===
   552 This returns a bunch of values associated with the gear, their meaning is often depending on the gear type and many values might be unused for certain gear types.
   552 This returns a bunch of values associated with the gear, their meaning is often depending on the gear type and many values might be unused for certain gear types.
   553 
   553 
   554 This is returned (all variables are integers):
   554 This is returned (all variables are integers):
   555 
   555 
   556 `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage`
   556 `Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom`
       
   557 
       
   558 Boom is 0.9.23+
   557 
   559 
   558 A rough description of some of the parameters:
   560 A rough description of some of the parameters:
   559 
   561 
   560  * `Radius`: Effect or collision radius, most of the time
   562  * `Radius`: Effect or collision radius, most of the time
   561  * `ImpactSound`: Sound it makes on a collision (see [Sounds])
   563  * `ImpactSound`: Sound it makes on a collision (see [Sounds])
   562  * `Tint`: Used by some gear types to determine its colorization. The color is in RGBA format.
   564  * `Tint`: Used by some gear types to determine its colorization. The color is in RGBA format.
   563 
   565  * `Boom`: Used by most gears to determine the damage dealt. (0.9.23+)
   564 Example:
   566 
   565 <code language="lua">
   567 Example:
   566 -- Get all values in a single line of code:
   568 <code language="lua">
   567 local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage = GetGearValues(myGear)
   569 -- Get all values in a single line of code (omit Boom in 0.9.22) :
       
   570 local Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, nImpactSounds, Tint, Damage, Boom = GetGearValues(myGear)
   568 </code>
   571 </code>
   569 
   572 
   570 === <tt>!GetVisualGearValues(vgUid)</tt> ===
   573 === <tt>!GetVisualGearValues(vgUid)</tt> ===
   571 This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values:
   574 This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles. It returns the following values:
   572 
   575 
   621 Example:
   624 Example:
   622 
   625 
   623 <code language="lua">    vgear = AddVisualGear(...)
   626 <code language="lua">    vgear = AddVisualGear(...)
   624     DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code>
   627     DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code>
   625 
   628 
   626 === <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage)</tt> (0.9.22) ===
   629 === <tt>!SetGearValues(gearUid, Angle, Power, WDTimer, Radius, Density, Karma, DirAngle, AdvBounce, ImpactSound, ImpactSounds, Tint, Damage, Boom)</tt> (0.9.22) ===
   627 Sets various gear value for the specified gear (`gearUid`). The meaining of each value often depends on the gear type. See the documentation on !GetGearValues for a brief description of the gear values.
   630 Sets various gear value for the specified gear (`gearUid`). The meaining of each value often depends on the gear type. See the documentation on !GetGearValues for a brief description of the gear values.  Boom is 0.9.23+.
   628 
   631 
   629 Set `nil` for each value you do not want to change.
   632 Set `nil` for each value you do not want to change.
   630 
   633 
   631 Example:
   634 Example:
   632 <code language="lua">
   635 <code language="lua">
   909 || 4 || long || horizontal ||
   912 || 4 || long || horizontal ||
   910 || 5 || long || decreasing right ||
   913 || 5 || long || decreasing right ||
   911 || 6 || long || vertical ||
   914 || 6 || long || vertical ||
   912 || 7 || long || increasing right ||
   915 || 7 || long || increasing right ||
   913 
   916 
   914 ==== <tt>!PlaceSprite(x, y, sprite, frameIdx, ...)</tt> ====
   917 ==== <tt>!PlaceSprite(x, y, sprite, frameIdx, tint, behind, flipHoriz, flipVert, [, landFlag, ...])</tt> ====
   915 Places a [Sprites sprite] at the specified position (`x`, `y`) on the map, it behaves like terrain then. `frameIdx` is the frame index starting by 0. This is used if the sprite consists of several sub-images. Only a subset of the sprites is currently supported by this function:
   918 Places a [Sprites sprite] at the specified position (`x`, `y`) on the map, it behaves like terrain then. `frameIdx` is the frame index starting by 0. This is used if the sprite consists of several sub-images. Only a subset of the sprites is currently supported by this function:
   916 
   919 
   917  * `sprAmGirder`
   920  * `sprAmGirder`
   918  * `sprAmRubber`
   921  * `sprAmRubber`
   919  * `sprAMSlot`
   922  * `sprAMSlot`
   935  * `sprBotlevels`
   938  * `sprBotlevels`
   936  * `sprIceTexture`
   939  * `sprIceTexture`
   937  * `sprCustom1`
   940  * `sprCustom1`
   938  * `sprCustom2`
   941  * `sprCustom2`
   939 
   942 
   940 The 5th and later arguments specify land flags (see the constants section) to be used for the newly created terrain. If omited, `lfNormal` is assumed.
   943 Tint is for an RGBA colouring to apply, this works about the same as Tint in gears.  Behind indicates the sprite should not replace existing land. flipHoriz and flipVert are for flipping the sprite vertically and horizontally before placing.
   941 
   944 The 9th and later arguments specify land flags (see the constants section) to be used for the newly created terrain. If omited, `lfNormal` is assumed.
   942 Example:
   945 
   943 
   946 Example:
   944 <code language="lua">PlaceSprite(2836, 634, sprAmGirder, 5, lfNormal)
   947 
       
   948 <code language="lua">PlaceSprite(2836, 634, sprAmGirder, 5)
   945 -- Places the girder sprite as normal terrain at (2836, 634). The `frameIdx` 5 is for the long decreasing right girder.</code>
   949 -- Places the girder sprite as normal terrain at (2836, 634). The `frameIdx` 5 is for the long decreasing right girder.</code>
   946 <code language="lua">PlaceSprite(1411, 625, sprAmRubber, 1, lfBouncy)
   950 <code language="lua">PlaceSprite(1411, 625, sprAmRubber, 1, nil, nil, nil, nil, lfBouncy)
   947 -- Places the rubber band sprite as bouncy terrain at (2836, 634). The `frameIdx` 1 is for the decreasing right rubber band.</code>
   951 -- Places the rubber band sprite as bouncy terrain at (2836, 634). The `frameIdx` 1 is for the decreasing right rubber band.</code>
       
   952 
       
   953 ==== <tt>!EraseSprite(x, y, sprite, frameIdx, eraseOnLFMatch, onlyEraseLF, flipHoriz, flipVert, [, landFlag, ...])</tt> ====
       
   954 Erases a [Sprites sprite] at the specified position (`x`, `y`) on the map. `frameIdx` is the frame index starting by 0. sprite, frameIdx, flipHoriz and flipVert behave the same as in PlaceSprite.
       
   955 
       
   956 Set eraseOnLFMatch to true to erase all land for a pixel that matches any of the passed in land flags.  This is useful if, for example, an lfBouncy sprite was placed "behind" land using PlaceSprite and you want to remove it without destroying the non-bouncy terrain.
       
   957 
       
   958 Set onlyEraseLF to true to only remove specific land flags.  If for example a sprite consists of lfIndestructible and lfBouncy, and you call EraseSprite with onlyEraseLF and lfIndestructible set, the sprite will remain bouncy but can be destroyed.  You can use this to entirely remove all land flags from a sprite - at this point the sprite will be visual only, painted on the map but with no collision.
       
   959 
       
   960 Example:
       
   961 
       
   962 <code language="lua">EraseSprite(2836, 634, sprAmGirder, 5)
       
   963 -- Removes the girder sprite at (2836, 634). The `frameIdx` 5 is for the long decreasing right girder.</code>
       
   964 <code language="lua">EraseSprite(1411, 625, sprAmRubber, 1, true, true, nil, nil, lfIndestructible)
       
   965 -- Removes indestructibility from a rubber band sprite at (2836, 634). The `frameIdx` 1 is for the decreasing right rubber band.</code>
   948 
   966 
   949 ==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> (0.9.21) ====
   967 ==== <tt>!AddPoint(x, y [, width [, erase] ])</tt> (0.9.21) ====
   950 This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”.
   968 This function is used to draw your own maps using Lua. The maps drawn with this are of type “hand-drawn”.
   951 
   969 
   952 The function takes a `x`,`y` location, a `width` (means start of a new line) and `erase` (if `false`, this function will draw normally, if `true`, this function will erase drawn stuff).
   970 The function takes a `x`,`y` location, a `width` (means start of a new line) and `erase` (if `false`, this function will draw normally, if `true`, this function will erase drawn stuff).