How can you get the coordinates of the pixels of an element using code (I think its something like tpt.get_property)?
I want to get the coordinates and move a particular element ata time. So, I would like to take the coordinates and add a number to them to move the element's pixels. I don't know if this is possible, nor how I would store the data. Does Lua have lists and would I have to store the x's in 1 list and y's in another?
ELEM is your element.
function ELEM_update(i, x, y, s, n)
tpt.parts[i].vx=XVELOCITY
tpt.parts[i].vy=YVELOCITY
tpt.element_func(ELEM_update, elements.ELEMENT_PT_ELEM,1)
What this should do is set the velocity of your element to XVELOCITY and YVELOCITY. Supposing VX is set to 1, and VY is set to 2, your element will move right 1, and down 2 each frame. I think that may be what you wanted?
Why are you using the legacy API for the update function? This works too:
elements.property(ELEM, "Update", funcUpdate)
local function funcUpdate(i,x,y,s,nt)
(update code here)
end
Is there any advantage to that? I honestly do not know... Anyways, I'm used the legacy, so it's just what came out.
I don't think the new api gives any performance changes, it's really just a matter of preference; if you learned with the old api, you might stay using it for familiarity.