object reference

bergedorfcacher
08 Jul 2016, 05:32

Hi,

under verbs I'm using 'Require another object'. Is there a generic way to get a reference to the second object for this script? I want to call a function there like DoSomething(this,target). While I can fill in the target name each time, just copying the same script would be a bit more convenient. (I will need to do this for nearly all oject combinations, so probably a couple of hundred times!)


Pertex
08 Jul 2016, 06:51

You can import the core function ShowMenuResponse and add this line at the beginning

game.menuobject = option

In your function you can use this attribute then.

 <function name="ShowMenuResponse" parameters="option">
game.menuobject = option
if (game.menucallback = null) {
      error ("Unexpected menu response")
 }
 else {
      parameters = NewStringDictionary()
      dictionary add (parameters, "result", option)
      script = game.menucallback
      ClearMenu
      invoke (script, parameters)
    }
  </function>

hegemonkhan
08 Jul 2016, 06:52

I'm not that knowledgeable on the built-in stuff, so take this with a grain of salt (wait for the more knowledgeable people to respond):

Verbs are Script Attributes of a/an specific/individual Object, so you got only these universal things to use:

the special 'this' keyword/keycommand, which GETS/RETURNS/OUTPUTS the Object containing the Script Attribute (Verb) which you're using 'this' within it. So for example, if I had an 'orc' Object with a 'fight' Script Attribute (a 'fight' Verb), then using 'this' inside of it, would GET/RETURN/OUTPUT the 'orc' Object.

and you can always use the 'game.pov' (your currently controlled Player Object) too within any scripting.

Lastly, if you can use a specific/individual Object, then you can use that (but obviously this is not any good when you need/want to do dynamic scripting).


I don't think there's any way with the Script Attribute (Verb) itself to reference more Objects, except maybe through using Delegates for your Script Attribute (Verb).

Though, you can always have the scripting reference whatever you want, such as using iterations with whatever Object's List/Dictionary Attributes, and etc methods.


otherwise, you can use Commands, if you need to use more referencing. And I think there's maybe a way to join your Command with a Verb... but I forgot now where I saw it (as this was long ago, probably... one of Pixie's old libraries... I think....), and it was beyond my understanding anyways.


bergedorfcacher
08 Jul 2016, 08:52

@hegemonkhan: Thanks for your thoughts. I', using 'this' all the time, here I was more looking for something like 'that'. :-) I'm slowly learning about the differnce between verbs and commands. Not quite there yet.

@Pertex: Thanks, works like a charm. (After I got across the small hurdle of using GetObject(game.menuobject) instead of game.menuobject.

I'm working with quest now for less than a week and I must say I'm really overwhelmed by the responsiveness and friendlyness in this community!