Advertisement
Xelostar

Noise Demo 1

Jul 7th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. local colorchar = {}
  2. local colorchars = "0123456789abcdef"
  3. local charNr = 0
  4. for char in colorchars:gmatch(".") do
  5.     colorchar[2 ^ charNr] = char
  6.     charNr = charNr + 1
  7. end
  8.  
  9. local function drawWorld(world, atX, atY)
  10.     local size = table.getn(world)
  11.     for y = 1, size do
  12.         local str = ""
  13.         local c1 = ""
  14.         local c2 = ""
  15.  
  16.         local color1 = colors.black
  17.         local color2 = colors.black
  18.  
  19.         for x = 1, size do
  20.             local value = world[x][y]
  21.             if (value <= 0.25) then
  22.                 color1 = colors.black
  23.                 if (value <= 0.25 / 2) then
  24.                     color2 = colors.black
  25.                 else
  26.                     color2 = colors.gray
  27.                 end
  28.             elseif (value <= 0.50) then
  29.                 color1 = colors.gray
  30.                 if (value <= 0.50 - 0.25 / 2) then
  31.                     color2 = colors.gray
  32.                 else
  33.                     color2 = colors.lightGray
  34.                 end
  35.             elseif (value <= 0.75) then
  36.                 color1 = colors.lightGray
  37.                 if (value <= 0.75 - 0.25 / 2) then
  38.                     color2 = colors.lightGray
  39.                 else
  40.                     color2 = colors.white
  41.                 end
  42.             else
  43.                 color1 = colors.white
  44.                 color2 = colors.white
  45.             end
  46.  
  47.             str = str..string.char(127)
  48.             c1 = c1..colorchar[color2]
  49.             c2 = c2..colorchar[color1]
  50.         end
  51.         term.scroll(1)
  52.         term.setCursorPos(atX or 1, atY or 19)
  53.         term.blit(str, c1, c2)
  54.         if (x ~= size) then
  55.             sleep(0.001)
  56.         end
  57.     end
  58. end
  59.  
  60. os.loadAPI("/noise")
  61. local seed = math.random(1, 10000)
  62.  
  63. local chunky = 1
  64. while true do
  65.     chunky = chunky + 1
  66.  
  67.     local world = noise.createNoise(32, 8, chunky, seed)
  68.     drawWorld(world, 10)
  69.  
  70.     os.queueEvent("fakeEvent")
  71.     os.pullEvent("fakeEvent")
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement