Advertisement
Guest User

Untitled

a guest
Jul 25th, 2018
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. genscript
  2.  
  3. functional script to generate tile layers
  4. completely generic, exports a generic format using indexes. either each tile as position or 2d array of entire space
  5.  
  6. values can be given as distinct values, or a random range given as `{min,max}`
  7. examples:
  8. seed 5 // distinct value
  9. seed {1,5} // random seed of 1, 2, 3, 4 or 5
  10.  
  11. [pos]
  12. generator functions can take absolute position, or cursor position. generators may change the cursor position
  13. positions are given with (x,y), a label, or "cursor"
  14. the position label "cursor" is just a special label that is set automatically by certain functions
  15. cursor begins at 0, 0
  16.  
  17. [life]
  18. "life" values are either a float (0-1) or int (1+). floats are random chance of survival, ints are absolute lifetimes in iterations
  19.  
  20. [tile]
  21. tile values can either be index (integer), or name (string), which are saved with settile
  22.  
  23. [comments]
  24. lines beginning with #, and empty lines are ignored.
  25.  
  26. [errors]
  27. if a line fails to execute for whatever reason, execution just moves to the next line and continues
  28. if 10000 commands are executed, execution stops immediately. this could be changed with a command maybe? or just in implementations
  29.  
  30.  
  31. functions:
  32.  
  33. seed [value] // set seed
  34.  
  35. randomseed // randomise seed. by default the seed is randomised
  36.  
  37. settile [name] [tile] // set "name" to value of [tile]
  38.  
  39. savepos [label] // save cursor position
  40.  
  41. loadpos [label] // set cursor to saved position
  42.  
  43. move [x] [y] // move the cursor by x and y
  44.  
  45. movelabel [label] [x] [y] // move the saved position [label] by x and y
  46.  
  47. digger [pos] [tile] [life] [turn chance] // each iteration place a tile and move in current direction, with [turn chance] of turning left or right
  48.  
  49. expand4 [tile] [outlinetile] // expand/outline given tile with [outlinetile], to each side
  50.  
  51. expand8 [tile] [outlinetile] // expand/outline given tile with [outlinetile], to each side and each diagonal
  52.  
  53. circle [pos] [tile] [size] // paint a circle at position with radius [size]
  54.  
  55. rect [pos] [tile] [width] [height] // paint a rectangle width center of position and side lengths of [width] and [height]
  56.  
  57. replace [tile] [replacement] // replace all [tile] with [replacement]
  58.  
  59. smooth [tile] [neighbors] [replacement] // replace all [tile] with [neighbors] or fewer immediate neighbors with [replacement]
  60.  
  61. noise [tile] [...replacements] // replace all [tile] with a random selection from [...replacements]
  62.  
  63. loop [amount] // repeat block until `endloop` [amount] times
  64.  
  65. endloop // used to delimit loops
  66.  
  67. execline [line] // execute a specific line
  68.  
  69. jumpline [line] [chance] // jump execution to a specific line, with a given chance. (so `jump [line] 0.9` would mean a 90% of jumping to the line)
  70.  
  71. end // end execution immediately (reaching the end of the file also ends execution)
  72.  
  73.  
  74. ----- example script -----
  75. # basic genscript for simple rooms with paths between
  76. # by jazz mickle
  77. loop {5,8}
  78. # build a room at current position
  79. rect cursor 1 {3,6} {2,5}
  80. # build a pathway to the next room
  81. digger cursor 1 {10,15} 0.1
  82. endloop
  83. # repeat the room command for the last room
  84. execline 5
  85. ---------------------------
  86.  
  87.  
  88.  
  89.  
  90. THOUGHTS
  91.  
  92. i think this provides a basis for me to expand on with new functions as i come up with ideas, and covers basic generation techniques such as Nuclear Throne's tile generation.
  93.  
  94. a lot of generation commands were ignored because they could be accomplished with other commands. these include:
  95.  
  96. square [pos] [tile] [size] // paint a square with center of position and side length of [size]. alias for `rect [pos] [tile] [size] [size]`
  97.  
  98. dot [pos] [tile] // set single tile at position. alias for `square [pos] [tile] 1`
  99.  
  100. also, setting a "thickness" for the digger is unnecessary because you can do a digger, then use expand4 or expand8
  101.  
  102. the execline command is to help with repeating code, but using line numbers is kind of terrible. maybe there should be labels?
  103.  
  104. jumpline is goto, but with a random chance haha. i think goto is fine in a script like this
  105.  
  106. end/jumpline could be used interestingly if you use random values for the line to jump to. past the `end` you could have another set of jumplines to select from, meaning jumping to a random section of code, but with some good control. almost like executing random functions.
  107.  
  108. custom functions might be a good idea. possibly separate files with a new symbol to represent arguments (such as $1, $2, ...). for instance:
  109.  
  110. # thickdigger [pos] [tile] [life] [turn chance] [thickness]
  111. digger $1 $2 $3 $4
  112. loop $5
  113. expand4 $2 $2
  114. endloop
  115. end
  116.  
  117. or
  118.  
  119. # dot [pos] [tile]
  120. rect $1 $2 1 1
  121. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement