Newbie: Syntax issue with objects?

tbworld
17 Sept 2016, 07:37

Hi,
I'm very new to quest but i have quite a bit of experience with similar languages and I have a feeling i merely need syntax help.
I've written a command. In the pattern box i wrote [throw #object#]. And the script I wrote says [msg("You threw the " + object + " across the room")]

When I type [throw rock] in game
The output reads "You threw the Object: rock across the room"
How do I make it merely say "You threw the rock across the room"?

Thanks in advance, sorry for such an easy question
Tbworld


DavyB
17 Sept 2016, 11:29

Use 'object.name' or 'object.alias' as appropriate.


tbworld
17 Sept 2016, 15:44

Perfect! thanks so much. Its always the little things that make you spend hours getting no where :)


hegemonkhan
17 Sept 2016, 20:17

the #object# argument/parameter is a pointer/reference to that Object that you'll type in, so you don't want to use it ('object') in a message (as it returns the Object itself, which is displayed as you've seen, 'Object: NAME_OF_OBJECT', already), instead you want to get that Object's Attribute/s (such as it's 'alias' or 'name/ID' Attributes), which is done via dot/period notation:

NAME_OF_OBJECT.NAME_OF_ATTRIBUTE


msg (object) ---> Object: NAME(ID)_OF_OBJECT
msg (object.name) ---> NAME(ID)_OF_OBJECT


<object name="ball">
  <attr name="alias" type="string">red ball</attr>
</object>

// you type in:
// blah ball

<command name="whatever_command">
  <pattern>blah #object#</pattern>
  <script>
    // msg (object)
    // output:
    // Object: ball
    //
    // msg (object.name)
    // output:
    // ball
    //
    // msg (object.alias)
    // output:
    // red ball
  </script>
</command>