List of stuff that goes in expressions.

CheeseMyBaby
30 Apr 2018, 21:08

Ok, I'm super tired. I'll try to make sense but I'm afraid I'll fail horribly.

So this."Bla bla " + object.article + " blaaaah!"

Is there a list with stuff like the object.article and other stuff that can go in an expression available?
A list that also explains what it means?

I've been playing around with expressions but constantly find myself unsure of what I should type to make what I want to happen... happen.

I've been searching for such a list but without luck.


K.V.
30 Apr 2018, 21:12

You probably just need to know which attribute you want.

http://docs.textadventures.co.uk/quest/attributes.html

Note that they are listed on that main page with the first letter capitalized, but Quest is case-sensitive and every letter in an attribute is usually lower case.


Another good trick is opening the debugger during a game and checking everything out:

image


K.V.
30 Apr 2018, 21:20

You can also use GetAttributeNames to list all the attributes for an object.

// Using True for the second parameter lists ALL attributes, even inherited, unused attributes.
list = GetAttributeNames(game.pov, true)
msg ("Attributes for the player object:")
DisplayList(list, true)

View the list:

Attributes for the player object:

  1. name
  2. elementtype
  3. type
  4. parent
  5. external_gender
  6. external_article
  7. pov_alt
  8. pov_used
  9. alias
  10. alt
  11. look
  12. gender
  13. article
  14. feature_player
  15. visible
  16. displayverbs
  17. inventoryverbs
  18. take
  19. use
  20. givesingle
  21. drop
  22. possessive
  23. wornmodifier
  24. isopen
  25. open
  26. close
  27. container
  28. descprefix
  29. objectslistprefix
  30. exitslistprefix
  31. contentsprefix
  32. description
  33. implementation_notes
  34. scenery
  35. hidechildren
  36. listchildren
  37. usedefaultprefix
  38. volume
  39. price
  40. dark
  41. lightstrength
  42. darklevel
  43. grid_width
  44. grid_length
  45. grid_fill
  46. grid_border
  47. grid_borderwidth
  48. grid_bordersides
  49. grid_render
  50. grid_label
  51. grid_label_colour
  52. grid_parent_offset_auto
  53. grid_parent_offset_x
  54. grid_parent_offset_y
  55. pov_alias
  56. pov_look
  57. pov_gender
  58. pov_article
  59. pov_possessive
  60. feature_usegive
  61. feature_container
  62. feature_switchable
  63. feature_edible
  64. feature_lightdark
  65. visited
  66. hasbeenmoved
  67. timesexamined
  68. not_all
  69. changedparent
  70. changedisopen
  71. changedlocked
  72. changedswitchedon

If you were really crazy, you could print off every attribute for every object in the game, with the value.

foreach (o, AllObjects()) {
  msg ("<hr/>Attributes for "+ GetDisplayName(o)+":")
  list = GetAttributeNames(o, true)
  foreach (att, list) {
    if (HasAttribute(o,att)) {
      msg (att + ": " + GetAttribute(o,att))
    }
  }
}

View the results of one object (the stick):

Attributes for a stick:
name: stick
elementtype: object
type: object
parent: Game: game
take: True
feature_usegive: True
givesingle: True
look: Script: msg ("You see nothing special about "+this.article+".")
giveto: Dictionary: Ralph = Script: JS.console.log ("Running the 'giveto' script':")msg ("You give "+this.article+" to Ralph.")JS.console.log (this)
generatedverbslist: List:
visible: True
displayverbs: List: Look at; Take;
inventoryverbs: List: Look at; Use; Drop;
use: False
drop: True
gender: it
article: it
possessive: its
wornmodifier: worn
isopen: False
open: False
close: False
container: False
descprefix: You are in
objectslistprefix: You can see
exitslistprefix: You can go
contentsprefix: containing
description:
implementation_notes:
scenery: False
hidechildren: False
listchildren: False
usedefaultprefix: True
volume: 0
price: 0
dark: False
lightstrength:
darklevel: False
grid_width: 1
grid_length: 1
grid_fill: White
grid_border: Black
grid_borderwidth: 1
grid_bordersides: 15
grid_render: False
grid_label:
grid_label_colour: Black
grid_parent_offset_auto: True
grid_parent_offset_x: 0
grid_parent_offset_y: 0
pov_alias: me
pov_alt: List: me; myself; self;
pov_look: Looking good.
pov_gender: you
pov_article: yourself
pov_possessive: your
feature_container: False
feature_switchable: False
feature_edible: False
feature_player: False
feature_lightdark: False
visited: False
hasbeenmoved: False
timesexamined: 0
not_all: False
changedparent: Script: if (game.pov = this) { if (IsDefined("oldvalue")) { OnEnterRoom(oldvalue) } else { OnEnterRoom(null) } if (game.gridmap) { MergePOVCoordinates } }
changedisopen: Script: if (this.isopen and HasScript(this, "onopen")) { do (this, "onopen") }if (not this.isopen and HasScript(this, "onclose")) { do (this, "onclose") }
changedlocked: Script: if (this.locked and HasScript(this, "onlock")) { do (this, "onlock") }if (not this.locked and HasScript(this, "onunlock")) { do (this, "onunlock") }
changedswitchedon: Script: if (this.switchedon and HasScript(this, "onswitchon")) { do (this, "onswitchon") }if (not this.switchedon and HasScript(this, "onswitchoff")) { do (this, "onswitchoff") }


CheeseMyBaby
30 Apr 2018, 21:55

Indeed you're right, like always =)
One more question.
If I do this

"You throw " + this.name + " in the dumpster."

... and this.name refers to a guitar the result would be:

You throw guitar in the dumpster.

Is there an easy way to get the prefix into the string so that it prints "You throw the guitar in the dumpster"?


K.V.
30 Apr 2018, 21:56

This may be helpful, too:

list = Split("Fred;Barney;Wilma;Betty")
this = PickOneString(list)
create (this, "npc_type")
this = GetObject(this)
this.parent = game.pov.parent
if ((this.name = "Fred") or this.name = "Barney") {
  this.article = "him"
  this.gender = "he" 
  this.possessive = "his"
}
else {
  this.article = "her"
  this.gender = "she"
  this.possessive = "hers"
}
this.look = CapFirst(this.gender)+" looks just like the character from The Flinstones!"
this.takemsg = "You can't take "+this.article+"."
this.speak => {
  msg (CapFirst(this.gender)+" ignores you.")
}

K.V.
30 Apr 2018, 22:01
msg ("You throw " + GetDisplayName(this) + " in the dumpster.")

The (minor) issue:

Your guitar's prefix is probably "a". It definitely is if you are using the default prefix (guitar.usedefaultprefix). So, this will print:

"You throw a guitar in the dumpster."

If you uncheck "use default prefix", it will just say "guitar" (not "a guitar" or "the guitar") when it prints something concerning the guitar.

This is what I do (and it's dirty):

msg ("You throw " + Replace(GetDisplayName(this), "a ", "the ") + " in the dumpster.")

CheeseMyBaby
30 Apr 2018, 22:11

Dirty or not, it works!

Thanks a lot!


hegemonkhan
30 Apr 2018, 23:55

KV has already covered and explained/help with most of this stuff, so this is just additional info/comments by me


here's most/all of an Object's built-in Attributes:

http://docs.textadventures.co.uk/quest/elements/object.html

and here's most/all of the special 'game' Object's built-in Attributes:

http://docs.textadventures.co.uk/quest/elements/game.html

these two links above are found within this link's location:

http://docs.textadventures.co.uk/quest/elements/


there's global/game-wide controls/options (Attributes, and Object Types and their Inherited Attributes) for prefix/suffix/etc within the special 'game' Object (in the GUI/Editor and/or using its built-in Attributes directly in code/scripting yourself)


also, you can set the prefix/suffix/etc on individual Objects as well within the GUI/Editor and/or via code/scripting yourself


and there's many other methods as well via scripting, such as string+concatenation usage


The Pixie
01 May 2018, 06:49

This is what I do (and it's dirty):

msg ("You throw " + Replace(GetDisplayName(this), "a ", "the ") + " in the dumpster.")

If the object is an apple, the p[refix will (hopefully) be "an"...


CheeseMyBaby
01 May 2018, 08:53

here's most/all of an Object's built-in Attributes:
and here's most/all of the special 'game' Object's built-in Attributes:
these two links above are found within this link's location:

Thanks HK!
I guess the problem (well, ONE of the problems) with me is that I don't really know what to ask for.
"An object's built-in attributes" etc. I'd never think to ask for that xD
I've seen the pages you linked before but there's so many of them and when I'm looking for something specific most (highly informative!) pages like that blur and I'm just dumbfounded.

@K.V, HK, Pix, mrangel
I've always learned best when someone explains something to me (not by just reading about it), hence all my questions here on the forum.
And seriously, you guys, you've been a tremendous help!
If the Quest world had Oscar's you should all get them. Truckloads of them!
Thanks!


mrangel
01 May 2018, 09:17

I prefer something like (off the top of my head):

<function name="GetDefiniteArticle" parameters="object">
  if (game.enablehyperlinks) {
    result = "{object:"+object.name+"}"
  }
  else {
    result = GetDisplayAlias (object)
  }
  if (not result = GetDisplayName(object)) {
    result = "the "+result
  }
  return (result)
</function>

That way, even for other possible prefixes (like "some", or "your") it gets replaced with "the". The only case where it doesn't add "the" is where the prefix is blank. In the test cases I can think of, that reads more naturally.
(if the prefix is "some", the Dumpster statement sounds better to me with "the". In the "your" example, I think it works either way)


The Pixie
01 May 2018, 14:51

I guess the problem (well, ONE of the problems) with me is that I don't really know what to ask for.

There is a more general problem that it is not obvious where this should be documented even.


K.V.
01 May 2018, 14:58

Stolen!

I changed the name to GetTheDisplayName, though. (I hope you don't mind.)