Guest User

IsoBlock

a guest
May 9th, 2020
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function init()
  2.     setName("IsoBlock")
  3.     setDesc("Isometric Block Simulation")
  4.     setSize(100, 24+64+8+8+18+7+4+18)
  5.     addOutput(24+32)
  6.     addInput("z",24+8+8+8)
  7.     addInput("x",24+8+8+8+8)
  8.     addInput("y",24+8+8+8+8+8)
  9.     addParameter("Depth", "Depth of the block", 24+64+8+8, 0, 0, (getTileSize()/2)-1)
  10.     addParameter("Width", "Width of the block", 24+64+8+8+18, getTileSize(), 0, getTileSize())
  11.     addParameter("Length", "Length of the block", 24+64+8+8+18+18, getTileSize(), 0, getTileSize())
  12. end
  13.  
  14. function apply()
  15.     tileSize = getTileSize()
  16.     Depth = getValue(3,0,0,1)
  17.     Width = getValue(4,0,0,1)
  18.     Length = getValue(5,0,0,1)
  19.    
  20.     for i=0, tileSize*tileSize-1 do
  21.         x = i%tileSize
  22.         y = math.floor(i/tileSize)
  23.         s = (getTileSize()/2)-0.5
  24.         outr,outg,outb = getValue(0,x,y,1)
  25.         if (x >= tileSize-Width and y > tileSize-Length) then
  26.             setPixel(0, s+((x-y)/2), s+math.ceil((x+y)/4)-Depth, outr, outg, outb )
  27.         end
  28.     end
  29.     for i=0, tileSize*tileSize-1 do
  30.         x = i%tileSize
  31.         y = math.floor(i/tileSize)
  32.         s = (getTileSize()/2)-0.5
  33.         outr,outg,outb = getValue(1,x,y,1)
  34.         if (x <= Length and y < Depth*2-1) then
  35.             setPixel(0, s+(x/2), ((y/2)-math.ceil(x/4))-Depth, outr, outg, outb )
  36.         end
  37.     end
  38.     for i=0, tileSize*tileSize-1 do
  39.         x = i%tileSize
  40.         y = math.floor(i/tileSize)
  41.         s = (getTileSize()/2)-0.5
  42.         outr,outg,outb = getValue(2,x,y,1)
  43.         if (x <= Width and y < Depth*2-1) then
  44.             setPixel(0, s-(x/2), ((y/2)-math.ceil(x/4))-Depth, outr, outg, outb )
  45.         end
  46.     end
  47.    
  48. end
RAW Paste Data