energy particle collision

  • polokus
    27th Sep 2020 Member 0 Permalink

    3 types of energy particle

     

    sim.can_move(elements.POLOKUS_PT_MUON, elements.DEFAULT_PT_IRON, 2)

     

    Line does not allow MUON to pass through IRON.

     

    I was searching for solution on forum,

    Placed after update function. this worked.

    Relief, sigh.

     

    only works for one particle type even though they all only have this same code.

     

    can not figure out why

    continue side project

    Change !!!!ONLY!!!! temperature value. Restart.

    MUON no longer passes through IRON

    what

    put line before code again

    no work

    put line after code again

    no work

    restart

    no work

    watch self turn into monkey showing palms

    add question to engineer

    ...

    receive answer and bathed in particles mankind has yet to name?

    :-)

     

    GUESS WHO JUST DISCOVERED A NEW ELEMENT!!!

    also its like 3am and I have psychosis so Im sorry if I don't sound like a real person and thank you for reading

     

    P.S. when i restarted the muon had moved in the menu

    Edited 2 times by polokus. Last: 27th Sep 2020
  • jacob1
    27th Sep 2020 Developer 0 Permalink
    Can you post the code that is causing you trouble? Just one line isn't enough to figure out the problem.
  • polokus
    27th Sep 2020 Member 0 Permalink

    local glocton = elements.allocate("POLOKUS", "GLOC")
    elements.element(elements.DEFAULT_PT_PROT)
    elem.property(elem.POLOKUS_PT_GLOC, "Name", "GLOC")
    elem.property(elem.POLOKUS_PT_GLOC, "Colour", 0x185915)
    elem.property(elem.POLOKUS_PT_GLOC, "Description", "Glocton.")
    elem.property(elem.POLOKUS_PT_GLOC, "Collision", -1)
    elem.property(elem.POLOKUS_PT_GLOC, "Weight", -1)
    elem.property(elem.POLOKUS_PT_GLOC, "HeatConduct", 0)
    elem.property(elem.POLOKUS_PT_GLOC, "Properties", elem.TYPE_ENERGY+elem.PROP_NEUTPASS+elem.PROP_LIFE_DEC)
    elem.property(elem.POLOKUS_PT_GLOC, "MenuSection", elem.SC_NUCLEAR)
    elem.property(elem.POLOKUS_PT_GLOC, "MenuVisible", 1)
    tpt.element_func(NU, tpt.element('GLOC'))
    local function GLOCUpdate(i,x,y,s,n)

    --insert update function

    tpt.element_func(GLOC,glocton)
    elem.property(elem.POLOKUS_PT_GLOC, "Update",GLOCUpdate)
    sim.can_move(elements.POLOKUS_PT_GLOC, elements.DEFAULT_PT_IRON, 2)
    sim.can_move(elements.POLOKUS_PT_GLOC, elements.DEFAULT_PT_COAL, 2)
    sim.can_move(elements.POLOKUS_PT_GLOC, elements.DEFAULT_PT_STNE, 2)
    sim.can_move(elements.POLOKUS_PT_GLOC, elements.DEFAULT_PT_CNCT, 2)
    sim.can_move(elements.POLOKUS_PT_GLOC, elements.DEFAULT_PT_SAND, 2)
    sim.can_move(elements.POLOKUS_PT_GLOC, elements.DEFAULT_PT_PQRT, 2)
    sim.can_move(elements.POLOKUS_PT_GLOC, elements.DEFAULT_PT_BRMT, 2)

    For some reason, collision set to 0.99 fixes it, but then sometimes it doesn't work.

    The other energy particles have the same code - sometimes only one of them or two of them work.

    I really want to say I've been stupid and forgot to set Collision to 0.99, but I had this same problem many times before, which is why none of my elements do care to interact as such. Is there anything I might have missed?

     

    For looking, thanks!

    Edited 3 times by polokus. Last: 27th Sep 2020
  • LBPHacker
    27th Sep 2020 Developer 0 Permalink
    I've looked into why this happens, and it turns out that setting element properties invokes init_can_move, which resets the can_move table completely. This sort of makes sense, because there's code in init_can_move that sets up sane default values based on basic element properties. You can of course leave all your can_move settings for last, but then another script might come along, set a few element properties, and nuke can_move again. The only good solution to this problem is buffering can_move settings per element.

    tl;dr design flaw, not fixable from Lua. You'll have to wait for the next version, or a snapshot at best :(
    Edited once by LBPHacker. Last: 27th Sep 2020
  • polokus
    27th Sep 2020 Member 0 Permalink

    @LBPHacker (View Post)

     Yayy, I discovered something actually broken, this time, it wasn't me!

    Thanks for the answer. I'm wonder how often you must work on element interactions to not notice this.

  • LBPHacker
    27th Sep 2020 Developer 0 Permalink
    It's pretty obvious when you work with them, except nobody ever really touches can_move from Lua (and it works fine with default elements).
  • polokus
    27th Sep 2020 Member 0 Permalink

    Do you know any other way I could make particles like PROT in LUA ?

    Edited 3 times by polokus. Last: 27th Sep 2020