Advertisement
electronic_steve

#tptscripts portal script

Jun 10th, 2014
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.67 KB | None | 0 0
  1. local px=-1
  2. local py=-1
  3. local portalcolor = "orange"
  4. function unreg(x)
  5. tpt.unregister_step(x)
  6. end
  7. function reg(x)
  8. tpt.register_step(x)
  9. end
  10. local portalelement = "prti"
  11. local ESMD = elements.allocate("ESMD", "FATE")
  12. elements.element(elements.ESMD_PT_FATE, elements.element(tpt.element("PHOT")))
  13. elements.property(elements.ESMD_PT_FATE, "Name", "FATE")
  14. elements.property(elements.ESMD_PT_FATE, "Description", "field of anti-expropriation")
  15. elements.property(elements.ESMD_PT_FATE, "MenuVisible", 1)
  16. elements.property(elements.ESMD_PT_FATE, "MenuSection", 3)
  17. elements.property(elements.ESMD_PT_FATE, "HighPressure", 999999)
  18. elements.property(elements.ESMD_PT_FATE, "Colour", 0xFF127BC1)
  19. elements.property(elements.ESMD_PT_FATE, "Temperature", 0+273.15)
  20.  
  21.   function FATE(i, x, y, s, n)
  22.  local ctype= tpt.get_property("ctype",i)
  23. if math.random(1,50)==1  then tpt.set_property("vy",-1,i)end
  24. if math.random(1,50)==1  then  tpt.set_property("vy",1,i)end
  25. if tpt.get_property("vx",i)==0 then else tpt.set_property("vx",0,i) end
  26.  if tpt.get_property("type",x,y+1)==0 or  tpt.get_property("type",x,y+1)==tpt.element("FATE") then else tpt.set_property("vy",-1,i)  end
  27.  if tpt.get_property("type",x,y-1)==0 or  tpt.get_property("type",x,y-1)==tpt.element("FATE")  then else tpt.set_property("vy",1,i)  end
  28.  if  tpt.get_property("type",x,y)==ctype  then tpt.delete(i) tpt.delete(x,y)  end
  29. end
  30. tpt.element_func(FATE,tpt.element("FATE"))
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. local ESMD = elements.allocate("ESMD", "PRTB")
  43. elements.element(elements.ESMD_PT_PRTB, elements.element(tpt.element("PHOT")))
  44. elements.property(elements.ESMD_PT_PRTB, "Name", "PRTB")
  45. elements.property(elements.ESMD_PT_PRTB, "Description", "portal  ball")
  46. elements.property(elements.ESMD_PT_PRTB, "MenuVisible", 0)
  47. elements.property(elements.ESMD_PT_PRTB, "MenuSection", 0)
  48. elements.property(elements.ESMD_PT_PRTB, "HighPressure", 999999)
  49. elements.property(elements.ESMD_PT_PRTB, "Colour", 0xFF127BC1)
  50. elements.property(elements.ESMD_PT_PRTB, "Temperature", 0+273.15)
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.   function portalgun(i, x, y, s, n)
  58.  stkmlife = tpt.get_property("life",i)
  59. px = x
  60. py = y
  61. if tpt.get_property("tmp",i) ==0  then tpt.register_step(drawportalgun) tpt.set_property("tmp",i) end
  62. if tpt.get_property("tmp",i) ==nil then tpt.unregister_step(drawportalgun) end
  63.  end
  64.  
  65.  
  66.  tpt.element_func(portalgun,tpt.element("STK2"))
  67.  
  68.  
  69.  
  70.  function drawportalgun()
  71. if px<8 or px>604 or py<8 or py>376 or stkmlife <=50 then tpt.unregister_step(drawportalgun) end
  72.  
  73.  
  74. if portalgunset == 1 then
  75.  tpt.drawline(px,py+3,px+2,py+5,100,100,255)
  76.  tpt.drawpixel(px+3,py+5,100,100,255)
  77.  tpt.drawline(px+4,py+5,px+4,py+6,204,204,204)
  78.  tpt.drawpixel(px+5,py+4,204,204,204)
  79.  tpt.drawpixel(px+6,py+4,255,185,0)
  80.  tpt.drawrect(px+5,py+5,1,1,239,239,239)  
  81. tpt.drawline(px+5,py+7,px+6,py+7,170,170,170)
  82. tpt.drawline(px+7,py+6,px+6,py+4,170,170,170)
  83. tpt.drawline(px+8,py+5,px+10,py+4,48,48,48)
  84. tpt.drawline(px+8,py+6,px+10,py+7,32,32,32)
  85. end
  86.  
  87. if portalgunset == 2 then
  88.  tpt.drawline(px,py+3,px-2,py+5,100,100,255)
  89.  tpt.drawpixel(px-3,py+5,100,100,255)
  90.  tpt.drawline(px-4,py+5,px-4,py+6,204,204,204)
  91.  tpt.drawpixel(px-5,py+4,204,204,204)
  92.  tpt.drawpixel(px-6,py+4,255,185,0)
  93.  tpt.drawrect(px-6,py+5,1,1,239,239,239)  
  94. tpt.drawline(px-5,py+7,px-6,py+7,170,170,170)
  95. tpt.drawline(px-7,py+6,px-6,py+4,170,170,170)
  96. tpt.drawline(px-8,py+5,px-10,py+4,48,48,48)
  97. tpt.drawline(px-8,py+6,px-10,py+7,32,32,32)
  98. end
  99.  end
  100.  local ESP = 0
  101.   function keyfix(key_char)
  102.  
  103. if ESP ==2 then ESP = 0 end
  104.  if key_char == "v" then ESP = ESP+1 end
  105.  if key_char == "c" then ESP = ESP+1 end
  106.  if key_char == "a" then ESP = ESP+1 end
  107.  if key_char == "d" then ESP = ESP+1 end
  108.  if key_char == "]" then ESP = ESP+1 print(ESP) end
  109. end
  110. tpt.register_keypress(keyfix)
  111.  function portalgunshotkey(key_char)
  112.  
  113.   if key_char == "v" and portalgunset == 1 and ESP == 2 then tpt.create(px+12,py+5,tpt.element("PRTB"))  end
  114.   if key_char == "v" and portalgunset == 2 and ESP == 2  then tpt.create(px-12,py+5,tpt.element("PRTB"))   end
  115.   if key_char == "c" and portalgunset==0 and ESP == 2  then portalgunset=math.random(1,2)   end
  116.   if key_char == "c" and portalgunset==math.random(1,2) and ESP == 0  then portalgunset=0   end
  117.    
  118.   if key_char == "a"  and ESP == 2 then portalgunset=2    end
  119.   if key_char == "d"  and ESP == 2 then portalgunset=1  end
  120.  
  121.  
  122. end
  123.  
  124.  
  125. tpt.register_keypress(portalgunshotkey)
  126.  
  127.   function portballfunc(i, x, y, s, n)
  128.   deleteportal = 1
  129.  
  130.  local tmp2  = tpt.get_property("tmp2",i)
  131. if tmp2 == 0 then  tpt.set_property("tmp2",portalelement,i) end
  132.  if tpt.get_property("tmp2",i) == tpt.element("prti") then deleteportal=1 end
  133.  if tpt.get_property("tmp2",i) ==  tpt.element("prto") then deleteportal=2 end
  134.  
  135.  if tpt.get_property("tmp",i) == 0 and portalgunset ==1 then tpt.set_property("tmp",1,i) tpt.set_property("vx",1,i) end
  136.  if tpt.get_property("tmp",i) == 0 and portalgunset ==2 then tpt.set_property("tmp",2,i) tpt.set_property("vx",-1,i) end
  137.  if tpt.get_property("type",x+1,y) == 0 then else tpt.set_property("vx",0,i) tpt.delete(i)
  138.   deleteportal = 0
  139.  for goup =1,9 do
  140.     tpt.set_property("temp",9999,tpt.create(x,y-goup,tmp2))
  141.   if tpt.get_property("type",x+1,y-goup) ==0 then break end
  142.  if  tpt.get_property("type",x,y-goup) ==0 or tpt.get_property("type",x,y-goup) ==tmp2  then else break end
  143.  end
  144.    for godown =0,5 do
  145.   tpt.set_property("temp",9999,tpt.create(x,y+godown,tmp2))
  146.   if tpt.get_property("type",x+1,y+godown) ==0 then break end
  147.  if  tpt.get_property("type",x,y+godown) ==0 or tpt.get_property("type",x,y+godown) ==tmp2 then else break end
  148.  end
  149.  end
  150.   if tpt.get_property("type",x-1,y) == 0 then else tpt.set_property("vx",0,i)
  151.   tpt.delete(i)
  152.  deleteportal = 0
  153.  for goup =1,9 do
  154.     tpt.set_property("temp",9999,tpt.create(x,y-goup,tmp2))
  155.   if tpt.get_property("type",x-1,y-goup) ==0 then break end
  156.  if  tpt.get_property("type",x,y-goup) ==0 or tpt.get_property("type",x,y-goup) ==tmp2  then else break end
  157.  end
  158.   for godown =0,5 do
  159.     tpt.set_property("temp",9999,tpt.create(x,y+godown,tmp2))
  160.   if tpt.get_property("type",x-1,y+godown) ==0 then break end
  161.  if  tpt.get_property("type",x,y+godown) ==0 or tpt.get_property("type",x,y+godown) ==tmp2 then else break end
  162.  end
  163.  end
  164.  end
  165.  
  166.  
  167.  
  168.  
  169.  tpt.element_func(portballfunc,tpt.element("PRTB"))
  170.  
  171.  
  172. local tl = 0
  173.  function clickstikman(x, y, b, e)
  174.  
  175. if b==1 and e ==1 and x> px-15 and y>py-22 and x<px and y<py-10 and drawguitest and portalcolor=="orange" then portalcolor2="blue"     end
  176. if b==1 and e ==1 and x> px-15 and y>py-22 and x<px and y<py-10 and drawguitest and portalcolor=="blue" then portalcolor2="orange"     end
  177.  
  178.  
  179. if b==2 and e==1 and tl==1 then
  180. drawguitest = false
  181. tpt.unregister_step(drawgui)
  182. tl=2
  183. end
  184. if x>px-2 and x<px+2 and y>py-2 and y<py+2 and b==1 and e==1 and tl==0 then
  185. drawguitest = true
  186. tpt.register_step(drawgui)
  187. tl = 1
  188. end
  189. if tl==2 then tl = 0 end
  190. --fix lua bug
  191. if portalcolor2 == "blue" then portalcolor = "blue" portalelement  = "prto" end
  192. if portalcolor2 == "orange" then portalcolor = "orange" portalelement  = "prti" end
  193. if deleteportal2 == 1 then deleteportal = 0 end
  194. if deleteportal2 == 2 then deleteportal = 0 end
  195. end
  196.  tpt.register_mouseclick(clickstikman)
  197.  
  198.  
  199.  function drawgui()
  200.  
  201.  
  202.  
  203.  if portalcolor == "orange" then tpt.drawtext( px-tpt.textwidth("\170 "), py-20, '\170', 234, 88, 22) prtalelement="prti"  end
  204.  if portalcolor == "blue" then tpt.drawtext( px-tpt.textwidth("\170 "), py-20, '\170', 31, 234, 255) prtalelement="prto" end
  205.  if portalgunset == 2 then tpt.drawtext( px, py-20, '\150', 192, 192, 192, col) end
  206.  if portalgunset == 1 then tpt.drawtext( px, py-20, '\149', 192, 192, 192, col) end
  207.  
  208.  tpt.drawrect(px-tpt.textwidth("\170 ")-1,py-21,tpt.textwidth("\170 ")+tpt.textwidth("\150")+2,10)
  209. end
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  function portalfunc(i, x, y, s, n)
  219.  if deleteportal == 1 and tpt.get_property("tmp",i) == 100 then  tpt.delete(i)  deleteportal2 = 0  end
  220.  end
  221.  
  222.  tpt.element_func(portalfunc,tpt.element("prti"))
  223.  
  224.  
  225.  
  226.  
  227.  
  228.   function portalfunc2(i, x, y, s, n)
  229.  if deleteportal == 2 and tpt.get_property("tmp",i) == 100 then  tpt.delete(i)  deleteportal2 = 0  end
  230.  end
  231.  
  232.  tpt.element_func(portalfunc,tpt.element("prto"))
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  local cindex = 1
  243.  local cindex2 = 1
  244.  local cindex3 = 1
  245.   function drawname()
  246.  
  247.   cindex = cindex+1
  248.   cindex2 = cindex2+1.25
  249.   cindex3 = cindex3+1.5
  250.   if cindex >=256 then cindex = 1   end
  251.   if cindex2 >=256 then cindex2 = 1   end
  252.    if cindex3 >=256 then cindex3 = 1   end
  253.  tpt.drawtext(510,412,"electronic_...",cindex,cindex2,cindex3)
  254.  st=1
  255.  end
  256.  
  257.  
  258.  function nametest()
  259.  
  260.  if tpt.get_name() == "electronic_steve"  and st==nil then tpt.register_step(drawname) end
  261.  end
  262.  tpt.register_step(nametest)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement