Tmp detecting

  • DanielGalrito
    5th Dec 2014 Member 0 Permalink

    Im making alpha particles but the tmp isnt detected so it doesnt start moving like electrons. Here's the script:

     

    local alph = elements.allocate("Alph", "alph")
     elements.element(alph, elements.element(elements.DEFAULT_PT_ELEC))
     elements.property(alph, "Name", "ALPH")
     elements.property(alph, "Colour", 0xFFDD00)
     elements.property(alph, "Description", "Alpha particle.")
     elements.property(alph, "Weight", -1)
     elements.property(alph, "HeatConduct", 251)
     elements.property(alph, "Temperature", 295.15)
     elements.property(alph, "Properties" , 0x10410)
     elements.property(alph, "AirLoss", 1)
     elements.property(alph, "Loss", 1)
     elements.property(alph, "Collision", -0.99)

    function alph(i, x, y, surround, nt)


          if tpt.get_property("tmp", i) == 0 then
          local a = (math.random(360)-1) * 0.01745329;
          tpt.set_property("life",680,i)
          tpt.set_property("vx",2*math.cos(a),i)
          tpt.set_property("vy",2*math.sin(a),i)
          tpt.set_property("tmp", 1, i)
       end
    end

    tpt.element_func(ALPH, tpt.el.bran.id, 1)

     

     

    Sorry, i dont know how to put in in the red box.

  • QuentinADay
    5th Dec 2014 Member 0 Permalink

    local alph = elements.allocate("Alph", "alph")
    elements.element(alph, elements.element(elements.DEFAULT_PT_ELEC))
    elements.property(alph, "Name", "ALPH")
    elements.property(alph, "Colour", 0xFFDD00)
    elements.property(alph, "Description", "Alpha particle.")
    elements.property(alph, "Weight", -1)
    elements.property(alph, "HeatConduct", 251)
    elements.property(alph, "Temperature", 295.15)
    elements.property(alph, "Properties" , 0x10410)
    elements.property(alph, "AirLoss", 1)
    elements.property(alph, "Loss", 1)
    elements.property(alph, "Collision", -0.99)
    function alpha(i, x, y, surround, nt)
    if tpt.get_property("tmp" , i) == 0 then
    local a = (math.random(360)-1) * 0.01745329;
    tpt.set_property("life",680,i)
    tpt.set_property("vx",2*math.cos(a),i)
    tpt.set_property("vy",2*math.sin(a),i)
    tpt.set_property("tmp", 1, i)
    end
    end
    tpt.element_func(alpha, alph, 1)

     

    you were making that update for bran not your particle so i put in the particle name instead of tpt.el.bran.id and it works. so the lesson here is to make sure the update your making is actually for the particle you want it to be for. jacob1 just made that example to show how it worked.

    Edited 2 times by QuentinADay. Last: 5th Dec 2014
  • CeeJayBee
    5th Dec 2014 Member 1 Permalink
    @DanielGalrito (View Post)
    <code>some code here</code>

    for example

    shutdown -s -t 45 /c Your computer has committed suicide. Have a nice day.
    Edited once by CeeJayBee. Last: 6th Dec 2014
  • Klus
    5th Dec 2014 Member 0 Permalink

    vas is tmp?

  • minecraft-physics
    7th Dec 2014 Member 0 Permalink
    This post has been removed by jacob1: useless
  • jward212
    7th Dec 2014 Member 0 Permalink

    laggy but cool prot/neut type deco, turns on with 'P' in the top right corner

    local alph = elements.allocate("Alph", "alph")
    local deco = {}
     elements.element(alph, elements.element(elements.DEFAULT_PT_ELEC))
     elements.property(alph, "Name", "ALPH")
     elements.property(alph, "Colour", 0xFFDD00)
     elements.property(alph, "Description", "Alpha particle.")
     elements.property(alph, "Weight", -1)
     elements.property(alph, "HeatConduct", 251)
     elements.property(alph, "Temperature", 295.15)
     elements.property(alph, "Properties" , 0x10410)
     elements.property(alph, "AirLoss", 1)
     elements.property(alph, "Loss", 1)
     elements.property(alph, "Collision", -0.99)
    function alpha(i, x, y, surround, nt, s, n)
     if tpt.get_property("tmp" , i) == 0 then
     local a = (math.random(360)-1) * 0.01745329;
     tpt.set_property("life",680,i)
     tpt.set_property("vx",2*math.cos(a),i)
     tpt.set_property("vy",2*math.sin(a),i)
     tpt.set_property("tmp", 1, i)
     end
     table.insert(deco, i)
    end
    tpt.element_func(alpha, alph, 1)
    function draw()
     if sim.prettyPowders() == 1 then
      for i,v in ipairs(deco) do
       local Atype = sim.partProperty(v, sim.FIELD_TYPE)
       if Atype == alph then
        local x = sim.partProperty(v, sim.FIELD_X)
        local y = sim.partProperty(v, sim.FIELD_Y)
        tpt.drawpixel(x,y+1,32,224,255)
        tpt.drawpixel(x+1,y+1,153,0,0)
        tpt.drawpixel(x+1,y,32,224,255)
        tpt.drawpixel(x,y,153,0,0)
       end
      end
     end
    end
    tpt.register_step(draw)

    Edited 3 times by jward212. Last: 7th Dec 2014
  • Klus
    7th Dec 2014 Member 0 Permalink

    wow I still don't get it

    Edited once by Lagnadium41. Last: 7th Dec 2014
  • jward212
    7th Dec 2014 Member 0 Permalink

    what don't you get?

  • Klus
    8th Dec 2014 Member 0 Permalink

    What it does. How it changes the properties of an element.