Difference between revisions of "Programming levelgens"
Watusimoto (Talk | contribs) (New page: Creating levelgen scripts is very straightforward. T '''addWall()''' - Adds a wall to the game<br> '''addItem()''' - Adds a non-wall item to the game<br> '''addLevelLine()''' - Feeds a ...) |
Watusimoto (Talk | contribs) |
||
Line 1: | Line 1: | ||
− | Creating levelgen scripts is very straightforward. | + | Creating levelgen scripts is very straightforward. The methodology basically follows that used in the level definition files. If you are familiar with that format, you will find understanding the levelgen methods very easy. The easiest way to learn how level files are structured is to create a sample level in the editor, and examine it in a text editor. Don't worry, it's not complicated! |
− | ''' | + | '''addItem( <args> )''' - Adds an item to the game<br> |
− | + | Takes a variable number of arguments, and follows the same argument order as that used in level files. | |
− | + | ||
− | + | ||
− | + | For example: | |
− | For example: | + | |
<source lang="lua"> | <source lang="lua"> | ||
+ | -- Create a 10 x 10 block of RepairItems | ||
for i = 0, 10 do | for i = 0, 10 do | ||
for j = 0, 10 do | for j = 0, 10 do | ||
− | levelgen:addItem("RepairItem",1 + i * .2, 1 + j * .2); | + | levelgen:addItem("RepairItem", 1 + i * .2, 1 + j * .2); |
end | end | ||
end | end | ||
+ | </source> | ||
+ | |||
+ | |||
+ | '''addWall( wallsize, issolid, points )''' - Adds a wall to the game. The wallsize param is the thickness of the wall, in the same units as used in the editor (the standard wall has a thickness of 50). The issolid parameter is not yet fully supported, so use "false" for this value for now. Finally, points is a Lua table containing 2 or more Points. | ||
+ | |||
+ | For example: | ||
+ | <source lang="lua"> | ||
+ | -- Create a U-shaped segment of wall. To create a closed loop, | ||
+ | -- repeat the first point at the end of the list. | ||
+ | levelgen:addWall(50, false, { Point(1,1), Point(1,5), Point(5,5), Point(5,1) } ) | ||
+ | </source> | ||
+ | |||
+ | |||
+ | '''addLevelLine( line )''' - Feeds a raw level line to the level processor. You can use any line from a level definition file as an argument. | ||
+ | <source lang="lua"> | ||
+ | -- Some raw lines | ||
+ | levelgen:addLevelLine("LoadoutZone 0 4.8 4.2 7.1 3.9 7.2 4.8 4.8 4.5") | ||
+ | levelgen:addLevelLine("BarrierMaker 50 5.5 3 5.5 3.5") | ||
+ | </source> | ||
+ | |||
+ | |||
+ | '''getGridSize()''' - Returns the current level's gridsize<br> | ||
+ | <source lang="lua"> | ||
+ | -- Create a 1x1 square of wall that is as thick as it is long | ||
+ | levelgen:addWall(levelgen:getGridSize() * 1, false, { Point(0,0), Point(1,0) } ) | ||
</source> | </source> |
Revision as of 05:47, 22 September 2009
Creating levelgen scripts is very straightforward. The methodology basically follows that used in the level definition files. If you are familiar with that format, you will find understanding the levelgen methods very easy. The easiest way to learn how level files are structured is to create a sample level in the editor, and examine it in a text editor. Don't worry, it's not complicated!
addItem( <args> ) - Adds an item to the game
Takes a variable number of arguments, and follows the same argument order as that used in level files.
For example:
-- Create a 10 x 10 block of RepairItems for i = 0, 10 do for j = 0, 10 do levelgen:addItem("RepairItem", 1 + i * .2, 1 + j * .2); end end
addWall( wallsize, issolid, points ) - Adds a wall to the game. The wallsize param is the thickness of the wall, in the same units as used in the editor (the standard wall has a thickness of 50). The issolid parameter is not yet fully supported, so use "false" for this value for now. Finally, points is a Lua table containing 2 or more Points.
For example:
-- Create a U-shaped segment of wall. To create a closed loop, -- repeat the first point at the end of the list. levelgen:addWall(50, false, { Point(1,1), Point(1,5), Point(5,5), Point(5,1) } )
addLevelLine( line ) - Feeds a raw level line to the level processor. You can use any line from a level definition file as an argument.
-- Some raw lines levelgen:addLevelLine("LoadoutZone 0 4.8 4.2 7.1 3.9 7.2 4.8 4.8 4.5") levelgen:addLevelLine("BarrierMaker 50 5.5 3 5.5 3.5")
getGridSize() - Returns the current level's gridsize
-- Create a 1x1 square of wall that is as thick as it is long levelgen:addWall(levelgen:getGridSize() * 1, false, { Point(0,0), Point(1,0) } )