Advertisement
MYXOMOPX

Varscript Island generator

Jan 3rd, 2013
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.09 KB | None | 0 0
  1. [-1:0:0, 1:0:0, 0:0:1, 0:0:-1] %%vec
  2. :Blocks4{ ## Block -> [Blocks]
  3.     @@vec ${OVER SWAP ADDBLOCK} SWAP DROP
  4. }
  5. :GetPlatform{ ## Block -> [Blocks]
  6.  
  7.     <B ARRAY SWAP ADD %temp
  8.     200 %l
  9.     BEGIN
  10.          () @temp LEN
  11.          () @l
  12.         AND
  13.         WHILE
  14.         ARRAY @temp &{Blocks4 JOIN} UNIQUE @temp &AREM @result &AREM ?ID %x
  15.         @temp @result JOIN UNIQUE %result
  16.         @x %temp
  17.         @l 1 - %l
  18.         REPEAT
  19.     @result
  20. }
  21. :FillIsland{ ## block ->
  22.     "Scan area" .
  23.     GetPlatform
  24.     "Filling ..." .
  25.     ${
  26.         ME 0 GET >BL
  27.         -1 ADDBLOCK
  28.         ME 1 GET >BL
  29.         -1 ADDBLOCK
  30.         ME RANDOM 0.5 > IF 1 ELSE 2 THEN GET >BL
  31.         -1 ADDBLOCK
  32.         ME 2 GET >BL
  33.     } %floor
  34.     0 %deg
  35.     BEGIN
  36.         @floor FALSE << OR
  37.         WHILE
  38.         @floor &{DUP Blocks4 ?ID LEN 4 D- RANDOM 2.2 @deg D+ D* D+ 0 > IF -1 ADDBLOCK ME 2 GET >BL ELSE DROP THEN}
  39.         @floor ${-1 ADDBLOCK} ?ID %floor
  40.         @deg 0.1 D+ 3 MIN %deg
  41.         REPEAT
  42.     "Completed. select next block" .
  43. }
  44. "Select block to fill or air to finish" .
  45. SUB {
  46.     EVENT(PLAYER) ME =! IF RETURN THEN
  47.     EVENT(BLOCK) %b
  48.     EVENT(CANCEL)
  49.     @b IF
  50.         @b FillIsland
  51.         ELSE
  52.         SEND(fin)
  53.         "Finish" .
  54.         END
  55.         THEN
  56. } REG(PlayerInteract) AWAIT(fin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement