Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- genscript
- functional script to generate tile layers
- completely generic, exports a generic format using indexes. either each tile as position or 2d array of entire space
- values can be given as distinct values, or a random range given as `{min,max}`
- examples:
- seed 5 // distinct value
- seed {1,5} // random seed of 1, 2, 3, 4 or 5
- [pos]
- generator functions can take absolute position, or cursor position. generators may change the cursor position
- positions are given with (x,y), a label, or "cursor"
- the position label "cursor" is just a special label that is set automatically by certain functions
- cursor begins at 0, 0
- [life]
- "life" values are either a float (0-1) or int (1+). floats are random chance of survival, ints are absolute lifetimes in iterations
- [tile]
- tile values can either be index (integer), or name (string), which are saved with settile
- [comments]
- lines beginning with #, and empty lines are ignored.
- [errors]
- if a line fails to execute for whatever reason, execution just moves to the next line and continues
- if 10000 commands are executed, execution stops immediately. this could be changed with a command maybe? or just in implementations
- functions:
- seed [value] // set seed
- randomseed // randomise seed. by default the seed is randomised
- settile [name] [tile] // set "name" to value of [tile]
- savepos [label] // save cursor position
- loadpos [label] // set cursor to saved position
- move [x] [y] // move the cursor by x and y
- movelabel [label] [x] [y] // move the saved position [label] by x and y
- digger [pos] [tile] [life] [turn chance] // each iteration place a tile and move in current direction, with [turn chance] of turning left or right
- expand4 [tile] [outlinetile] // expand/outline given tile with [outlinetile], to each side
- expand8 [tile] [outlinetile] // expand/outline given tile with [outlinetile], to each side and each diagonal
- circle [pos] [tile] [size] // paint a circle at position with radius [size]
- rect [pos] [tile] [width] [height] // paint a rectangle width center of position and side lengths of [width] and [height]
- replace [tile] [replacement] // replace all [tile] with [replacement]
- smooth [tile] [neighbors] [replacement] // replace all [tile] with [neighbors] or fewer immediate neighbors with [replacement]
- noise [tile] [...replacements] // replace all [tile] with a random selection from [...replacements]
- loop [amount] // repeat block until `endloop` [amount] times
- endloop // used to delimit loops
- execline [line] // execute a specific line
- 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)
- end // end execution immediately (reaching the end of the file also ends execution)
- ----- example script -----
- # basic genscript for simple rooms with paths between
- # by jazz mickle
- loop {5,8}
- # build a room at current position
- rect cursor 1 {3,6} {2,5}
- # build a pathway to the next room
- digger cursor 1 {10,15} 0.1
- endloop
- # repeat the room command for the last room
- execline 5
- ---------------------------
- THOUGHTS
- 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.
- a lot of generation commands were ignored because they could be accomplished with other commands. these include:
- square [pos] [tile] [size] // paint a square with center of position and side length of [size]. alias for `rect [pos] [tile] [size] [size]`
- dot [pos] [tile] // set single tile at position. alias for `square [pos] [tile] 1`
- also, setting a "thickness" for the digger is unnecessary because you can do a digger, then use expand4 or expand8
- the execline command is to help with repeating code, but using line numbers is kind of terrible. maybe there should be labels?
- jumpline is goto, but with a random chance haha. i think goto is fine in a script like this
- 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.
- custom functions might be a good idea. possibly separate files with a new symbol to represent arguments (such as $1, $2, ...). for instance:
- # thickdigger [pos] [tile] [life] [turn chance] [thickness]
- digger $1 $2 $3 $4
- loop $5
- expand4 $2 $2
- endloop
- end
- or
- # dot [pos] [tile]
- rect $1 $2 1 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement