Difference between revisions of "Levelgen example: SquarePegs"
Watusimoto (Talk | contribs) |
Watusimoto (Talk | contribs) |
||
Line 67: | Line 67: | ||
<h2>Levelgen code</h2> | <h2>Levelgen code</h2> | ||
+ | Save the following code in a file called "sorc.levelgen" in your levels folder. | ||
<source lang="lua"> | <source lang="lua"> |
Latest revision as of 00:36, 29 October 2010
See other examples in the Levelgen gallery.
The following is an awesome level by Karamazovapy. Save the level in a file called "squarepegs.level" in your levels folder, and save the levelgen code below in a file called "sorc.levelgen" in that same folder.
Each time you play this level, it will be different!
Level Code
Save the following in a file called "squarepegs.level" in your levels folder.
Invalid language.
You need to specify a language like this: <source lang="html4strict">...</source>
Supported languages for syntax highlighting:
4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic
CTFGameType 10 5 LevelName Square Pegs & Round Holes LevelDescription LevelCredits Script sorc.levelgen GridSize 255 MinPlayers 0 MaxPlayers 0 Team Blue 0 0 1 Team Red 1 0 0 BarrierMaker 50 3 3 3 -3 BarrierMaker 50 1 4.1 1 4 2 4 BarrierMaker 50 -2 4 -1 4 -1 4.1 BarrierMaker 50 2 -4 1 -4 1 -4.1 BarrierMaker 50 -3 -3 -3 3 BarrierMaker 50 -1 -4.1 -1 -4 -2 -4 BarrierMaker 50 -0.4 4 -0.2 4 BarrierMaker 50 -0.4 -4 -0.2 -4 BarrierMaker 50 0.2 4 0.4 4 BarrierMaker 50 0.2 -4 0.4 -4 LoadoutZone 1 -0.4 -4.2 0.4 -4.2 0.4 -4.09804 -0.4 -4.1 LoadoutZone 0 -0.4 4.1 0.4 4.1 0.4 4.2 -0.4 4.2 Teleporter 2 -3 0 0 Teleporter -2 3 0 0 ForceFieldProjector -1 0.4 4 1 ForceFieldProjector -1 0.4 -4 1 ForceFieldProjector -1 -0.4 4 1 FlagItem 0 0 4.4 Spawn 1 -1 -3.5 RepairItem 0 0 20 FlagItem 1 0 -4.4 ForceFieldProjector -1 -0.4 -4 1 Spawn 0 2 3.5 AsteroidSpawn -2 2 60 AsteroidSpawn 2 -2 60 Asteroid 2 -2 Asteroid -2 2 Spawn 0 1 3.5 Spawn 0 0 3.5 Spawn 0 -1 3.5 Spawn 0 -2 3.5 Spawn 1 -2 -3.5 Spawn 1 0 -3.5 Spawn 1 1 -3.5 Spawn 1 2 -3.5 Spawn 1 0 -2 Spawn 0 0 2 Spawn 0 0.2 2 Spawn 0 -0.2 2 Spawn 1 0.2 -2 Spawn 1 -0.2 -2 Spawn 0 1 1 Spawn 1 -1 -1
Levelgen code
Save the following code in a file called "sorc.levelgen" in your levels folder.
--BaseDefense toggles between a solid block and turret or a broken barrier in front of the flags local BaseDefense = math.random(2) if(BaseDefense == 2) then levelgen:addLevelLine("BarrierMaker 50 -0.3 4 0.3 4 ") levelgen:addLevelLine("BarrierMaker 50 -0.3 -4 0.3 -4 ") levelgen:addLevelLine("Turret -1 0 -3.90196 1") levelgen:addLevelLine("Turret -1 0 3.90196 1") else levelgen:addLevelLine("BarrierMaker 1 -0.1 -3.9 -0.1 -3.9 ") levelgen:addLevelLine("BarrierMaker 1 0 -3.9 0 -3.9 ") levelgen:addLevelLine("BarrierMaker 1 0.1 -3.9 0.1 -3.9 ") levelgen:addLevelLine("BarrierMaker 1 -0.1 3.90196 -0.1 3.9 ") levelgen:addLevelLine("BarrierMaker 1 0 3.90196 0 3.90196 ") levelgen:addLevelLine("BarrierMaker 1 0.1 3.90196 0.1 3.9 ") end --CircleDraw and SquareDraw are functions that lead down the curved or angular paths for level creation. The first-level code handles the flag areas, center features, and corners. Further tests (ex. LgCirA, SmSqC) determine the presence of the smaller circles or squares. function CircleDraw() levelgen:addLevelLine("BarrierMaker 50 -3 -2.9 -3 -3 -2.96593 -3.25882 -2.86603 -3.5 -2.70711 -3.70711 -2.5 -3.86603 -2.25882 -3.96593 -2 -4 -1.9 -4 ") levelgen:addLevelLine("BarrierMaker 50 3 2.9 3 3 2.96593 3.25882 2.86603 3.5 2.70711 3.70711 2.5 3.86603 2.25882 3.96593 2 4 1.9 4 ") levelgen:addLevelLine("BarrierMaker 50 -1.9 4 -2 4 -2.25882 3.96593 -2.5 3.86603 -2.70711 3.70711 -2.86603 3.5 -2.96593 3.25882 -3 3 -3 2.9 ") levelgen:addLevelLine("BarrierMaker 50 1.9 -4 2 -4 2.25882 -3.96593 2.5 -3.86603 2.70711 -3.70711 2.86603 -3.5 2.96593 -3.25882 3 -3 3 -2.9 ") levelgen:addLevelLine("BarrierMaker 50 1 4 0.965926 4.25882 0.866025 4.5 0.707107 4.70711 0.5 4.86602 0.258819 4.96593 0 5 -0.258819 4.96593 -0.5 4.86602 -0.707107 4.70711 -0.866025 4.5 -0.965926 4.25882 -1 4 ") levelgen:addLevelLine("BarrierMaker 50 -1 -4 -0.965926 -4.25882 -0.866025 -4.5 -0.707107 -4.70711 -0.5 - 4.86602 -0.258819 -4.96593 0 -5 0.258819 -4.96593 0.5 -4.86602 0.707107 -4.70711 0.866025 -4.5 0.965926 -4.25882 1 -4 ") levelgen:addLevelLine("BarrierMaker 50 0.519615 0.3 0.424264 0.424264 0.3 0.519615 0.155291 0.579556 0.1 0.6 -0.1 0.6 -0.155291 0.579556 -0.3 0.519615 -0.424264 0.424264 -0.519615 0.3 ") levelgen:addLevelLine("BarrierMaker 50 2.4 0 2.37956 0.155291 2.31962 0.3 2.22426 0.424264 2.1 0.519615 1.95529 0.579556 1.8 0.6 1.64471 0.579556 1.5 0.519615 1.37574 0.424264 1.28039 0.3 1.22044 0.155291 1.2 0 1.22044 -0.155291 1.28039 -0.3 1.37574 -0.424264 1.5 -0.519615 1.64471 -0.579556 1.8 -0.6 1.95529 -0.579556 2.1 -0.519615 2.22426 -0.424264 2.31962 -0.3 2.37956 -0.155291 2.4 0 ") levelgen:addLevelLine("BarrierMaker 50 -1.2 0 -1.22044 0.155291 -1.28039 0.3 -1.37574 0.424264 -1.5 0.519615 -1.64471 0.579556 -1.8 0.6 -1.95529 0.579556 -2.1 0.519615 -2.22426 0.424264 -2.31961 0.3 -2.37956 0.155291 -2.4 0 -2.37956 -0.155291 -2.31961 -0.3 -2.22426 -0.424264 -2.1 -0.519615 -1.95529 -0.579556 -1.8 -0.6 -1.64471 - 0.579556 -1.5 -0.519615 -1.37574 -0.424264 -1.28039 -0.3 -1.22044 -0.155291 -1.2 0 ") levelgen:addLevelLine("BarrierMaker 50 -0.519615 -0.3 -0.424264 -0.424264 -0.3 -0.519615 -0.155291 -0.579556 -0.1 -0.6 0.1 -0.6 0.155291 -0.579556 0.3 -0.519615 0.424264 -0.424264 0.519615 -0.3 ") levelgen:addLevelLine("SpeedZone -1.6 -3.8 -2 -3.8 1750 SnapEnabled") levelgen:addLevelLine("SpeedZone 1.6 3.8 2 3.8 1750 SnapEnabled") levelgen:addLevelLine("SpeedZone 2.8 0.2 2.8 -0.2 1500 SnapEnabled") levelgen:addLevelLine("SpeedZone -2.8 -0.2 -2.8 0.2 1500 SnapEnabled") levelgen:addLevelLine("Turret -1 0 -0.698039 1") levelgen:addLevelLine("Turret -1 0 0.698039 1") local LgCirA = math.random(4) if(LgCirA == 4) then else levelgen:addLevelLine("BarrierMaker 50 -1.15981 1.55 -1.11213 1.48787 -1.05 1.44019 -0.977646 1.41022 -0.9 1.4 -0.822354 1.41022 -0.75 1.44019 -0.687868 1.48787 -0.640192 1.55 -0.610222 1.62235 -0.6 1.7 -0.610222 1.77765 -0.640192 1.85 -0.687868 1.91213 -0.75 1.95981 -0.822354 1.98978 -0.9 2 -0.977646 1.98978 -1.05 1.95981 -1.11213 1.91213 -1.15981 1.85 -1.18978 1.77765 -1.2 1.7 -1.18978 1.62235 -1.15981 1.55 ") levelgen:addLevelLine("BarrierMaker 50 0.840192 -1.85 0.887868 -1.91213 0.95 -1.95981 1.02235 - 1.98978 1.1 -2 1.17765 -1.98978 1.25 -1.95981 1.31213 -1.91213 1.35981 -1.85 1.38978 -1.77765 1.4 -1.7 1.38978 -1.62235 1.35981 -1.55 1.31213 -1.48787 1.25 -1.44019 1.17765 -1.41022 1.1 -1.4 1.02235 -1.41022 0.95 -1.44019 0.887868 -1.48787 0.840192 -1.55 0.810222 -1.62235 0.8 -1.7 0.810222 -1.77765 0.840192 -1.85 ") end local LgCirB = math.random(4) if(LgCirB == 4) then else levelgen:addLevelLine("BarrierMaker 45 0.640192 1.55 0.687868 1.48787 0.75 1.44019 0.822354 1.41022 0.9 1.4 0.977646 1.41022 1.05 1.44019 1.11213 1.48787 1.15981 1.55 1.18978 1.62235 1.2 1.7 1.18978 1.77765 1.15981 1.85 1.11213 1.91213 1.05 1.95981 0.977646 1.98978 0.9 2 0.822354 1.98978 0.75 1.95981 0.687868 1.91213 0.640192 1.85 0.610222 1.77765 0.6 1.7 0.610222 1.62235 0.640192 1.55 ") levelgen:addLevelLine("BarrierMaker 45 -1.15981 -1.85 -1.11213 -1.91213 -1.05 -1.95981 -0.977646 - 1.98978 -0.9 -2 -0.822354 -1.98978 -0.75 -1.95981 -0.687868 -1.91213 -0.640192 -1.85 -0.610222 -1.77765 -0.6 -1.7 -0.610222 -1.62235 -0.640192 -1.55 -0.687868 -1.48787 -0.75 -1.44019 -0.822354 -1.41022 -0.9 -1.4 -0.977646 - 1.41022 -1.05 -1.44019 -1.11213 -1.48787 -1.15981 -1.55 -1.18978 -1.62235 -1.2 -1.7 -1.18978 -1.77765 -1.15981 - 1.85 ") end local SmCirA = math.random(4) if(SmCirA == 4) then else levelgen:addLevelLine("BarrierMaker 20 0.9134 -3.05 0.92929 -3.07071 0.95 -3.0866 0.97412 -3.09659 1 -3.1 1.02588 -3.09659 1.05 -3.0866 1.07071 -3.07071 1.0866 -3.05 1.09659 -3.02588 1.1 -3 1.09659 -2.97412 1.0866 -2.95 1.07071 -2.92929 1.05 -2.9134 1.02588 -2.90341 1 -2.9 0.97412 -2.90341 0.95 -2.9134 0.92929 -2.92929 0.9134 -2.95 0.90341 -2.97412 0.9 -3 0.90341 -3.02588 0.9134 -3.05 ") levelgen:addLevelLine("BarrierMaker 20 -1.0866 2.95 -1.07071 2.92929 -1.05 2.9134 -1.02588 2.90341 -1 2.9 -0.97412 2.90341 -0.95 2.9134 -0.92929 2.92929 -0.9134 2.95 -0.90341 2.97412 -0.9 3 -0.90341 3.02588 - 0.9134 3.05 -0.92929 3.07071 -0.95 3.0866 -0.97412 3.09659 -1 3.1 -1.02588 3.09659 -1.05 3.0866 -1.07071 3.07071 -1.0866 3.05 -1.09659 3.02588 -1.1 3 -1.09659 2.97412 -1.0866 2.95 ") end local SmCirB = math.random(4) if(SmCirB == 4) then else levelgen:addLevelLine("BarrierMaker 20 -0.0865998 -3.05 -0.0707102 -3.07071 -0.0500002 -3.0866 - 0.0258799 -3.09659 0 -3.1 0.0258799 -3.09659 0.0500002 -3.0866 0.0707102 -3.07071 0.0865998 -3.05 0.09659 -3.02588 0.0999999 -3 0.09659 -2.97412 0.0865998 -2.95 0.0707102 -2.92929 0.0500002 -2.9134 0.0258799 -2.90341 0 -2.9 - 0.0258799 -2.90341 -0.0500002 -2.9134 -0.0707102 -2.92929 -0.0865998 -2.95 -0.09659 -2.97412 -0.0999999 -3 - 0.09659 -3.02588 -0.0865998 -3.05 ") levelgen:addLevelLine("BarrierMaker 20 -0.0866025 2.95 -0.0707107 2.92929 -0.05 2.9134 -0.0258819 2.90341 0 2.9 0.0258819 2.90341 0.05 2.9134 0.0707107 2.92929 0.0866025 2.95 0.0965926 2.97412 0.1 3 0.0965926 3.02588 0.0866025 3.05 0.0707107 3.07071 0.05 3.0866 0.0258819 3.09659 0 3.1 -0.0258819 3.09659 -0.05 3.0866 - 0.0707107 3.07071 -0.0866025 3.05 -0.0965926 3.02588 -0.1 3 -0.0965926 2.97412 -0.0866025 2.95 ") end local SmCirC = math.random(4) if(SmCirC == 4) then else levelgen:addLevelLine("BarrierMaker 20 0.9134 2.95 0.92929 2.92929 0.95 2.9134 0.97412 2.90341 1 2.9 1.02588 2.90341 1.05 2.9134 1.07071 2.92929 1.0866 2.95 1.09659 2.97412 1.1 3 1.09659 3.02588 1.0866 3.05 1.07071 3.07071 1.05 3.0866 1.02588 3.09659 1 3.1 0.97412 3.09659 0.95 3.0866 0.92929 3.07071 0.9134 3.05 0.90341 3.02588 0.9 3 0.90341 2.97412 0.9134 2.95 ") levelgen:addLevelLine("BarrierMaker 20 -1.0866 -3.05 -1.07071 -3.07071 -1.05 -3.0866 -1.02588 - 3.09659 -1 -3.1 -0.97412 -3.09659 -0.95 -3.0866 -0.92929 -3.07071 -0.9134 -3.05 -0.90341 -3.02588 -0.9 -3 - 0.90341 -2.97412 -0.9134 -2.95 -0.92929 -2.92929 -0.95 -2.9134 -0.97412 -2.90341 -1 -2.9 -1.02588 -2.90341 -1.05 -2.9134 -1.07071 -2.92929 -1.0866 -2.95 -1.09659 -2.97412 -1.1 -3 -1.09659 -3.02588 -1.0866 -3.05 ") end local SmCirD = math.random(4) if(SmCirD == 4) then else levelgen:addLevelLine("BarrierMaker 20 1.9134 2.95 1.92929 2.92929 1.95 2.9134 1.97412 2.90341 2 2.9 2.02588 2.90341 2.05 2.9134 2.07071 2.92929 2.0866 2.95 2.09659 2.97412 2.1 3 2.09659 3.02588 2.0866 3.05 2.07071 3.07071 2.05 3.0866 2.02588 3.09659 2 3.1 1.97412 3.09659 1.95 3.0866 1.92929 3.07071 1.9134 3.05 1.90341 3.02588 1.9 3 1.90341 2.97412 1.9134 2.95 ") levelgen:addLevelLine("BarrierMaker 20 -2.0866 -3.05 -2.07071 -3.07071 -2.05 -3.0866 -2.02588 - 3.09659 -2 -3.1 -1.97412 -3.09659 -1.95 -3.0866 -1.92929 -3.07071 -1.9134 -3.05 -1.90341 -3.02588 -1.9 -3 - 1.90341 -2.97412 -1.9134 -2.95 -1.92929 -2.92929 -1.95 -2.9134 -1.97412 -2.90341 -2 -2.9 -2.02588 -2.90341 -2.05 -2.9134 -2.07071 -2.92929 -2.0866 -2.95 -2.09659 -2.97412 -2.1 -3 -2.09659 -3.02588 -2.0866 -3.05 ") end end function SquareDraw() levelgen:addLevelLine("BarrierMaker 50 -1.9 -4 -3 -4 -3 -2.9 ") levelgen:addLevelLine("BarrierMaker 50 1.9 4 3 4 3 2.9") levelgen:addLevelLine("BarrierMaker 50 -3 2.9 -3 4 -1.9 4 ") levelgen:addLevelLine("BarrierMaker 50 3 -2.9 3 -4 1.9 -4 ") levelgen:addLevelLine("BarrierMaker 50 -1 4 -1 5 1 5 1 4 ") levelgen:addLevelLine("BarrierMaker 50 -1 -4 -1 -5 1 -5 1 -4 ") levelgen:addLevelLine("BarrierMaker 355 0 0.7 0 -0.7") levelgen:addLevelLine("BarrierMaker 355 -2.4 -0.7 -2.4 0.7 ") levelgen:addLevelLine("BarrierMaker 355 2.4 -0.7 2.4 0.7 ") levelgen:addLevelLine("ForceFieldProjector -1 0.698039 0 1") levelgen:addLevelLine("ForceFieldProjector -1 -0.698039 0 1") levelgen:addLevelLine("Teleporter 2.6 1 -2.6 -3 ") levelgen:addLevelLine("Teleporter -2.6 -1 2.6 3 ") local LgSqA = math.random(4) if(LgSqA == 4) then else levelgen:addLevelLine("BarrierMaker 155 0.9 1.4 0.9 2 ") levelgen:addLevelLine("BarrierMaker 155 -0.9 -2 -0.9 -1.4 ") end local LgSqB = math.random(4) if(LgSqB == 4) then else levelgen:addLevelLine("BarrierMaker 155 -0.9 1.4 -0.9 2 ") levelgen:addLevelLine("BarrierMaker 155 0.9 -2 0.9 -1.4 ") end local SmSqA = math.random(4) if(SmSqA == 4) then else levelgen:addLevelLine("BarrierMaker 105 -1 2.8 -1 3.2 ") levelgen:addLevelLine("BarrierMaker 105 1 -3.2 1 -2.8 ") end local SmSqB = math.random(4) if(SmSqB == 4) then else levelgen:addLevelLine("BarrierMaker 105 0 -3.2 0 -2.8 ") levelgen:addLevelLine("BarrierMaker 105 0 2.8 0 3.2 ") end local SmSqC = math.random(4) if(SmSqC == 4) then else levelgen:addLevelLine("BarrierMaker 105 1 2.8 1 3.2 ") levelgen:addLevelLine("BarrierMaker 105 -1 -3.2 -1 -2.8 ") end local SmSqD = math.random(4) if(SmSqD == 4) then else levelgen:addLevelLine("BarrierMaker 105 2 2.8 2 3.2 ") levelgen:addLevelLine("BarrierMaker 105 -2 -3.2 -2 -2.8 ") end end --This is the test that determines Square Pegs or Round Holes. Executes one of the above functions. local Shape = math.random(2) if(Shape == 2) then CircleDraw() else SquareDraw() end