Autorun.lua Sharing

  • Dawgie
    28th Mar 2012 Member 0 Permalink
    post your favorite autorun scripts here you don't have to have them in a code box so i don't want to see any posts such as "use a code box". Note: You must explain what it does!  But anyway here's mine-
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    typens={'DUST','WATR','OIL','FIRE','STNE','LAVA','GUN','NITR','CLNE','GAS','C-4','GOO','ICE','METL','SPRK','SNOW','WOOD','NEUT','PLUT','PLNT','ACID','VOID','WTRV','CNCT','DSTW','SALT','SLTW','DMND','BMTL','BRMT','PHOT','URAN','WAX','MWAX','PSCN','NSCN','LN2','INSL','VACU','VENT','RBDM','LRBD','NTCT','SAND','GLAS','PTCT','BGLA','THDR','PLSM','ETRD','NICE','NBLE','BTRY','LCRY','STKM','SWCH','SMKE','DESL','COAL','LO2','O2','INWR','YEST','DYST','THRM','GLOW','BRCK','CFLM','FIRW','FUSE','FSEP','AMTR','BCOL','PCLN','HSWC','IRON','MORT','LIFE','DLAY','CO2','DRIC','CBNW','STOR','PVOD','CONV','CAUS','LIGH','TESC','DEST','SPNG','RIME','FOG','BCLN','LOVE','DEUT','WARP','PUMP','FWRK','PIPE','FRZZ','PRZW','GRAV','BIZR','BIZG','BIZS','INST','ISOZ','ISZS','PRTI','PRTO','PSTE','PSTS','ANAR','VINE','INVS','EQVE','SPW2','SPWN','SHLD','SHD2','SHD3','SHD4','LOLZ','WIFI','FILT','ARAY','BRAY','STK2','BOMB','C-5','SING','QRTZ','PQRT','EMP','BREL','','','','','','BOYL','','','','','','','H2','SOAP','BHOL','WHOL','MERC','PBCN','GPMP','CLST','WIRE','GBMB','FIGH','IGNC','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','Conductor wall','E-wall','Reg wall','Streamline','Sign','Fan','Liq-only wall','Absorber','Erase walls','Wall','Air-only wall','Solid-only wall','Yellow wall','E-Hole','AIR','HEAT','COOL','VAC','Gas-only wall','WIND','Gravity wall','PGRV','NGRV','Energy wall','PROP'}
    typens[0]='NONE'
    function findelem(a)
    if (typens[a]=='')or(typens[a]==nil) then
     return a
    else
     return typens[a]..'('..a..')'
    end
    end
    psel=0
    ctype=0
    ctypet=0
    life=0
    lifet=0
    tmp=0
    tpmt=0
    tmp2=0
    tmp2t=0
    temp=273.15+22
    tempt=0
    parts={}
    function replace()
     pp={}
     local i=0
     while parts[i]~=nil do
      pp[i]=parts[i]
      i=i+1
     end
     parts={}
     i=0
     tpt.start_getPartIndex()
     while tpt.next_getPartIndex() do
      if tpt.get_property('type',tpt.getPartIndex())==psel then
       parts[i]=tpt.getPartIndex()
       i=i+1
      end
     end
     i=0
     while parts[i]~=nil do
      if pp[i]==nil then
       if ctypet==1 then tpt.set_property('ctype',ctype,parts[i]) end
       if lifet==1 then tpt.set_property('life',life,parts[i]) end
       if tempt==1 then tpt.set_property('temp',temp,parts[i]) end
       if tmpt==1 then tpt.set_property('tmp',tmp,parts[i]) end
       if tmp2t==1 then tpt.set_property('tmp2',tmp2,parts[i]) end
      end
      i=i+1
     end
    end

    function step()
    if psel~=tpt.selectedl then
     psel=tpt.selectedl
     local i=0
     parts={}
     tpt.start_getPartIndex()
     while tpt.next_getPartIndex() do
      if tpt.get_property('type',tpt.getPartIndex())==psel then
       parts[i]=tpt.getPartIndex()
       i=i+1
      end
     end
     ctype=0
     ctypet=0
     life=0
     lifet=0
     tmp=0
     tpmt=0
     tmp2=0
     tmp2t=0
     temp=273.15+22
     tempt=0
     if psel==149 then
      tmp=-1
      tmp2=-1
     end
     if psel==21 or psel==86 then life=75 end
     if psel==95 then life=10 end
     if psel==152 then tmp=10 end
     if psel==131 or psel==4 or psel==49 or psel==68 or psel==18 or psel==6 then life='~' end
     if psel==132 or psel==133 or psel==155 then tmp='~' end
     if psel==71 then life=50 end
     if psel==59 then
      life=110
      tmp=50
     end
     if psel==101 then life=100 end
     if psel==99 then life=60 end
     if psel==73 then life=110 end
     if psel==13 then ctype=2 end
     if psel==31 then life=680 end
     if psel==87 or psel==68 then temp=0 end
     if psel==97 or psel==154 then temp=273.15 end
     if psel==79 then temp=273.15+4 end
     if psel==48 then temp=273.15+9000 end
     if psel==42 then temp=273.15+67 end
     if psel==4 then temp=273.15+422 end
     if psel==57 then temp=273.15+342 end
     if psel==49 then temp=9999 end
     if psel==23 then temp=273.15+122 end
     if psel==2 or psel==25 or psel==82 or psel==111 or psel==149 or psel==95 then temp=273.15+20 end
     if psel==6 then temp=273.15+1522 end
     if psel==34 then temp=273.15+50 end
     if psel==37 then temp=273.15-203 end
     if psel==60 then temp=273.15-193 end
     if psel==66 then temp=273.15+42 end
     if psel==16 then temp=273.15-8 end
     if psel==100 then temp=273.15-183 end
     if psel==13 then temp=273.15-28 end
     if psel==51 then temp=273.15-238 end
     if psel==81 then temp=273.15-100 end
     if psel==31 then temp=273.15+922 end
     end
    drawgui()
    replace()
    end

    function drawgui()
    if al>0 then
    tpt.drawrect(4,361,603,12,255,255,255,al)
    tpt.fillrect(4,361,603,12,0,1,1,al)
    tpt.drawtext(6,363,'TYPE:'..findelem(tpt.selectedl),0,255,255,al)
    if tpt.selectedl<159 then
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>128 and tpt.mousex<257 then tpt.fillrect(128,361,129,12,255,0,255,al/2) end
    tpt.drawtext(130,363,'CTYPE:'..findelem(ctype),255,0,0,al)
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>256 and tpt.mousex<313 then tpt.fillrect(256,361,57,12,255,0,255,al/2) end
    tpt.drawtext(258,363,'LIFE:'..life,0,255,255,al)
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>313 and tpt.mousex<393 then tpt.fillrect(313,361,80,12,255,0,255,al/2) end
    if cels==0 then
    tpt.drawtext(314,363,'TEMP:'..temp..'K',255,0,0,al)
    else
    tpt.drawtext(314,363,'TEMP:'..(temp-273.15)..'C',255,0,0,al)
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>393 and tpt.mousex<447 then tpt.fillrect(393,361,54,12,255,0,255,al/2) end
    tpt.drawtext(394,363,'TMP:'..tmp,0,255,255,al)
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>447 and tpt.mousex<605 then tpt.fillrect(447,361,160,12,255,0,255,al/2) end
    tpt.drawtext(448,363,'TMP2:'..tmp2,255,0,0,al)
    end
    end
    end

    function click(x,y,btn,ev)
     if ev==2 and btn==1 and tpt.selectedl<159 then
      if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>128 and tpt.mousex<257 then
       a=tpt.input('','Enter new CTYPE:',ctype)
       s=tonumber(a)
       if s~=nil then
        ctype=s
        ctypet=1
       else
        local i=0
        for i=0,158 do
         if string.upper(typens[i])==string.upper(a) then
          ctype=i
          ctypet=1
          break
         end
        end
       end
      end
      if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>256 and tpt.mousex<313 then
    s=tonumber(tpt.input('','Enter new LIFE:',life))
    if s~=nil then
     life=s
     lifet=1
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>313 and tpt.mousex<393 then
    s=tonumber(tpt.input('','Enter new TEMP:',temp))
    if s~=nil then
     temp=s
     tempt=1
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>393 and tpt.mousex<447 then
    s=tonumber(tpt.input('','Enter new TMP:',tmp))
    if s~=nil then
     tmp=s
     tmpt=1
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>447 and tpt.mousex<605 then
    s=tonumber(tpt.input('','Enter new TMP2:',tmp2))
    if s~=nil then
     tmp2=s
     tmp2t=1
    end
    end
    end
    if tpt.mousey>361 and tpt.mousey<372 and tpt.mousex>128 and tpt.mousex<605 then return false end
    end
    tgl=1
    function key(a,b,c,d)
     if (b==308 or b==304)and c==257 and event==1 then
      ctypet=1
      ctype=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      lifet=1
      life=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      tempt=1
      temp=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      tmpt=1
      tmp=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
      tmp2t=1
      tmp2=tpt.get_property('ctype',tpt.mousex,tpt.mousey)
     end
     if a=='e' and d==2 then
      tgl=1-tgl
      if tgl==0 then
       tpt.unregister_step(step)
       tpt.unregister_mouseclick(click)
      else
       tpt.register_step(step)
       tpt.register_mouseclick(click)
      end
     end
    end
    tpt.register_step(step)
    tpt.register_mouseclick(click)
    tpt.register_keypress(key)
    al=200
    cels=1



  • mniip
    28th Mar 2012 Developer 0 Permalink
    Hey, thats my script
  • The-Fall
    28th Mar 2012 Member 0 Permalink
    And some one is caught red handed.
  • devast8a
    28th Mar 2012 Former Staff 0 Permalink
    @mniip (View Post)
    @The-Fall (View Post)
    He never said it was his script, only his favorite script.
  • boxmein
    28th Mar 2012 Former Staff 0 Permalink
    Umm, would you explain what yours does?
  • Dingolo
    28th Mar 2012 Member 0 Permalink
    Here's mine:
    tpt.el.elec.menusection=3
    tpt.el.elec.color=0x9555ff
    tpt.el.elec.description="Ball Lightning. Travels in strait lines and bounces of solids. It electrifies conductors. Explodes when Life=1."
    tpt.el.elec.name="BLLT"
    math.randomseed(os.time())
    function ball_lightning(i,x,y,s,n)
       if tpt.get_property("tmp",i)==0 then
          tpt.set_property("life",math.random(50,150),i)
          tpt.set_property("tmp",1,i)
       end
       for n = 1,50 do
          xoff=math.random(-7,7)
          yoff=math.sqrt((49)-(xoff^2))
          if tpt.get_property("type",x+xoff,y+yoff)==0 then
             tpt.create(x+xoff,y+yoff,"ligh")
             tpt.set_property("life",4,x+xoff,y+yoff)
             tpt.set_property("tmp",math.atan2(-yoff,xoff)/3.14159*180,x+xoff,y+yoff)
             tpt.set_property("tmp2",1,x+xoff,y+yoff)
          end
          if tpt.get_property("type",x-xoff,y-yoff)==0 then
             tpt.create(x-xoff,y-yoff,"ligh")
             tpt.set_property("life",4,x-xoff,y-yoff)
             tpt.set_property("tmp",math.atan2(yoff,-xoff)/3.14159*180,x-xoff,y-yoff)
             tpt.set_property("tmp2",1,x-xoff,y-yoff)
          end
       end
       if tpt.get_property("life",i)==1 then
       for yoff=-38,38 do
          for xoff=-math.sqrt((38^2)-(yoff^2)),math.sqrt((38^2)-(yoff^2)) do
             if (x+xoff)>3 and (x+xoff)<608 and (y+yoff)>3 and (y+yoff)<380 then
                if tpt.get_property("type",x+xoff,y+yoff)==0 then
                   tpt.create(x+xoff,y+yoff,"plsm")
                   tpt.set_property("life",30,x+xoff,y+yoff)
                   tpt.set_pressure((x+xoff)/4,(y+yoff)/4,1,1,10)
                end
             end
          end
       end
       tpt.delete(i)
    end
    end
  • Dawgie
    28th Mar 2012 Member 0 Permalink
    @boxmein
    My favorite adds a menu at the bottom that let you set ctype tmp ect. before you place the element
    @mniip
    Sorry i had forgotten who posted this script originally
  • mniip
    28th Mar 2012 Developer 1 Permalink
    No, that is mine setProp(or something like that), anyways there are just a few topics in lua section, its easy to find out. Btw i dont have scripts in autorun, i just have links to them.
    Currently my autorun contains only one line,
    dofile("tptos.lua")
    for more info http://github.com/mniip/TPTOS
  • jenn4
    28th Mar 2012 Member 0 Permalink
    My autorun.lua:


    No need for it. You may download scripts if you need them separately, but otherwise they just slow down TPT and whole machine even more.
  • billion57
    9th May 2012 Member 0 Permalink
    @mniip (View Post)
    The setProp script is really awesome!