RE: Lua - prompt and wait for selection?
2021-10-10, 8:22 (This post was last modified: 2021-10-10, 8:22 by David Manley.)
2021-10-10, 8:22 (This post was last modified: 2021-10-10, 8:22 by David Manley.)
(2021-09-25, 18:58)Roland Melkert Wrote: If you, or anyone else, has some additional ideas on api extensions please let me know.
I'm exploring whether I can integrate running an animation as part of running a macro and capturing a user reply to the animation. I've got a simple sample case available for downloading as a zip file from BrickSafe. The zip file contains a LDraw model and its Lua script. Note that this sample is deliberately simple - the longer term aim is for more complex cases but it is easier to use a simple case to pose the following questions.
This is the model in the zip file:
The intention is for the macro to take four selected parts and (for this example), rotate the tan coloured pin, green lift arm and green pin around the tan pin so that the green pin is positioned on the blue axle pin. But I want to be able to give the user a preview of the rotation and the ability to accept or reject the rotation.
The premise I had was that I could create animations to show the consequence of a potential rotation and then prompt the user to accept or reject the rotation.
So here are my challenges;
1) I want to run the animation from within the macro. But I''m not sure the API allows me to do this. I can fake it a bit by using actions (take a look at lines 93-95 in the Lua script) e.g.
Code:
ldc.action('editSes_modeSetAni'):run()
ldc.action('aniMan_play'):run()
2) At the end of the animation, when the animation has been run via the macro (as opposed to being run as an independent animation), if the user accepts the proposed rotation, I'd like to apply the actual rotation to the parts. This is a slight speculation but if I apply the part rotation within the animation's end event, would it be correct to assume that the rotated parts would still be returned to their original position (refer to lines 114 and 115 in the Lua script)? If so, is there a technique to make the rotation "stick" post the end of the animation? If there isn't presently a technique, would you consider adding something (he wrote, waving his hands in the air) to the API to allow suitably designated part transformations within an animation to "stick" after completion of the animation?
Regards,
David