Login
Remember
IF Answers
Ask a Question

# Empty Function List Appearing in Quest

0 votes
72 views
asked May 31 in Authoring by Rob
retagged May 31 by Dannii

I feel like an idiot, here. I'm unable to access any of the premade functions for Quest. I'm getting a completely blank list when I open the Functions box, and because the game seems to come with numerous functions (as listed in the help docs), I'm perplexed.

I even tried using the function I want

    GetRandomInt (1, 10)

directly in a script, but it just generated an error for me.

- quest
- functions

commented Jun 19 by jaynabonne (141 points)
A note about your example: GetRandomInt is an "expression" function, meaning it is implemented in the expression parser. That's a long-winded (and probably obscure) way of saying that it returns a return value, and you need to assign it to something. I bet that
result = GetRandomInt(1,10)
will work, as it's being used in an assignment expression. Otherwise, Quest will not be able to see it. It's a quirk of Quest, but basically if a built-in function returns a value, you probably need to use it somehow (assign it or check it in an "if" or something).

## 2 Answers

+1 vote
answered Jun 3 by The Pixie (121 points)

Go into code view from the Tools menu. The top four line should look like this (perhaps with different numbers):

    <!--Saved by Quest 5.6.5508.33899-->
    <asl version="550">
      <include ref="English.aslx" />
      <include ref="Core.aslx" />

My guess is that the third and/or fourth lines will be missing. These are what tell Quest what library files to use, and if they are not there, you have none of the built in libraries. Try adding the missing lines and see what happens.

0 votes
answered May 31 by hegemonkhan (161 points)
edited Jun 1 by hegemonkhan

in the GUI~Editor, the 'Functions' is for adding~creating your own~custom Functions, for example (sorry, it's in code, as it's quick for me):

    <function name="sex_function">
      show menu ("Sex?", split ("male;female", ";"), false) {
        player.sex_string_attribute = result
      }
    </function>

Functions are like the GUI~Editor's Verbs in that you can 'add a script' to them, except that they're not tied to an Object, and are much more powerful (can use Parameters and able to return Values).

to use~activate~execute~run~fire a Function, you select this script: 'call function' Script

run as script -> add a~new script -> scripts -> 'call function' Script

and simply type in the Function's Name into the Name text box (Call function: [_____] With Parameters: you can ignore this, don't add any Parameters, until you understand them), to 'call upon~activate~execute~run~fire' the Function.

You almost got the use~syntax of the 'GetRandomInt (min, max)' built-in Function correct, but not quite. It returns an integer (non-decimal number) Value, so by itself, it produces an error. You either have to set it to an Attribute or use it in an Expression.

for example (setting it to an Attribute):

'game' Game Object -> 'Script' Tab -> 'start' script -> add new script -> variables -> 'set a variable or attribute' Script -> (see below)

(if you understand algebraic substitution, then hopefully you can use understand how this is working: y=x, instead of 'y' we're using 'player.strength', and instead of 'x', we're using 'GetRandomInt (1, 10)' )

set variable player.strength [random number] between [number] [1] and [number] [10]

or if you want to be brave and try to code (this is the same as the above):

set variable player.strength [expression] GetRandomInt (1, 10)

or if you want to be really brave, in code view (within your 'start' Script), doing the actual coding (this is the same as above):

player.strength = GetRandomInt (1, 10)

and to see it working:

'game' Game Object -> 'Script' Tab -> 'start' script -> add new script -> output -> 'print a message' Script -> (see below)

Print [expression] "Strength: " + player.strength

or in code (this is the same as above):

msg ("Strength: " + player.strength)

// it should output:
// Strength: #

try out (play) your game, and see it works.

in code, it'll look like this (full game code):

    <asl version="560">
      <include ref="English.aslx" />
      <include ref="Core.aslx" />
      <game name="xxx">
        <gameid>xxx</gameid>
        <version>1.0</version>
        <firstpublished>2015</firstpublished>
        <start type="script">
          player.strength = GetRandomInt (1, 10)
          msg ("Strength: " + player.strength)
        </start>
      </game>
      <object name="room">
        <inherit name="editor_room" />
        <object name="player">
          <inherit name="editor_object" />
          <inherit name="editor_player" />
        </object>
      </object>
    </asl>

here is an example of using a Function instead (using the above full game code):

    <asl version="560">
      <include ref="English.aslx" />
      <include ref="Core.aslx" />
      <game name="xxx">
        <gameid>xxx</gameid>
        <version>1.0</version>
        <firstpublished>2015</firstpublished>
        <start type="script">
          test_function
        </start>
      </game>
      <object name="room">
        <inherit name="editor_room" />
        <object name="player">
          <inherit name="editor_object" />
          <inherit name="editor_player" />
        </object>
      </object>
      <function name="test_function">
        player.strength = GetRandomInt (1, 10)
        msg ("Strength: " + player.strength)
      </function>
    </asl>

I'd recommend going through as much of the entire tutorial as you can:

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

and then try to learn this next:

http://docs.textadventures.co.uk/quest/guides/character_creation.html

as your first steps in learning quest and coding~if concepts (whether or not you want to learn to actual code or not, it's needed for game making).

also, 90% of everything you want to do within your game, uses these two super scripts, so you MUST learn them extremely well and ASAP too:

.1. the 'set a variable or attribute' Script (Attribute usage):

http://forum.textadventures.co.uk/viewtopic.php?f=10&t=5253

.2. the 'if' Script (conditional action~event scripting):

http://forum.textadventures.co.uk/viewtopic.php?f=10&t=5253

then try to study the other guides:

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

as you get a good bit more familiar with quest, its code, and scripting (add a~new script), then the wiki stuff will make more sense and be of use to you, knowing how to properly use it, such as this stuff:

http://docs.textadventures.co.uk/quest/elements/
http://docs.textadventures.co.uk/quest/types/
http://docs.textadventures.co.uk/quest/functions/ (categorical order)
http://docs.textadventures.co.uk/quest/functions/index_allfunctions.html (alphabetical order)
http://docs.textadventures.co.uk/quest/scripts/

and then etc more advanced guides~code~libraries~etc.

P.S.

if you want to see all of the built-in code stuff (such as the built-in Functions), in the lower left corner is:

Filter

Filter -> Show Library Elements -> change it so that it is checked (the 'Show Library Elements is a toggle for hiding~showing the built-in stuff) -> then in the above left side's 'tree of stuff', you will now see a lot of light grey text that wasn't there before, this light grey text is all of the built-in stuff.

## Related questions

- For Quest: Can A Template Return A Function?
- How to restore previous versions in web version of quest.
- How do you center images in Quest?
- How do I use the create exit command properly in Quest
- Help! I need to use a candle as a light source in rooms in my Quest text adventure game

...