Changeset 5307 for data/contentcreation/pps/MirkoKaiser/CuboidSS/Version2/levels/CuboidSpaceStation2.lua
- Timestamp:
- Dec 4, 2008, 10:49:52 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
data/contentcreation/pps/MirkoKaiser/CuboidSS/Version2/levels/CuboidSpaceStation2.lua
r5300 r5307 1 1 <?lua 2 3 4 2 5 -- This lua script creates a totally random generated space station for the orxonox computer game! 3 6 7 8 9 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 4 10 -- This prints xml code, which creates a MovableEntity, which I need to attach all the parts of the space station, if you want to move, rotate or displace the whole space station, this is the line you have to change. 5 11 print("<MovableEntity scale=1 position=\"0,0,-5000\" velocity=\"0,0,0\" rotationaxis=\"0,0,1\" rotationrate=0 yaw=180 >") 6 7 8 12 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 13 14 15 16 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 9 17 -- Create a randomseed, so that the math.random() function is actually random. 10 18 math.randomseed(os.time()) 11 19 -- End create randomseed. 12 13 14 20 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 21 22 23 24 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 15 25 -- Here you can define some global variables, with which you can modify the space station. 16 26 -- Define the maximal size of the space station, this is actually just for the grid, be sure that this value is big enough. 17 27 sSSize=30 18 28 -- Define how many parts the space station has, this value has to be exact, so be sure to increment it if you're adding a new part. 19 sSParts= 729 sSParts=8 20 30 -- Define how many body parts the space station has, this value has to be exact. Body part means a part, which has connections at least in two directions. 21 31 sSBodyParts=3 … … 29 39 rightSidePartsIndex={} 30 40 -- Define how many top parts you have. 31 topParts= 141 topParts=2 32 42 -- Define which index your top parts have. 33 43 topPartsIndex={} … … 51 61 gridDim=2.25 52 62 -- End define global parameters. 53 54 55 63 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 64 65 66 67 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 56 68 -- This creates a 4-dimensional grid, which tells us if there is a part or not, and in which direction it has connections. 57 69 -- The parameters x,y,z are the axis of the space station, which iterate to sSSize, the maximal size of the space station. … … 75 87 end 76 88 -- End create 4-dim grid. 77 78 79 89 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 90 91 92 93 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 80 94 -- This creates an array which stores all the bodyparts, it's size is depending on the global values pDim and sSParts. 81 95 -- The first parameter i, tells us how many parts fit into the array, so it iterates from 1 to sSParts, each part has his own value i. … … 234 248 bodyParts[topPartsIndex[1]][1][0][3][0]=1 235 249 bodyParts[topPartsIndex[1]][-1][0][3][0]=1 250 251 topPartsIndex[2]=8 252 bodyParts[topPartsIndex[2]][0][0][0][4]="SatelliteDish.mesh" 253 bodyParts[topPartsIndex[2]][0][0][0][5]="pitch=-90" 254 bodyParts[topPartsIndex[2]][0][0][0][0]=1 255 bodyParts[topPartsIndex[2]][0][0][1][0]=1 256 bodyParts[topPartsIndex[2]][0][0][-1][0]=1 257 bodyParts[topPartsIndex[2]][1][0][0][0]=1 258 bodyParts[topPartsIndex[2]][1][0][1][0]=1 259 bodyParts[topPartsIndex[2]][1][0][-1][0]=1 260 bodyParts[topPartsIndex[2]][-1][0][0][0]=1 261 bodyParts[topPartsIndex[2]][-1][0][1][0]=1 262 bodyParts[topPartsIndex[2]][-1][0][-1][0]=1 263 236 264 -- End insert the top parts. 237 265 … … 242 270 243 271 -- End create array bodyParts. 244 272 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 273 274 275 276 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 245 277 -- Here I define some functions which I will use later. 246 278 --This function actualizes the grid, which I have to call always after I have added a new part to the space station. … … 277 309 -- End checkPart function. 278 310 -- End define functions. 279 311 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 312 313 314 315 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 280 316 -- This is xml code, which means now we attach some parts to the MovableEntity. 281 317 print("<attached>") 282 283 284 318 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 319 320 321 322 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 285 323 -- Attach all bodyparts. 286 324 -- Define at which position in the x-direction you're space station will start. … … 322 360 end 323 361 -- End attach all bodyparts. 324 325 326 362 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 363 364 365 366 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 327 367 -- Attach thrusters, if there are some. 328 368 if thrusterIndex ~= false then … … 348 388 end 349 389 -- End attach Thrusters. 350 351 352 390 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 391 392 393 394 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 353 395 -- Attach cockpit, if there is one. 354 396 function setCockpit() … … 398 440 end 399 441 -- End attach cockpit. 400 401 402 442 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 443 444 445 446 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 403 447 -- Attach parts on the left side of the space station. 404 448 function setLeftSidePart() … … 451 495 end 452 496 -- End attach left side parts. 453 454 455 497 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 498 499 500 501 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 456 502 -- Attach parts on the right side of the space station. 457 503 function setRightSidePart() … … 504 550 end 505 551 -- End attach right side parts. 506 507 508 552 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 553 554 555 556 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 509 557 -- Attach parts on top of the space station. 510 558 function setTopPart() … … 526 574 if topPartsIndex[0] ~= false then 527 575 for sPC=1,topParts do 528 tempTopPartsIndex = topPartsIndex[ math.random(1,topParts)]576 tempTopPartsIndex = topPartsIndex[sPC] 529 577 partSet=0 530 578 y=math.floor(sSSize/2) … … 557 605 end 558 606 -- End attach top parts. 559 560 561 607 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 608 609 610 611 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 562 612 -- Attach all connectionparts. 563 613 -- This iterates through the whole grid array. … … 584 634 end 585 635 -- End attach all connectionparts. 586 587 588 636 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 637 638 639 640 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 589 641 -- This is xml code, which ends the attachment and the MovableEntity. 590 642 print("</attached>") 591 643 print("</MovableEntity>") 644 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 645 646 592 647 593 648 ?>
Note: See TracChangeset
for help on using the changeset viewer.