running another object's verb

psymann
04 May 2013, 18:12
Hello all,

Hoping some clever coders can help me again :-S

I have an object "machine" which I can "turn on" - it has "turn on" verb, which runs a script.

I then have an object "power button" which I can "press" - it has a verb called "press".

To save typing in the same code twice, I want to set the "press" verb on the "power button" to: "run the 'turn on' verb of the machine".

Is there a way to do this?

Thanks,

psy

george
04 May 2013, 19:21
hi, I'm new to Quest but I think what you want is a function. The tutorial says,

Functions provide a way for you to set up scripts that can be called from anywhere in your game, so you don't have to keep copying and pasting or re-entering the script.



See http://quest5.net/wiki/More_things_to_d ... _Functions

jaynabonne
04 May 2013, 21:18
Assuming your script attribute is named "turnon", then you'd just do:

do (machine, "turnon")

psymann
04 May 2013, 21:32
Ahaaaa!

I am a dufus. As soon as you said "assuming your attribute is called 'turnon'", I realised...

It is indeed called "turnon". Not "turn on". No wonder it wasn't working!

Turns out I was doing the right thing after all (your 'do' command seems to be the same as the GUI's "Run an object's script attribute" which is what I'd done.

I just can't spell ;-)

Thanks :-)


Thanks also, george - jay's solution is better in this case, but now you're reminded me about functions I should probably see how I can use them more in other ways :-)

psy