Advertisement
DayTimer

TPT - Langton's Ants

Dec 17th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. -- Just fixing bug with wrong testing system during 3 hours. I hate bugfixes...
  2. -- I just made a mess with formatting.
  3. siden = 1
  4. side = 1
  5. local ANT = elements.allocate("DLI", "ANT")
  6. elements.element(ANT, elements.element(elements.DEFAULT_PT_PROT))
  7. elements.property(ANT, "Name" , "ANT")
  8. elements.property(ANT, "Description" , "Default Langton's ant. Changes elements under it to air, rotates 90* and moves forward, else rotates -90* and changes air to FRME. DO NOT PLACE MORE THAN 1!")
  9. elements.property(ANT, "Color", 0x66cc66)
  10. elements.property(ANT, "Diffusion", 0)
  11. elements.property(ANT, "Weight", 0)
  12. elements.property(ANT, "MenuSection", 12)
  13. elements.property(elements.DLI_PT_ANT, "Update",
  14. function(i,x,y,s,nt)
  15.     siden = side
  16.     sim.partProperty(i, "y", y+1) --to test particles under it
  17.     if siden == 4 then
  18.         local px,py = 0,0
  19.         px,py = x, y
  20.         if sim.partID(px,py) == 0 then
  21.             tpt.create(px,py,"FRME")
  22.             sim.partProperty(i, "x", px+1)
  23.             side=1
  24.         else
  25.             sim.partKill(sim.partID(px,py))
  26.             side=3
  27.             sim.partProperty(i, "x", px-1)
  28.         end end
  29.             if siden == 3 then
  30.                 local px,py = 0,0
  31.                 px,py = x, y
  32.                 if sim.partID(px,py) == 0 then
  33.                     tpt.create(px,py,"FRME")
  34.                     sim.partProperty(i, "y", py+1)
  35.                     side=4
  36.                 else
  37.                     sim.partKill(sim.partID(px,py))
  38.                     side=2
  39.                     sim.partProperty(i, "y", py-1)
  40.                 end end
  41.                     if siden == 2 then
  42.                         local px,py = 0,0
  43.                         px,py = x, y
  44.                         if sim.partID(px,py) == 0 then
  45.                             tpt.create(px,py,"FRME")
  46.                             sim.partProperty(i, "x", px-1)
  47.                             side=3
  48.                         else
  49.                             sim.partKill(sim.partID(px,py))
  50.                             side=1
  51.                             sim.partProperty(i, "x", px+1)
  52.                         end end
  53.                             if siden == 1 then
  54.                                 local px,py = 0,0
  55.                                 px,py = x, y
  56.                                 if sim.partID(px,py) == 0 then
  57.                                     tpt.create(px,py,"FRME")
  58.                                     sim.partProperty(i, "y", py-1)
  59.                                     side=2
  60.                                 else
  61.                                     sim.partKill(sim.partID(px,py))
  62.                                     side=4
  63.                                     sim.partProperty(i, "y", py+1)
  64.                                 end
  65. sim.partProperty(i,"y", y-1) --testing particle under it
  66.     end
  67. end
  68. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement