Protons

  • Videogamer555
    1st Jan 2012 Member 1 Permalink
    PRTN collides with stuff and adds a proton to it. As with real atoms more protons = higher "atomic number". In this case that means adding 1 to the "type" property of a pixel. It skips indestructable DMND, CLNE and BCLN (cause I want to be able to clone PRTN without it being itself alterned by PRTN), VOID (which should absorb EVERYTHING), PRTI and PRTO (portals which should "teleport" PRTN rather than be destroyed by it), and of course PRTN itself. By "skip" I mean it adds 2 to the atomic number in order to avoid creating these "skipped" elements, and it adds nothing to them if it strikes them themselves. Or course in atoms when the atomic number is increased it does so by absorbing the proton. Therefore whenever PRTN causes a change of the material type in TPT, the PRTN itself is destroyed in the process. However WATCH OUT for the glitch that happens when it tries to convert the last currently available element of TPT (the one with the highest "type" number) to the next highest one. When this happens the program will literally CRASH! I have yet to figure out how to program it to autodetect the highest possible element number in TPT (in order to stop it from trying to make this glitchy conversion), and I don't myself know what that number is.

    Here's the Lua code to make PRTN out of ELEC.
    tpt.el.elec.heat=295.15
    tpt.el.elec.name="prtn"
    tpt.el.elec.color=0xff8080
    tpt.el.elec.description="1"


    math.randomseed(os.time())
    function prtn_update(i, x, y, s, n)
    xvel=tpt.get_property("vx",x,y)
    yvel=tpt.get_property("vy",x,y)
    currtype=tpt.get_property("type",x+xvel,y+yvel)
    if currtype>0 and (currtype+1)~=tpt.el.elec.id and currtype~=tpt.el.elec.id and (currtype+1)~=tpt.el.clne.id and currtype~=tpt.el.clne.id and (currtype+1)~=tpt.el.bcln.id and currtype~=tpt.el.bcln.id and (currtype+1)~=tpt.el.dmnd.id and currtype~=tpt.el.dmnd.id and (currtype+1)~=tpt.el.void.id and currtype~=tpt.el.void.id and (currtype+1)~=tpt.el.prti.id and currtype~=tpt.el.prti.id and (currtype+1)~=tpt.el.prto.id and currtype~=tpt.el.prto.id then
    tpt.set_property("type",currtype+1,x+xvel,y+yvel)
    tpt.delete(i)
    elseif currtype>0 and (currtype+1)==tpt.el.elec.id and (currtype+1)==tpt.el.clne.id and (currtype+1)==tpt.el.bcln.id and (currtype+1)==tpt.el.dmnd.id and (currtype+1)==tpt.el.void.idand (currtype+1)==tpt.el.prti.id and (currtype+1)==tpt.el.prto.id then
    tpt.set_property("type",currtype+2,x+xvel,y+yvel)
    tpt.delete(i)
    end
    end
    tpt.element_func(prtn_update, tpt.el.elec.id,1)


  • jenn4
    1st Jan 2012 Member 0 Permalink
    The highest element is FIGH with value of 158. After that is NUM woth value of 159 that is reguired for C code, but it's not an element.
  • ads999
    1st Jan 2012 Member 0 Permalink
    @jenn4 (View Post)
    So basically what he needs to do is make it so: If Element ID = 158 then change to Element ID 1. Simple
  • jenn4
    1st Jan 2012 Member 0 Permalink
  • Videogamer555
    1st Jan 2012 Member 0 Permalink

    ads999:

    @jenn4 (View Post)
    So basically what he needs to do is make it so: If Element ID = 158 then change to Element ID 1. Simple

    I said I wanted an autodetect. That is I need code that isn't version dependent so if later upgrades to TPT add new elements then I won't have to reprogram my Lua code every time, because it will look for a variable in TPT that automatically will tell it what the highest number available is. I need to know how to do that auto detect.



    jenn4:

    The highest element is FIGH with value of 158. After that is NUM woth value of 159 that is reguired for C code, but it's not an element.


    Actually it's NOT "num" I just tried using tpt.el.num.id-1 to get the highest valid element number automatically, and it did NOT work. I need to know what the method is to get the highest valid element number automatically.