Check part's ID?

  • RedVelvetCake
    31st Jul 2017 Member 0 Permalink

    Im making an element that disolves other elements simular to ACID but it keeps disolving itself. I want to check the ID of each particle before desolving it to make sure it isnt the same as its own ID.

     

    How would i get the ID of an element?

  • jacob1
    31st Jul 2017 Developer 0 Permalink
    It's passed into the update function (first argument I think, but I haven't checked)

    Usually people just call it "i"
  • RedVelvetCake
    31st Jul 2017 Member 0 Permalink

    No i mean how do i get the element ID of a part by its index.

  • Alexwall
    31st Jul 2017 Member 0 Permalink

    When you allocate the element like
    local MYELEMENT = elements.allocate("MYELEMENT ", "MELE") you use the first 2 so just
    elements.MYELEMENT_PT_MELE

  • RedVelvetCake
    31st Jul 2017 Member 0 Permalink

    i want to delete all elements near my element

    for k, v in pairs(sim.partNeighbours(x, y, 1)) do
      if not getelementtype(v) == vdfl then
        sim.partKill(v)
      end
    end

    replace getelementtype(v) with the command

    i want to input a specific pixel and it spit out what element that pixel is.

    Edited 2 times by RedVelvetCake. Last: 31st Jul 2017
  • DanielGalrito
    31st Jul 2017 Member 0 Permalink

    if sim.partProperty(k, "type") ~= vdfl then

  • RedVelvetCake
    31st Jul 2017 Member 0 Permalink

    for k, v in pairs(sim.partNeighbours(x, y, 1)) do
       if sim.partProperty(k, "type") ~= vdfl then
          sim.partKill(v)
       end
    end

    this is my code now. but now the element isnt destroying itself but its not destroying anything :/

  • ssccsscc
    31st Jul 2017 Member 0 Permalink

    @RedVelvetCake (View Post)

    sim.partProperty(k, "type")
    Replace "k" with "v"