help with register_keypress

  • ivel236
    20th Jul 2016 Member 0 Permalink
    Nevermind... I think I understand it now. Sorry for making a pointless thread, if any admins want to delete it then go ahead.
    Anyway here's a little script that can help you make soap worms.
    ============================================================================================
    *UPDATED SCRIPT*

    function keyclicky(a,b,c,d)
    if (a=="p") and (b==112) then
    tpt.set_property("life",99999,"soap")
    tpt.set_property("tmp2",42,"soap")
    tpt.set_property("ctype","stkm","soap")
    tpt.log("WORMIFICATION ACTIVATE!")
    end
    if (toggle~=1) and (toggle~=0) then toggle=0
    elseif (toggle==0) and (a=="a") and (b==97) and (d==1) then toggle=1 tpt.log("Autoworm Enabled")
    elseif (toggle==1) and (a=="a") and (b==97) and (d==1) then toggle=0 tpt.log("Autoworm Disabled")
    end
    if (zooming~=1) and (zooming~=0) then zooming=0
    elseif (zooming==0) and (a=="z") and (b==122) and (d==1) then zooming=1 tpt.log("zoooooom zooooom zooooom!")
    elseif (zooming==1) and (b==122) and (d==2) then zooming=0
    end
    if (newworm~=1) and (newworm~=0) then newworm=0
    elseif (newworm==0) and (a=="o") and (b==111) and (d==1) then newworm=1
    elseif (newworm==1) and (b==111) and (d==2) then newworm=0
    end
    end
    function handlethaterror(reason)
    if (reason~=nil) then tpt.log("ya dun messed up. Reason: "..reason)
    else tpt.log("ya dun messed up and I don't even know how.")
    end
    end
    function autoworm(mousex,mousey,button,state)
    if mousex<612 and mousey<384 then mousex,mousey = sim.adjustCoords(mousex,mousey) end
    if (button==1) and (toggle==1) and (state==1) and (zooming==0) then partID2 = sim.partID(mousex,mousey)
    if (partID2==nil) then tpt.create(mousex,mousey,"soap")
    tpt.set_property("life",99999,mousex,mousey)
    tpt.set_property("tmp2",42,mousex,mousey)
    tpt.set_property("ctype","stkm",mousex,mousey)
    if (tmp==nil) then tmp=sim.partID(mousex,mousey) end
    if (newworm==1) then tmp=sim.partID(mousex,mousey) end
    tpt.set_property("tmp",tmp,mousex,mousey)
    tmp = sim.partID(mousex,mousey)
    elseif (partID2>=0) then currenttmp = tpt.get_property("tmp",partID2)
    if (currenttmp==partID2) then tpt.set_property("tmp",tmp,mousex,mousey)
    else tmp = partID2
    end
    else handlethaterror()
    end
    return false
    end
    end
    tpt.register_mouseclick(autoworm)
    tpt.register_keypress(keyclicky)

    Pressing 'a' key will toggle "worm mode".
    Once "worm mode" is enabled you can hold the 'o' key and click in the drawing area to make a new worm head, any further clicks will build the worm from there unless you o+leftclick again.
    You can also click on an existing particle of soap (or anything else) and that will become the new starting point for the worm.
    You can join two worms together by clicking the existing tail of one worm and then clicking the existing head of another worm.
    Also, pressing 'p' will turn all soap onscreen into ideal worm conditions. (life 9999, ctype stkm. etc...) this is useful if something went wrong and you need to reset the soap.
    Edited 7 times by ivel236. Last: 27th Jul 2016