LuaAPI.wiki
changeset 39 45a576e56425
parent 38 123cc75cbe6a
child 42 565e15a60043
equal deleted inserted replaced
38:123cc75cbe6a 39:45a576e56425
       
     1 #labels 80
     1 <wiki:toc max_depth="3" />
     2 <wiki:toc max_depth="3" />
     2 
     3 
     3 == Global available Constants ==
     4 == Global available Constants ==
     4 
     5 
     5 <blockquote><tt>LAND_WIDTH</tt>, <tt>LAND_HEIGHT</tt>
     6 <blockquote><tt>LAND_WIDTH</tt>, <tt>LAND_HEIGHT</tt>
    76 </blockquote>
    77 </blockquote>
    77 Example:
    78 Example:
    78 
    79 
    79 <code lang="lua">    local gear = !AddGear(0, 0, gtTarget, 0, 0, 0, 0)
    80 <code lang="lua">    local gear = !AddGear(0, 0, gtTarget, 0, 0, 0, 0)
    80     !FindPlace(gear, true, 0, LAND_WIDTH)</code>
    81     !FindPlace(gear, true, 0, LAND_WIDTH)</code>
       
    82 
       
    83 === <tt>!AddVisualGear(x, y, viusalGearType, state, critical)</tt> ===
       
    84 
       
    85 <blockquote>This creates a new visual gear at position x,y (measured from top left) of kind visualGearType (see [visualGearTypes Visual Gear Types]).  The function returns the uid of the visual gear created.  Set critical to true if the visual gear is crucial to game play.  False if it is just an effect, and can be skipped when in fastforward (such as when joining a room).  A critical visual gear will always be created, a non-critical one may fail.  Most visual gears delete themselves. 
       
    86 </blockquote>
       
    87 Example:
       
    88 
       
    89 <code lang="lua">    vgear = !AddVisualGear(1000, 1000, vgtExplosion, 0, false) -- adds an non-critical explosion at position 1000,1000. Returns 0 if it was not created.
       
    90 </code>
       
    91 
    81 === <tt>!SpawnHealthCrate(x, y)</tt> (0.9.14) ===
    92 === <tt>!SpawnHealthCrate(x, y)</tt> (0.9.14) ===
    82 
    93 
    83 <blockquote>Spawns a health crate at the specified position.
    94 <blockquote>Spawns a health crate at the specified position.
    84 </blockquote>
    95 </blockquote>
    85 === <tt>!SpawnAmmoCrate(x, y, ammoType)</tt> (0.9.14) ===
    96 === <tt>!SpawnAmmoCrate(x, y, ammoType)</tt> (0.9.14) ===
   165 </blockquote>
   176 </blockquote>
   166 === <tt>!GetBotLevel(gearUid)</tt> (0.9.14) ===
   177 === <tt>!GetBotLevel(gearUid)</tt> (0.9.14) ===
   167 
   178 
   168 <blockquote>returns the bot level from 0 to 5. 0 means human player.
   179 <blockquote>returns the bot level from 0 to 5. 0 means human player.
   169 </blockquote>
   180 </blockquote>
       
   181 
       
   182 === <tt>!GetVisualGearValues(vgUid)</tt> ===
       
   183 
       
   184 <blockquote>This returns the typically set visual gear values, useful if manipulating things like smoke or bubbles or circles.  It returns the following values:
       
   185 X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint 
       
   186 X, Y typically position, dX, dY typically speed, Angle is usually the rotation angle, Frame is typically the animation frame, FrameTicks is usually an animation counter.  State can have a variety of values, but is typically bit packed, Timer is usually the gear lifetime and Tint is the colour.
       
   187 Most visual gears require little to no modification of parameters.
       
   188 </blockquote>
       
   189 Example:
       
   190 
       
   191 <code lang="lua">    !GetVisualGearValues(vgUid) -- return visual gear values
       
   192 </code>
       
   193 
   170 == Functions to modify gears ==
   194 == Functions to modify gears ==
       
   195 
       
   196 === <tt>!DeleteGear(gearUid)</tt> ===
       
   197 
       
   198 <blockquote>Deletes a Gear</blockquote>
       
   199 Example:
       
   200 
       
   201 <code lang="lua">    gear = !AddGear(…)
       
   202     !DeleteGear(gear) -- Delete the newly created gear.</code>
       
   203 
       
   204 === <tt>!DeleteVisualGear(vgUid)</tt> ===
       
   205 
       
   206 <blockquote>Deletes a Visual Gear.  Note, most visual gears delete themselves.</blockquote>
       
   207 Example:
       
   208 
       
   209 <code lang="lua">    vgear = !AddVisualGear(…)
       
   210     !DeleteVisualGear(vgear) -- Delete the newly created visual gear.</code>
       
   211 
       
   212 
       
   213 === <tt>!SetVisualGearValues(vgUid, X, Y, dX, dY, Angle, Frame, FrameTicks, State, Timer, Tint)</tt> ===
       
   214 
       
   215 <blockquote>This allows manipulation of many of the visual gear values.  Calling GetVisualGearValues first is recommended on most visual gears unless you are controlling all the key values.  In the case of vgtCircle, the visual gear values are mapped as follows.  X, Y: position.  State: radius. Timer: Thickness.  FrameTicks: pulsation speed (0 to disable).  dX, dY: min/max pulsation opacity (0-255). Tint: colour, RGBA.
       
   216 Most visual gears require little to no modification of parameters.
       
   217 </blockquote>
       
   218 Example:
       
   219 
       
   220 <code lang="lua">    !SetVisualGearValues(circleUid, 1000,1000, 20, 200, 0, 0, 100, 50, 3, 0xff0000ff) -- set a circle to position 1000,1000 pulsing from opacity 20 to 200 (8%-78%), radius of 50, 3px thickness, bright red.
       
   221 </code>
   171 
   222 
   172 === <tt>!FindPlace(gearUid, fall, left, right)</tt> ===
   223 === <tt>!FindPlace(gearUid, fall, left, right)</tt> ===
   173 
   224 
   174 <blockquote>Finds a place for the specified gear between x=left and x=right and places it there.
   225 <blockquote>Finds a place for the specified gear between x=left and x=right and places it there.
   175 </blockquote>
   226 </blockquote>