Checking if element has property

  • Acute
    18th Nov 2022 Member 0 Permalink

    How could i check wether an element has a property from a collision?

  • username90000
    18th Nov 2022 Member 0 Permalink

    well i dont know what u mean by colision but try press d for see properety
    or if u mean colision with something to detect use sensors

  • Acute
    18th Nov 2022 Member 0 Permalink

    @username90000 (View Post)

     I meant from the source code, when the particle collides with another, I wanted to check if the particle it collided with has a certain property

  • username90000
    18th Nov 2022 Member 0 Permalink

    uh

  • Jakav
    19th Nov 2022 Member 0 Permalink

    In C++, or in Lua?

  • Acute
    19th Nov 2022 Member 0 Permalink
  • Cracker1000
    19th Nov 2022 Member 0 Permalink

    @Acute (View Post)

     There isn't an inbuilt function for detecting collisions like that but you can very easily write your own, something along the lines of if (TYP(r)&& parts[ID(r)].vx !=0) to give a better idea.

    Then you could detect for a special property like .tmp or whatever you want and store it (see how sensor elements do it).

     

    This again is a very basic explaination and will definitely require adjustments as per your need. Feel free to ask for further help.

  • jacob1
    20th Nov 2022 Developer 0 Permalink
    There is a much more correct way to check for particle collisions, which would be to hook into the particle movement logic. Think of elements like VOID, which eats particles that collide with it.

    You can find that logic in try_move here, with some additional special cases in eval_move right above it (such as the aforementioned VOID logic).

    You can get information on the colliding particle with parts[i], all properties such as life,ctype,tmp reside here. If you want properties of the element type as a whole, you can use elements[parts[i].type]. If you give me more specifics I can tell you what exactly to check for.