Advertisement
TPT_PL

Lithium (Li)

Oct 9th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.27 KB | None | 0 0
  1. local Li = elem.allocate("YOL0", "LITH")
  2. elem.element(Li, elem.element(elem.DEFAULT_PT_BMTL))
  3. elem.property(Li, "Name", "LITH")
  4. elem.property(Li, "Description", "Lithium, can be used as a rechargeable battery, rusts in empty space.")
  5. elem.property(Li, "Color", 0x666633)
  6. elem.property(Li, "Properties", elem.TYPE_SOLID+elem.PROP_HOT_GLOW)
  7.  
  8. local function lithium(i, x, y, s, nt)
  9.     if s > 0 then
  10.         if math.random(1, 1000000) == 1 then
  11.             sim.partChangeType(i, elem.DEFAULT_PT_BRMT)
  12.         end
  13.     end
  14.     for r in sim.neighbors(x, y, 2, 2) do
  15.         if sim.partProperty(r, "type") == elem.DEFAULT_PT_SPRK and sim.partProperty(r, "life") == 3 then
  16.             if sim.partProperty(r, "ctype") == elem.DEFAULT_PT_PSCN then
  17.                 sim.partProperty(i, "tmp", sim.partProperty(i, "tmp")+1)
  18.             end
  19.         elseif sim.partProperty(r, "type") == elem.DEFAULT_PT_NSCN and sim.partProperty(i, "tmp") > 0 and sim.partProperty(r, "life") == 0 then
  20.             sim.partProperty(r, "type", elem.DEFAULT_PT_SPRK)
  21.             sim.partProperty(r, "ctype", elem.DEFAULT_PT_NSCN)
  22.             sim.partProperty(r, "life", 4)
  23.             sim.partProperty(i, "tmp", sim.partProperty(i, "tmp")-1)
  24.         end
  25.     end
  26. end
  27.  
  28. elem.property(Li, "Update", lithium)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement