That's hacky and a bad idea. I suggest reading about contextsZenonSeth wrote:Ah ok, I see. I wasn't sure about using a mod-global list of names cause I wasn't sure of the access order - e.g. if I store the pos in a table, my form shows, but then another of my form's right click is process before mine, using up the pos. I think just being new to the minetest modding api, and having bad experiences with global tables like that before, made me cautious.Krock wrote: You can do more than just show the formspec in on_rightclick. [snipped]
The approach I 'solved' it with is essentially the same, only i stored the pos in the formspec itself, using:where spos is a comma-separated coord list. Though even if 'hidden' the field can still be edited. A solution that just occured to me is to store the pos in the field name, as in have the name be some known prefix, say fieldNodePos, concatinated with the comma-separated coords. Would probably work, just have to iterate over all fields on the formspec callback.
Code: Select all
"field[-1,-1;0,0;"..fieldNodePos..";;" .. spos .. "]"..
But I mean, if the minetest_game uses the global lookup table to store right clicked position, I should too. Thanks
Remember that a malicious client can modify anything that you send to it, so don't give it the ability to choose a position unless you check that the position is in range in the callback, and always check for permissions in the callback too.