string list.contains()

Mmaarten
09 Apr 2020, 17:05

is there a way to use a .contains(String) function on a string list attached to an attribute?


mrangel
10 Apr 2020, 01:08

You want the ListContains (list, item) function.

For example:

if (ListContains (object.displayverbs, "Drop")) {

(I used displayverbs for the example just because it's the most commonly used stringlist attribute)


Mmaarten
10 Apr 2020, 08:45

Thanks! Is there a reference guide with all built in functions? I keep bumping into basic stuff like this that I could esily solve in any "real" language :P


mrangel
10 Apr 2020, 10:39

Functions (both built-in and included in the Core library): [link]
Script commands and language constructs: [link]


Mmaarten
10 Apr 2020, 12:36

That is the best answer I have ever seen <3


hegemonkhan
12 Apr 2020, 17:52

(filler for getting my edited post, updated/posted)


more useful links (well, pages, as its the same doc site, lol):

https://docs.textadventures.co.uk/quest (main doc site page)

https://docs.textadventures.co.uk/quest/#Tutorial (quest tutorial)

https://docs.textadventures.co.uk/quest/aslx.html (aslx file format syntax)

https://docs.textadventures.co.uk/quest/scripts/setting_variables.html (VARIABLE syntax in-code for quest)

https://docs.textadventures.co.uk/quest/asl_requirements.html (the quest engine's required stuff)

https://docs.textadventures.co.uk/quest/using_libraries.html (library file usage)

https://docs.textadventures.co.uk/quest/elements/ (ELEMENTS: these are the OBJECTS of its Object-Oriented Programming, at least at the user-level, anyways. Do NOT confuse the ELEMENTS with the in-game/sub 'Object' ELEMENT)

https://docs.textadventures.co.uk/quest/types/ (Data Types)

https://docs.textadventures.co.uk/quest/null.html (the 'null' Data Type info)

https://docs.textadventures.co.uk/quest/elements/game.html (the special and required 'game' Object: publishing info, game-wide settings/controls, the special 'start' script, and etc other special stuff)

https://docs.textadventures.co.uk/quest/elements/object.html (all the built-in Attributes of the 'Object' ELEMENT, including at the very bottom, the built-in: Object Types / Types / Inherited Attributes / Groups-Classes, for in-game/user-level usage, anyways)

https://docs.textadventures.co.uk/quest/using_inherited_types.html (Object Types / Types / Inherited Attributes / Groups-Classes, for in-game/user-level usage, anyways)

https://docs.textadventures.co.uk/quest/scripts/ (the built-in Script/Functions)

https://docs.textadventures.co.uk/quest/functions/ (the built-in Functions, categorical order)
https://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (the built-in Functions, alphabetical order)

https://docs.textadventures.co.uk/quest/using_lists.html (using list/arrays)
https://docs.textadventures.co.uk/quest/using_dictionaries.html (using dictionaries)

https://docs.textadventures.co.uk/quest/display_verbs.html (using displayverbs/inventoryverbs)

https://docs.textadventures.co.uk/quest/character_creation.html (character creation guide: getting user input, using lists/arrays, showing menus, using attributes, etc)

https://docs.textadventures.co.uk/quest/functions/#scope (scope/list-returning functions)

https://docs.textadventures.co.uk/quest/functions/#string (string manipulation functions)


quest has only two ways of getting typed-in inputs during game play:

  1. the 'get input' Script/Function ( https://docs.textadventures.co.uk/quest/scripts/get_input.html )
  2. the 'Command' ELEMENT ( https://docs.textadventures.co.uk/quest/elements/command.html )

you can also use menus (user selection from choices/options):

important:

capitolized menu functions are done as in-text menus (as clickable blue hyperlinks in the big text box on the left side)
VS
non-capitolized menu functions are done as a popup window menu

  1. the 'show menu / ShowMenu' Functions ( https://docs.textadventures.co.uk/quest/scripts/show_menu.html and https://docs.textadventures.co.uk/quest/functions/showmenu.html)

  2. the 'ask / Ask' (yes:true/no:false) menu function ( https://docs.textadventures.co.uk/quest/scripts/ask.html )

and there's probably a few more menu functions that I'm forgetting... meh


there's also lots of guides on the doc site as well as on pixie's quest github page/s too, and there's some tutorial/teaching games made by some people (XanMag and maybe some others), and also some utube tutorial/teaching videos as well by some people (forgot who/name, argh, my apologies)


for looping:

  1. the 'for' Function ( https://docs.textadventures.co.uk/quest/scripts/for.html )
  2. the 'foreach' Function ( https://docs.textadventures.co.uk/quest/scripts/foreach.html )
  3. the 'while' Function ( https://docs.textadventures.co.uk/quest/scripts/while.html )
  4. script call-back / "tail-end recursion" (the 'do' and 'invoke' Functions, or just using, if using a function, the function's name and parameters in-code directly)

there's no 'do-while' Function in quest (as far as I know)


very useful functions:

  1. the 'GetXXX' functions (checking if Object has the specified Attribute and value, returns value or false)

  2. the 'HasXXX' and the 'DoesInherit' functions (checking if Object has the specified Attribute, returns true/false)

  3. the 'AllXXX'functions (returns Object Lists/Arrays)

  4. the 'IsXXX' and the 'TypeOf' functions (checking Data Type functions, returns true/false)

  5. the 'ToXXX' functions (Data Type conversion functions)

  6. the 'Contains', 'Got', 'GetObject', and 'HasObject' functions (for Objects)

  7. the 'ListContains' and 'DictionaryContains' functions (for Lists/Dictionaries)