Skip to content

Instantly share code, notes, and snippets.

@Sobsz
Last active August 1, 2021 16:10
Show Gist options
  • Save Sobsz/74a5e992b290224b11344d9440eb52c5 to your computer and use it in GitHub Desktop.
Save Sobsz/74a5e992b290224b11344d9440eb52c5 to your computer and use it in GitHub Desktop.
Parkour Generator(tm)
// needs an mb with `/oss #pg_genblock repeatable`, by default at 103,63,122
// also needs empty space corresponding to the parkour area, by default starting at 0,111,0
// also also the performance is awful please don't actually use this without serious modification
// unlicense/0bsd/cc0/wtfpl/whatever
#input
set teststr pg_seed
if runArg1|=|teststr call #pg_setseed
quit
#pg_setseed
set pg_rng {runArg2}
setmod pg_rng 4294967296
msg &~seed set to {pg_rng}
quit
#pg_rngnext
// https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
setmul pg_rng 69069
setadd pg_rng 1
setmod pg_rng 4294967295
set pg_rngout {pg_rng}
// the low bits are super predictable, not that it matters for parkour but whatever
setdiv pg_rngout 256
setrounddown pg_rngout
quit
#pg_gen
msg &~Parkour Generator(tm) is now generating...
// lower limit here because setrandrange errors otherwise
if pg_rng|=|0 setrandrange pg_rng 1 2147483647
msg &~seed is {pg_rng}
set pg_start_x {MBX}
set pg_start_y {MBY}
set pg_start_z {MBZ}
set pg_cur_x {MBX}
set pg_cur_y {MBY}
set pg_cur_z {MBZ}
set pg_min_x -4
set pg_max_x 4
set pg_min_y -3
set pg_max_y 8
set pg_min_z 1
set pg_max_z 100
call #pg_clear
goto #pg_genblock
quit
#pg_clear
set pg_temp_1 {pg_max_x}
setsub pg_temp_1 {pg_min_x}
set pg_temp_2 {pg_max_y}
setsub pg_temp_2 {pg_min_y}
setadd pg_temp_2 111
set pg_temp_3 {pg_max_z}
setsub pg_temp_3 {pg_min_z}
set pg_temp_4 {pg_start_x}
setadd pg_temp_4 {pg_min_x}
set pg_temp_5 {pg_start_y}
setadd pg_temp_5 {pg_min_y}
set pg_temp_6 {pg_start_z}
setadd pg_temp_6 {pg_min_z}
tempchunk 0 111 0 {pg_temp_1} {pg_temp_2} {pg_temp_3} {pg_temp_4} {pg_temp_5} {pg_temp_6}
quit
#pg_genblock
set pg_possible 0
call #pg_add|0|0|4
call #pg_add|1|0|4
call #pg_add|1|0|3
call #pg_add|2|0|3
call #pg_add|3|0|3
call #pg_add|3|0|2
call #pg_add|3|0|1
call #pg_add|0|-1|4
call #pg_add|0|1|3
call #pg_add|1|1|3
call #pg_add|0|0|2|0|3|1|true
call #pg_add|0|-1|3|0|3|1|true
call #pg_rngnext
set pg_block {pg_rngout}
setmod pg_block {pg_possible}
if pg_possible_{pg_block}_b call #pg_2ndblock
setadd pg_cur_x {pg_possible_{pg_block}_xa}
setadd pg_cur_y {pg_possible_{pg_block}_ya}
setadd pg_cur_z {pg_possible_{pg_block}_za}
tempblock 81 {pg_cur_x} {pg_cur_y} {pg_cur_z}
set pg_test {pg_cur_z}
setsub pg_test {pg_start_z}
setadd pg_test 4
if pg_test|>|pg_max_z goto #pg_done
goto #pg_genblockloop
quit
#pg_2ndblock
set pg_temp_1 {pg_cur_x}
setadd pg_temp_1 {pg_possible_{pg_block}_xb}
set pg_temp_2 {pg_cur_y}
setadd pg_temp_2 {pg_possible_{pg_block}_yb}
set pg_temp_3 {pg_cur_z}
setadd pg_temp_3 {pg_possible_{pg_block}_zb}
tempblock 65 {pg_temp_1} {pg_temp_2} {pg_temp_3}
quit
#pg_genblockloop
// this is to get around the action limit, point this to a mb with `/oss #pg_genblock repeatable`
cmd x 103 63 122
quit
#pg_add
call #pg_add2|{runArg1}|{runArg2}|{runArg3}|{runArg4}|{runArg5}|{runArg6}|{runArg7}
set pg_runArg1a {runArg1}
setmul pg_runArg1a -1
set pg_runArg4a {runArg4}
setmul pg_runArg4a -1
call #pg_add2|{pg_runArg1a}|{runArg2}|{runArg3}|{pg_runArg4a}|{runArg5}|{runArg6}|{runArg7}
quit
#pg_add2
set pg_add_min_x {runArg1}
if pg_add_min_x|>|{runArg4} set pg_add_min_x {runArg4}
setadd pg_add_min_x {pg_cur_x}
setsub pg_add_min_x {pg_start_x}
if pg_add_min_x|<|pg_min_x quit
set pg_add_max_x {runArg1}
if pg_add_max_x|<|{runArg4} set pg_add_max_x {runArg4}
setadd pg_add_max_x {pg_cur_x}
setsub pg_add_max_x {pg_start_x}
if pg_add_max_x|>|pg_max_x quit
set pg_add_min_y {runArg2}
if pg_add_min_y|>|{runArg5} set pg_add_min_y {runArg5}
setadd pg_add_min_y {pg_cur_y}
setsub pg_add_min_y {pg_start_y}
if pg_add_min_y|<|pg_min_y quit
set pg_add_max_y {runArg2}
if pg_add_max_y|<|{runArg5} set pg_add_max_y {runArg5}
setadd pg_add_max_y {pg_cur_y}
setsub pg_add_max_y {pg_start_y}
if pg_add_max_y|>|pg_max_y quit
set pg_possible_{pg_possible}_xa {runArg1}
set pg_possible_{pg_possible}_ya {runArg2}
set pg_possible_{pg_possible}_za {runArg3}
set pg_possible_{pg_possible}_b {runArg7}
if runArg7 set pg_possible_{pg_possible}_xb {runArg4}
if runArg7 set pg_possible_{pg_possible}_yb {runArg5}
if runArg7 set pg_possible_{pg_possible}_zb {runArg6}
setadd pg_possible 1
quit
#pg_done
msg &edone
quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment