Execute scripts on child objects

Discuss Lemur and share techniques.
Post Reply
bval123
Newbie
Posts:4
Joined:02 Apr 2015 20:22
Execute scripts on child objects

Post by bval123 » 07 Apr 2015 15:30

I have some scripts inside of a container that I'd like to be executed from its parent interface:

Code: Select all

-- Interface
--- ScriptA
--- Container
----- ScriptB
E.g., inside of ScriptA, i'd like to be able to do something like

Code: Select all

Container.ScriptA()
.

Currently I'm handling this pattern by having an expression that I set from the parent, and a script inside that executes "on expression".

Any ideas?

ndivuyo
Regular
Posts:279
Joined:23 May 2014 00:24

Re: Execute scripts on child objects

Post by ndivuyo » 08 Apr 2015 01:16

I'm a little unclear, you want to trigger ScriptA() from inside ScriptA()?? Or did you mistype and meant trigger Container.ScriptB() or...

Maybe your question is different, but if you don't already know: you execute scripts that are set to 'Manual' by just typing their name.
So if ScriptB() was set to execute 'Manual', then in ScriptA() you would just type: Container.ScriptB();
That would execute ScriptB()

Is this your question, or something else?

bval123
Newbie
Posts:4
Joined:02 Apr 2015 20:22

Re: Execute scripts on child objects

Post by bval123 » 08 Apr 2015 13:25

To clarify, and to show whats not working:

Code: Select all

interface
  button
    scriptA()
  container
    expA
    scriptB()
I want to execute scriptB from scriptA (basically, having a button that is a sibling to a container that triggers a script inside that container). This currently doesn't work and gives me a syntax error.

Code: Select all

// inside ScriptA, set to trigger on expression 'x' to serve as a click handler for button

// this works
setexpression(container, 'expA', 1);

// this is a syntax error
container.scriptB();

ndivuyo
Regular
Posts:279
Joined:23 May 2014 00:24

Re: Execute scripts on child objects

Post by ndivuyo » 08 Apr 2015 17:57

Does this example help you? Obviously you would never set things up like I did in my example, but just to show how you manipulate child expressions/scripts. I only use setexpression if I need to use a string name.

(by the way i'll probably delete the attachment after you see it)
Last edited by ndivuyo on 08 Apr 2015 23:31, edited 1 time in total.

bval123
Newbie
Posts:4
Joined:02 Apr 2015 20:22

Re: Execute scripts on child objects

Post by bval123 » 08 Apr 2015 18:16

Thanks for the example, it was more or less the setup I had.

The problem was embarrassingly just a typo in a different part of the template that was causing issues with the call to the script, I've got it working now :)

ndivuyo
Regular
Posts:279
Joined:23 May 2014 00:24

Re: Execute scripts on child objects

Post by ndivuyo » 08 Apr 2015 23:31

ok cool I'm going to delete my attachment to save space

Post Reply