- This topic has 16 replies, 4 voices, and was last updated 5 years, 6 months ago by
Yuri Kovelenov.
-
AuthorPosts
-
2019-09-19 at 12:15 am #18990
scalare
CustomerHello, continuing with our requests for dynamic functionality here
:
The puzzles provide a way to create a procedure, and after you do it, the procedure is added to the procedures tab for you to select and drag to call it whenever you need. However, if you have many different procedures, and you need to call them based on a parameter received from outside the viewport (via javascript) there is no dynamic way to call it. Let’s say you have a variable that you set with the name of a procedure. There is no way to call that procedure using that variable name. You have to ask for the variable value, and call the corresponding procedure using one of the pre-defined calls from the procedure tab.
Would a dynamic call make sense like it did for the dynamic parameters for sounds, textures for the replace texture and values for set value puzzles?
Thank you! :)
2019-09-19 at 6:16 am #18995Yuri Kovelenov
Staff2019-09-19 at 9:49 am #18999scalare
CustomerYes, of course, but if you have aa long list of procedures that could be needed to call, you end up with a very ugly and long if-elseif block, and if you have to add procedures at some point, you also need to edit the if-elseif block. If you could call the desired procedure by just using a variable name, things would be much easier and clean.
Think of the procedure call puzzle, but where it accepts a text literal, or a variable.2019-09-19 at 11:59 am #19005scalare
CustomerParameters for the procedures could also be dynamic. So, for example, if a procedure accepts 3 parameters, but another one accepts 5 parameters, we could just pass a list that we setup before the dynamic call.
2019-09-19 at 12:51 pm #19009Yuri Kovelenov
Staff2019-09-19 at 12:55 pm #19012scalare
CustomerThank you, Yuri! :)
2019-09-19 at 6:58 pm #19026jem
CustomerThis is an interesting feature request, but I was wondering if I could make this work today in 2.14? We could write a simple dispatching function in the ExternalInterface. It would take two arguments, the name of the function to be called and the arguments to pass on to that function. It would look something like this:
app.ExternalInterface.procedureCaller = function(procName, argsString) { app.ExternalInterface[procName](JSON.parse(argsString)); }
For example, you could call it like this:
app.ExternalInterface.procedureCaller("myProcedure1","{'color':'red', 'shape':'sphere'}");
…but this does not work for ordinary procedure puzzles because their code is inside a closure and it is not accessible. However, this does work well for the “when called from JS as..” puzzle because those functions are published to the ExternalInterface.
I can use this technique if I make a wrapper for each of my procedure puzzles. The wrapper is a “when called from JS as..” puzzle and it calls the procedure puzzle (see screenshot). This is a little ugly, but it does work. If there is a way to access the ordinary procedure puzzles from the ExternalInterface we could avoid this two-step.
…and I used a JSON string argument to deal with the variable quantity of arguments that scalare mentioned in his post.
Jeremy Wernick
2019-09-20 at 7:03 am #19053Yuri Kovelenov
Staff2019-09-20 at 11:39 am #19058scalare
CustomerExcellent Yuri, thank you! And thank you, jem. Your suggestion gave us an idea that we will test and see if we can make it work with the rest of what we’ve developed.
2019-09-21 at 12:55 am #19085GLiFTeK
CustomerHi,
Something like this is possible now with logic puzzles. Is it what you’re looking for?
would this be used in a Time “every frame do” puzzle or a Loops “repeat while” puzzle so that the if then is “waiting” for the “procedure” variable to change to something acceptable?
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2019-09-21 at 8:30 am #19086Yuri Kovelenov
Staffwould this be used in a Time “every frame do” puzzle or a Loops “repeat while” puzzle so that the if then is “waiting” for the “procedure” variable to change to something acceptable?
Yes, you can possibly use that if-else structure inside every frame puzzle, because it is asynchronous. However, this would likely produce an infinite loop with repeat while, which is not.
2019-10-01 at 1:32 pm #19649Yuri Kovelenov
Staff2019-10-01 at 1:35 pm #19650scalare
CustomerThat’s great, Yuri, thank you! How do we have to call them? Any examples? And how do we pass parameters?
2019-10-01 at 1:46 pm #19655Yuri Kovelenov
Staff2019-10-01 at 2:02 pm #19658scalare
CustomerExcellent, thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.