(solved )Function not triggering within an IF statement: Gamebook

Edit: nevermind I found the issue did some testing.

IF counter = 1
Call function

(not the actual code obviously)
however, when that parameter is met, the function simply won't run. In this case was simply a message pop up if another counter was at a certain number. The only solution I had found was to paste the entire function into the If statement instead of simplifying calling the function. I mean it worked but more clutter.

is there a way to have to run the call function or is this the only way to make it run right?


Here are the two main things:

SCRIPT TO CALL A FUNCTION IF 'COUNTER1' IS 0:


if (GetInt(game, "counter1") = 0) {
        call_me            // <-- This calls the function I named "call_me" (see below).
      }

ADD A FUNCTION
(mine is named "call_me")

    msg ("The function has now responded.")  // <-- This line is useless. Just for testing purposes.
    msg ("Counter 2 is currently: {game.counter2}.") // < -- Here's how to print a counter's value.

(Replace counter2 with your counter's name)

If you're running Quest in Windows, paste this entire code in a new game, then flip back to the GUI to check everything out.

If you're using the online editor, I can post some screenshots of what it looks like in the GUI.

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="GamebookCore.aslx" />
  <game name="if then call function">
    <gameid>8f1e3fbd-ab45-44df-8bd9-74469c782b4a</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="Page1">
    <inherit name="scripttext" />
    <description>This is page 1. Type a description here, and then create links to other pages below.</description>
    <options type="stringdictionary">
      <item>
        <key>Page2</key>
        <value>This link goes to page 2</value>
      </item>
    </options>
    <script type="script">
      SetCounter ("counter1", 0)
      SetCounter ("counter2", 1)
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Page2">
    <inherit name="script" />
    <description>This is page 2. Type a description here, and then create links to other pages below.</description>
    <script type="script">
      if (GetInt(game, "counter1") = 0) {
        call_me
      }
    </script>
  </object>
  <function name="call_me">
    msg ("The function has now responded.")
    msg ("Counter 2 is currently: {game.counter2}.")
  </function>
</asl>

Nevermind I figure out with some testing.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums