Main Page » LUA s3dweapon library


Contents

S3D Weapon Library

The Scorched3D weapons library is a LUA library that implements a set of Scorched3D functions that can create and manipulate weapons. All of the functions have the s3dweapon prefix i.e. use s3dweapon.functionname to call them.

s3dweapon.fire_weapon

 s3dweapon.fire_weapon(
    string weaponName,
    integer playerId,
    table position,
    table velocity) 

Fires the weapon called weaponName. This weapon needs to have been previously defined in the accessories.xml file. Example:

 s3dweapon.fire_weapon(
   "Nuke",  -- Fire a "Nuke" weapon
   playerId,  
   {x=0, y=0, z=0} -- At position 0,0,0
   {x=0, y=0, z=0} -- With no speed or direction (velocity)
   );

s3dweapon.explosion

 s3dweapon.explosion(
    integer playerId,
    table position,
    table explosionParameters) 

Creates an explosion at the given position. The explosion parameters are the same as the parameters to WeaponExplosion in the accessories.xml file. Example:

 s3dweapon.explosion(
   playerId,  
   {x=0, y=0, z=0} -- At position 0,0,0
   {
        size = 4,  -- The size of the explosion
        hurtamount = 0, -- Doesn't hurt
        deform = 2,  -- Up
        animate = false
    }
   );

s3dweapon.napalm

 s3dweapon.napalm(
    integer playerId,
    table position,
    table napalmParameters) 

Creates an napalm flow at the given position. The napalm parameters are the same as the parameters to WeaponNapalm in the accessories.xml file. Example:

 s3dweapon.napalm(
   playerId,  
   {x=0, y=0, z=0} -- At position 0,0,0
   {
      napalmtime=8.0
      napalmheight=0.2
      steptime=0.1
      hurtsteptime=2.0
      hurtpersecond=1.0
      numberstreams=1
      effectradius=5
    }
   );

s3dweapon.laser

 s3dweapon.laser(
    integer playerId,
    table position,
    table direction,
    table napalmParameters) 

Creates an laser from the given position. The laser parameters are the same as the parameters to WeaponLaser in the accessories.xml file. Example:

 s3dweapon.laser(
   playerId,  
   {x=0, y=0, z=0} -- At position 0,0,0
   {x=1, y=0, z=0} -- Pointing right
   {
      totaltime=1
      minimumdistance=10
      maximumdistance=200
      minimumhurt=34
      maximumhurt=40
      hurtradius=2
    }
   );

s3dweapon.random

 s3dweapon.random()

Returns a random number in the range 0 to 1.

Donate to Scorched3D Get it from CNET Download.com! 5 Stars