Guest User

Diamond NULLifier

a guest
May 10th, 2015
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. -- reaction(i, x, y, nt, radius, percentage, element A, element B, element C)
  2.  
  3. local function reaction(i,x,y,nt,r,p,a,b,c)
  4.     local chance = math.random(1,1/(p/100)) == 1
  5.     local dx = math.random(-r,r)
  6.     local dy = math.random(-r,r)
  7.     if nt > 0 and chance and tpt.get_property("type", x+dx, y+dy) == a then
  8.         tpt.set_property("type", b, i)
  9.         tpt.set_property("type", c, x+dx, y+dy)
  10.     end
  11. end
  12.  
  13. -- velocity(i, initial velocity, number of directions)
  14.  
  15. local function velocity(i,v,n)
  16.     if tpt.get_property("vx", i) == 0 and tpt.get_property("vy", i) == 0 then
  17.         local angle = math.random(1,n)*(2*math.pi/n)
  18.         tpt.set_property("vx", v*math.cos(angle), i)
  19.         tpt.set_property("vy", v*math.sin(angle), i)
  20.     end
  21. end
  22.  
  23. -- NULL element
  24.  
  25. local null = elements.allocate("ELEMENT", "NULL")
  26. elements.element(null, elements.element(elements.DEFAULT_PT_PHOT))
  27. elements.property(null, "Name", "NULL")
  28. elements.property(null, "Description", "NULL, displaces DMND.")
  29. elements.property(null, "Colour", 0xFF2020)
  30. elements.property(null, "Diffusion", 0)
  31. elements.property(null, "HotAir", 0)
  32. elements.property(null, "AirDrag", 0)
  33. elements.property(null, "AirLoss", 0)
  34. elements.property(null, "HeatConduct", 0)
  35.  
  36. local function nullUpdate(i,x,y,s,nt)
  37.     velocity(i, 2, 6)
  38.     reaction(i, x, y, nt, 2, 50, elements.DEFAULT_PT_DMND, elements.DEFAULT_PT_DMND, elements.ELEMENT_PT_NULL)
  39. end
  40.  
  41. elements.property(null, "Update", nullUpdate)
Advertisement
Add Comment
Please, Sign In to add comment