Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/planetLevelHS15/data/levels/luaTest.oxw @ 10811

Last change on this file since 10811 was 10811, checked in by luhug, 8 years ago

added luaTest.oxw to test random city generation

File size: 2.1 KB
Line 
1<LevelInfo
2 name = "Lua Test"
3 description = "A level with absolutely nothing in it."
4 tags = "test"
5 screenshot = "emptylevel.png"
6/>
7
8<?lua
9  include("stats.oxo")
10  include("HUDTemplates3.oxo")
11  include("templates/lodInformation.oxt")
12?>
13
14<?lua
15  include("templates/spaceshipAssff2.oxt")
16  include("templates/spaceshipPirate.oxt")
17  include("templates/spaceshipEscort.oxt")
18  include("templates/spaceshipRing.oxt")
19  include("templates/spaceshipSwallow.oxt")
20?>
21
22<!-- randomly generate houses -->
23<?lua
24  function randomHouses(x,y,cellSize)
25    returnString = ""
26    for currentX = 1, x, 1 do
27      for currentY = 1, y, 1 do
28        houseNr = math.floor(math.random()*4 + 1)
29        orientation = math.floor(math.random()*4)
30        if houseNr == 1 then
31          houseString = "PrimeTower"
32          houseHeight = 0
33        elseif houseNr == 2 then
34          houseString = "Glasstower1"
35          houseHeight = 0
36        elseif houseNr == 3 then
37          houseString = "ETH"
38          houseHeight = 0
39        elseif houseNr == 4 then
40          houseString = "Hausc1"
41          houseHeight = 0
42        elseif houseNr == 5 then
43          houseString = "haus5"
44          houseHeight = 0
45        elseif houseNr == 6 then
46          houseString = "haus1"
47          houseHeight = 0
48        end
49       
50        returnString = returnString .. "<StaticEntity position=\"" .. (currentX - (cellSize/2)) .. "," .. (currentX - (cellSize/2)) .. "," .. (houseHeight/2) .. "\" direction=\"0,0,1\" pitch=\"0\" roll=\"0\" yaw=\"" .. (orientation*90) .. "\"> <attached> <Model position=\"0,0,0\" mesh=\"" .. houseString .. ".mesh\" scale3D=\"100\"/></attached></StaticEntity>\n\n"
51      end
52    end
53    return returnString
54  end
55
56?>
57
58<Level>
59  <templates>
60    <Template link=lodtemplate_default />
61  </templates>
62  <?lua include("includes/notifications.oxi") ?>
63
64  <Scene
65    ambientlight = "0.8, 0.8, 0.8"
66    skybox       = "Orxonox/Starbox"
67  >
68
69    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
70    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
71
72    <?lua print(randomHouses(5,5,500)) ?>
73   
74  </Scene>
75</Level>
76
Note: See TracBrowser for help on using the repository browser.