Getting ctype of certain element in x,y

  • creator_of_fail
    3rd March Member 0 Permalink

    So what I want to do in Lua is find the ctype of an element in terms of x and y.

    I'm trying to use tpt.get_property("ctype",x,y), but that does not work, and sim.partProperty does not work because it uses certain individual parts. Is there a workaround to this, for example finding individual part numbers with x and y of that part?

  • jacob1
    3rd March Developer 1 Permalink
    Rather than tpt.get_property (which you should never use), try a combination of sim.partID and sim.partProperty instead.

    You can get the particle at a position with:
    local r = sim.partID(x, y)
    Then get the ctype with:
    sim.partProperty(r, "ctype")

    There are also two alternatives to sim.partID, sim.pmap(x, y) and sim.photons(x, y) which work exclusively with normal particles and with energy particles, respectively.

    Also ... your tpt.get_property should be working, and the new code I gave you does exactly the same thing. Please use the new version anyway though because tpt.get_property is deprecated in the next version.
    Edited once by jacob1. Last: 3rd March
  • creator_of_fail
    3rd March Member 0 Permalink

    It is working for the rest of it, but just getting the ctype like in my previous post is invalid or something. I will use the partID method though.