FeynmanTech

Powder Toy image plotting with QRTZ

Mar 14th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. function qrtz(filename)
  2. elemtype = 'qrtz'
  3. local f=io.open(filename,'rb')
  4. f:seek('set',20)
  5. local width=string.byte(f:read(1))+string.byte(f:read(1))*256+string.byte(f:read(1))*65536+string.byte(f:read(1))*16777216
  6. local height=string.byte(f:read(1))+string.byte(f:read(1))*256+string.byte(f:read(1))*65536+string.byte(f:read(1))*16777216
  7. f:seek('set',50)
  8. local red,green,blue=0,0,0
  9. for j=0,height-1 do
  10.  for i=0,width-1 do
  11.   blue,green,red=string.byte(f:read(1)),string.byte(f:read(1)),string.byte(f:read(1))
  12.   if i<612 and height-j<380 then
  13.    tpt.create(i,height-j,elemtype)
  14.    tpt.set_property('tmp',((red+green+blue)*.013071895),i,height-j)
  15.  tpt.set_property('life',((red+green+blue)*.013071895),i,height-j) -- No, life doesn't affect the color unless you change the element, but now you can change the element :)
  16.   end
  17.  end
  18.  for i=1,width%4 do f:read(1) end
  19. end
  20. f:close()
  21. end
Advertisement
Add Comment
Please, Sign In to add comment