Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.15 KB | None | 0 0
  1. local b = require 'map_gen.shared.builders'
  2. local math = require "utils.math"
  3.  
  4. --Create maltese shape
  5. local starting_area = 60
  6. local gradient = 0.05
  7. local tiles_half = (starting_area) * 0.5
  8. local function maltese_cross(x,y)
  9.  
  10.     local abs_x = math.abs(x)
  11.     local abs_y = math.abs(y)
  12.    
  13.     return not (abs_x > (tiles_half+(abs_y*gradient)) and abs_y > (tiles_half+(abs_x*gradient)))
  14. end
  15.  
  16. -- create water crossings and pattern
  17. local water_line =
  18.         b.any {
  19.         b.rectangle(10, 2)
  20.     }  
  21. water_line = b.change_tile(water_line, true, 'water')
  22.  
  23. local waters = b.single_y_pattern(water_line, 3)
  24. local bounds = b.rectangle(10, starting_area+1)
  25. waters = b.choose(bounds, waters, b.empty_shape)
  26. waters = b.translate(waters,34,-1)
  27.  
  28. water_pattern =
  29.     b.any{
  30.     waters,
  31.     b.rotate(waters,degrees(90)),
  32.     b.rotate(waters,degrees(180)),
  33.     b.rotate(waters,degrees(270))
  34.     }
  35.  
  36. -- create the starting area as a concrete square
  37. local concrete_square =  b.rectangle(60, 60)
  38. concrete_square = b.change_tile(concrete_square, true, 'grass-1')
  39.  
  40. -- work on the  ore generation based on the code in hub_spiral.lua
  41.  
  42. -- worm islands
  43. worm_island = b.rectangle(20,300)
  44. worm_island_end = b.circle(10)
  45. worm_island = b.any{
  46.     worm_island_end,
  47.     b.translate(worm_island,0,-150),
  48.     b.translate(worm_island_end,0,-300)
  49. }
  50. worm_island = b.change_tile(worm_island, true, 'grass-1')
  51.  
  52.  
  53. local worm_names = {
  54.     'small-worm-turret',
  55.     'medium-worm-turret',
  56.     'big-worm-turret'
  57. }
  58.  
  59. --worm_island = b.apply_entities(worm_island, worms)
  60.  
  61. worm_islands = b.any{
  62.     b.rotate(b.translate(worm_island,0,-100),degrees(45)),
  63.     b.rotate(b.translate(worm_island,0,-100),degrees(45+90)),
  64.     b.rotate(b.translate(worm_island,0,-100),degrees(45+180)),
  65.     b.rotate(b.translate(worm_island,0,-100),degrees(45+270))
  66. }
  67.  
  68. -- create the start area using the ore, water and concrete starting_square
  69. local start_area =
  70.     b.any {
  71.     water_pattern,
  72.     concrete_square
  73. }
  74.    
  75. maltese_cross = b.change_tile(maltese_cross, true, 'grass-1')
  76.  
  77. local sea = b.change_tile(b.full_shape, true, 'water')
  78. sea = b.fish(sea, 0.00125)
  79.  
  80. local map = b.any{worm_islands, start_area, maltese_cross,sea}
  81. return map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement