Advertisement
ssccsscc

Soap 'worm'

Dec 1st, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. local SWRM = elements.allocate("SSCCSSCC", "SWRM")
  2. elements.element(elements.SSCCSSCC_PT_SWRM, elements.element(elements.DEFAULT_PT_DMND))
  3. elements.property(elements.SSCCSSCC_PT_SWRM, "Name", "SWRM")
  4. elements.property(elements.SSCCSSCC_PT_SWRM, "Description", "Soap worm")
  5. elements.property(elements.SSCCSSCC_PT_SWRM, "MenuSection", 11)
  6.  
  7.  
  8. local function swrm(i,x,y,s,n)
  9. sim.partKill(i)
  10. end
  11. tpt.element_func(swrm,elements.SSCCSSCC_PT_SWRM)
  12.  
  13. n=0
  14. soap={}
  15.  
  16. function makesoap()
  17. function keyHandler(keyString, key, modifier, event)
  18. if key==279 then
  19. n=0
  20. tpt.set_pause(0)
  21. end
  22. function mouseHandler(mousex, mousey, button, event)
  23. local x2=tpt.mousex
  24. local y2=tpt.mousey
  25. local x, y = sim.adjustCoords(x2, y2)
  26. if (button==1) and (tpt.get_property("type", x, y)==0) and (tpt.selectedl=="SSCCSSCC_PT_SWRM") then
  27. n=n+1
  28. tpt.create(x, y, "SOAP")
  29. soap[n]=sim.partID(x, y)
  30. if n==1 then
  31. tpt.set_property("ctype","STNE",soap[n])
  32. tpt.set_property("life","100000",soap[n])
  33. end
  34. if n>1 then
  35. tpt.set_property("life","100000",soap[n])
  36. tpt.set_property("ctype","GUN",soap[n])
  37. tpt.set_property("tmp",soap[n-1],soap[n])
  38. tpt.set_property("tmp2",'0',soap[n])
  39. tpt.set_property("tmp2",soap[n],soap[n-1])
  40. end
  41. end
  42. end
  43. tpt.register_mouseclick(mouseHandler)
  44. end
  45. tpt.register_keypress(keyHandler)
  46. end
  47. tpt.register_step(makesoap)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement