Show object description on custom command

RodionGork
22 Aug 2016, 06:26

Friends, Hi!

I can use look at and examine predefined commands to see the object's description (which I carefully type in the text editor when creating object). However this won't work with simple look.

I want to add look #object# command which does the same. I think it should call script. However I failed to find out what to write in the script. So far I've tried

msg(object.description)

But it was a wrong guess. Can please anyone guide me for I'm completely novice to Quest and regretfully could not find such info with search (probably I'm using wrong keywords).

Thanks in advance,
Rodion


The Pixie
22 Aug 2016, 08:48

It is the "look" attribute you need to use:

msg(object.look)

Rooms use "description", items use "look". To cover all eventualities, you would be better using this (which I have just copied from the LOOK AT command):

if (GetBoolean(object, "hidechildren")) {
  object.hidechildren = false
}
if (TypeOf(object, "look") = "script") {
  do (object, "look")
}
else {
  lookdesc = ""
  if (HasString(object, "look")) {
    lookdesc = object.look
  }
  if (LengthOf(lookdesc) = 0) {
    lookdesc = Template("DefaultObjectDescription")
  }
  if (GetBoolean(object, "switchedon")) {
    if (HasString(object, "switchedondesc")) {
      lookdesc = lookdesc + " " + object.switchedondesc
    }
  }
  else {
    if (HasString(object, "switchedoffdesc")) {
      lookdesc = lookdesc + " " + object.switchedoffdesc
    }
  }
  isDark = CheckDarkness()
  if (isDark and not GetBoolean(object, "lightsource")) {
    lookdesc = DynamicTemplate("LookAtDarkness", object)
  }
  msg (lookdesc)
}
ListObjectContents (object)

RodionGork
22 Aug 2016, 13:53

Thanks a lot, verily that works!

By the way, where you were able to see the source of "look at" command? For me it is not shown anywhere... Though perhaps it is because I use web-version?

UPD: and is there any way to just call the "Look At" command? I've tried hopelessly

LookAt()

but surely this do not work :)


The Pixie
22 Aug 2016, 15:02

No, you cannot on the web version. For the off-line version, there is an option at the bottom left to see all library elements.

There is no LookAt command or equivalent. You can invoke commands with HandleSingleCommand, so this might work (and if it does, would be a neater way to do it):

HandleSingleCommand("look at " + object)

RodionGork
22 Aug 2016, 15:11

Ah, greath! Thanks once more - for some reason I've failed to look for it among "Functions". The only correction is I need "name" attribute I guess:

HandleSingleCommand("look at " + object.name)

this really work, thanks once more!