Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 2 and Version 3 of code/Scripting


Ignore:
Timestamp:
Apr 10, 2008, 4:33:42 PM (16 years ago)
Author:
bknecht
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/Scripting

    v2 v3  
    1212If your using the special lua tags ''<?lua'' and ''?>'' you can create levels easier. You could use loops to generate more objects and you can let a level depend on earlier accomplishments of the player. If you use random parameters you can even create a level which looks slightly different every time a player plays it. Here some examples how you could use Lua in our level files.
    1313
    14 === Asteroid field ===
     14=== Example: Asteroid field ===
    1515As I write this wiki page we have a level with 226 asteroids in it. For each asteroid we need one line of XML code:
    1616{{{
     
    2424With the scripting engine we could generate those asteroids a lot easier:
    2525{{{
    26 ... (has to be tested first)
     26<?lua
     27for i = 1, 226, 1
     28do ?>
     29<Model position="<?lua print(math.random(-19597, 18732))?>,
     30 <?lua print(math.random(-19597, 18732)) ?>,
     31 <?lua print(math.random(-19597, 18732)) ?>" scale="<?lua print(math.random( 20, 119)) ?>"
     32 mesh="ast<?lua print(i%6 + 1) ?>.mesh" rotationAxis="<?lua print(math.random()) ?>,
     33 <?lua print(math.random()) ?>, <?lua print(math.random()) ?>
     34 " rotationRate="<?lua print(math.random(16, 44)) ?>" />
     35<?lua
     36end
     37?>
    2738}}}
     39This will randomly arrange asteroids of different look and rotation axis and speed in an area. In fact you can code any Lua you want according to the [http://www.lua.org/manual/5.1/manual.htm Lua-Manual]. To actually add something to the XML-output you can use the ''print'' function. The above example shows you best how this works.