sticky element

  • Hecker
    9th Nov 2021 Member 0 Permalink

    is it possible to make an element sticky? like sticks to other particals??

  • IEATDIRT
    10th Nov 2021 Member 0 Permalink

    like GEL?

  • Hecker
    10th Nov 2021 Member 0 Permalink
  • thepowderizer1337
    11th Nov 2021 Member 1 Permalink

    if your modding, try to go in the code of powder toy and copy gel's code and then paste it and make some changes so it has the same thing as gel but it has a different name, a different color and whatnot

  • Hecker
    13th Nov 2021 Member 0 Permalink

    @thepowderizer1337   it's lua, but thanks.

  • leandroczbr
    19th Jan 2022 Member 0 Permalink

    @thepowderizer1337 (View Post)

     How do I get the gel code?

  • leandroczbr
    20th Jan 2022 Member 0 Permalink

    @ArolaunTech (View Post)

     thanks but is possible to turn the code into lua code?

  • Hecker
    20th Jan 2022 Member 0 Permalink

    @ArolaunTech (View Post)

     if I were to check if this partical was not touching any other partical then It's selve, and freeze it if not. how would I do that or would I have to loop through every partical execpt for this? or is this a better way?

  • ArolaunTech
    21st Jan 2022 Member 0 Permalink

    @Hecker

    The update function is something like this:

     

    local function update(i, x, y, s, nt)

    some code here... do whatever you want.

    end

     

    There are two arguments here that can help you: "s" and "nt". "s" is surround_space, it tells the update function how many empty spaces there are around a particle. Minimum is 0 (the particle is completely surrounded by other particles) and the maximum is 8 (the particle is alone). "nt" is the number of spaces around a particle that are not occupied by the same element. This includes empty spaces, so nt is always greater than or equal to s.

     

    For example, if a GOLD particle was surrounded by these particles:

     

    [INSL][NONE][INSL]

    [GOLD][*GOLD][GOLD]

    [INSL][INSL][INSL]

     

    then nt would be 6 (5 particles of INSL and one empty space) and s would be 1 (one empty space).

     

    So nt - s would be the number of spaces around a particle that are occupied by different particles. In your example:

     

    if nt - s > 0 then

    freeze

    else

    act like a liquid

    end