Wait times.

Hey! I'm really an amateur with all of this and rather than post tonnes of questions, I'd prefer to keep them isolated to a single thread. I'm working on a gamebook right now that's pretty simple, but of course I have practically no skill in coding and I don't really know where to learn. I also want to thank everyone on this forum for being so patient and great!

My first question:
K.V. (an actual god-send) talked me through how to print text after a period of specified time here:(http://textadventures.co.uk/forum/quest/topic/ni8aqytryeerjxnltzmobq/wait-a-period-of-time), and I was wondering how to apply the same concept to print a link after a period of time. What is the function to do so, and would it fit into this format?:

eval ("setTimeout(function(){addText("This is the delayed message.")}, 3000);")

The above would print "This is the delayed message" in the colour purple after 3000ms (3 seconds). How could I edit this to print a PAGE link instead? I've scoured the web but can't find a fitting function.

Also, on the topic, the "Add page link from ... to ..." function seems to be broken in gamebooks, and not print at all? I've seen the problem crop up on other threads and have encountered it myself, not sure why it is occurring as every suggested fix isn't necessary (i.e: make sure page names are written exactly as they are named, make sure both exist, etc.).


K.V.

Hello,

the "Add page link from ... to ..." function

This is my test code, and it works for me:

AddPageLink (Page1, Page2, "Begin Chapter One : Before The Storm.")

Gamebook Tester

This is page 1. Type a description here, and then create links to other pages below.

Begin Chapter One : Before The Storm.

And this link goes to page 3


After clicking the first link:


Gamebook Tester

This is page 1. Type a description here, and then create links to other pages below.

Begin Chapter One : Before The Storm.

This is page 2. Type a description here, and then create links to other pages below.


Did you rename Page1 or Page2, by any chance? (That's just a shot in the dark.)


The delayed link

  1. Create new function named PrintDelayedLink:

image


Same thing as above, but in FULL Code View:

  <function name="PrintDelayedLink" parameters="link">
    msg ("{page:"+link+":{color:purple:Delayed link to "+link+"}}")
  </function>

Change purple to whatever colour you like. (Pink Floyd fan? I am.)

Change Delayed link to "+link+" to whatever message you'd like for the link, but don't fool around with the }} or problems shall arise.


  1. Add this to your page's script in Code View:

JS.eval ("setTimeout(function(){ASLEvent(\"PrintDelayedLink\", \"page3\")}, 3000);")

Change page3 to whatever the name of your page is.

Change 3000 to whatever you like for the delay.


Here's the entire game's code, just to play around with (You can create a new game, click Code View, paste this over everything that's already there, then exit Code View):

>Click here for the code.
<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="GamebookCore.aslx" />
  <game name="Gamebook Tester">
    <gameid>e8dd5758-0ab6-4f1b-a024-875e9ebc5e56</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="Page1">
    <inherit name="scripttext" />
    <description><![CDATA[This is page 1. Type a description here, and then create links to other pages below.<br/><br/>]]></description>
    <options type="stringdictionary">
      <item>
        <key>Page2</key>
        <value>This link goes to page 2</value>
      </item>
      <item>
        <key>Page3</key>
        <value>And this link goes to page 3</value>
      </item>
    </options>
    <script type="script">
      AddPageLink (Page1, Page2, "Begin Chapter One : Before The Storm.")
      JS.eval ("setTimeout(function(){ASLEvent(\"PrintDelayedLink\", \"page3\")}, 3000);")
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Page2">
    <description>This is page 2. Type a description here, and then create links to other pages below.</description>
  </object>
  <object name="Page3">
    <description>This is page 3. Type a description here, and then create links to other pages below.</description>
  </object>
  <function name="PrintDelayedLink" parameters="link">
    msg ("{page:"+link+":{color:purple:Delayed link to "+link+"}}")
  </function>
</asl>

What was the silly question?


PS

Thanks again for the kind words, but it's really no problem, I promise!


Using JS for timers seems a little clunky. Does create timer not work in gamebooks?

I notice that the core function SetTimeout is only defined for text adventures; but I suspect that's just because nobody thought you'd need one, and the underlying quest code can support it.

Does it work if you create the function:

  <function name="SetTimeout" parameters="interval, script">
    timername = GetUniqueElementName("timeout")
    create timer (timername)
    timer = GetTimer(timername)
    timer.interval = interval
    timer.timeoutscript = script
    timer.script => {
      this.enabled = false
      invoke (this.timeoutscript)
      destroy (this.name)
    }
    EnableTimer(timer)
    timer.enabled = true
    timer.trigger = game.timeelapsed + timer.interval
  </function>

(taken from CoreTimers.aslx and coalesced into a single function so it wouldn't be a PITA to enter for people creating gamebooks on the web version)


K.V.

Does create timer not work in gamebooks?

I tried that first, and it makes Quest angry!

Check it out:

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at TextAdventures.Quest.EditorController.GetEditorDefinition(IEditableScript script)
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.AddScriptControls(ListBoxItem listItem, Grid parentGrid, IEditableScript script)
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.AddScript(IEditableScript script)
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.RefreshScriptsList()
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.m_scripts_Updated(Object sender, EditableScriptsUpdatedEventArgs e)
   at TextAdventures.Quest.EditableScripts.multiScript_ScriptUpdated(Object sender, ScriptUpdatedEventArgs e)
   at TextAdventures.Quest.Scripts.ScriptBase.NotifyUpdate(ScriptUpdatedEventArgs args)
   at TextAdventures.Quest.Scripts.MultiScript.ReplaceScripts(List`1 newScripts)
   at TextAdventures.Quest.Scripts.MultiScript.LoadCode(String code)
   at TextAdventures.Quest.Scripts.LazyLoadScript.LoadCode(String code)
   at TextAdventures.Quest.EditableScripts.set_Code(String value)
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.Save()
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.set_CodeView(Boolean value)
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.ctlToolbar_CodeView()
   at TextAdventures.Quest.EditorControls.ScriptToolbar.cmdCodeView_OnClick(Object sender, RoutedEventArgs e)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Primitives.ToggleButton.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

...and this is when the script is only create timer ("thisName"):

System.Exception: Starting transaction when previous transaction not finished
   at TextAdventures.Quest.UndoLogger.StartTransaction(String command)
   at TextAdventures.Quest.EditableScripts.set_Code(String value)
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.Save()
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.set_CodeView(Boolean value)
   at TextAdventures.Quest.EditorControls.ScriptEditorControl.ctlToolbar_CodeView()
   at TextAdventures.Quest.EditorControls.ScriptToolbar.cmdCodeView_OnClick(Object sender, RoutedEventArgs e)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Primitives.ToggleButton.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

It is rather clunky, though. Making a text adventure think it's a gamebook is what I always advise first.

The main thing I don't like is that I don't know how you can stop it from printing. It still prints after you click a different link, if you're a quick-draw.


Oh dear ... I think I can see what it's doing there, but that is ugly. It dies in the editor, right? Code view falls over when it tries to return to the GUI, because you've used a built-in function that's missing from the gamebook version of the editor library.
(edited)

Looking at this in a different way, I'm wondering if it might not be easier to change the behaviour of addText if you're doing this a lot. Maybe have addText append its contents into a hidden div, and then start a script which uses JS setTimeout to iterate over the contents of that div, moving elements into #divOutput one at a time. That way, you could have some custom attribute (<br delay="2000" />?) that causes the script to wait. You'd only have to send the modified function at startup, and then you could include your custom element wherever you wanted; or even make a Quest function DisplayDelay(seconds) that just sends the appropriate HTML for the client-side script to deal with.

Or even easier, have addText wait for a line that looks like {delay:2000}. That way, it could be included in normal text, no scripting necessary beyond pasting in a line of minified JS at startup.


K.V.

I've been eager to see what you or Pixie came up with on this one, mrangel.

After I found that create timer rendered Quest unusable, my first thought was to use the JS method, but with an ASLEvent to pass the parameters: link_text, color, background-color, font, delay_interval, and such, but, alas, only one parameter is allowed...

All you really have to do is hide the command input, the location, and the panes to make your text adventure run like a gamebook. There are a few other little differences, but they shouldn't take too much getting used to, and the advantages far outweigh the day or two it might take to adapt your Quest gamebook-creating skills to a Quest text adventure that looks and responds like a gamebook. (I keep harping on that, but here's a list from best to worst: desktop TA editor, online TA editor, gamebook editor.)


(edit: careless mistakes fixed)

A first guess, off the top of my head, so you can see what I was thinking. Not tested yet; and probably needs some fixes because I suck at jQuery. (Sorry if it doesn't work; I can do forums on my phone, but the web interface is too slow to effectively create a game for testing purposes, so I don't know how many differences there are between the web layout for text adventures and for gamebooks)

The idea behind this is that you can send a replacement addText function at startup; and then any time you send an HTML element with a delay property, it will wait after displaying it.
If you were using this in a text adventure, you'd presumably want makeOutputAppear to hide the command bar until it's finished.
And probably have a keypress event that calls makeOutputAppear as well, so pressing any key skips the current wait.

(function () {
  var delayTimer;
  addText = function (text) {
    var output = $("#pendingOutput").length ? $("#pendingOutput") : $("<div>", {id: "pendingOutput"}).css({display: "hidden"}).appendTo("#divOutput");
    text.replace(/\{delay:\s*(\d+)\s*\}/i, '<span delay="$1" />');
    output.append(text);
    if (!delayTimer) {
      makeOutputAppear();
    }
  }
  makeOutputAppear = function() {
    if (delayTimer) {
      clearTimeout(delayTimer);
      delayTimer = undef;
    }
    $("#pendingOutput").contents().each(function(i) {
      $("#divOutput").append($(this));
      // checking attributes of a comment or a block of text will behave oddly, so don't
      if (this.nodeType == Node.ELEMENT_NODE) {
        var delay = $(this).attr("delay");
        if (delay) {
          // If the delay is less than 60, assume it's supposed to be in seconds.
          if (delay < 60) {
            delay *= 1000;
          }
          delayTimer = setTimeout(makeOutputAppear(), delay);
          return (0);
        }
      }
      return (1);  // Not sure if this is actually necessary
    });
  }
})();

Hmmm ... a {delay:1000} inside a <font> would be ignored. I can see how to fix that, but it's not exactly elegant. Would mean recursing over the document structure, and keeping a stack to track where the {delay} was.


Aha, this discussion is beyond my understanding, but at least I'm trying!

1. In regards to your response to my query about delaying the printing of a link, the entire thing works perfectly (didn't for some reason when I tried to implement it into a WIP project, so I started from scratch and it was fine) apart from one thing.

When wanting to change the colour/font/general appearance of the link, this happens:

this

As you can see, the link itself contains the colour values (which of course, it shouldn't). I assumed it was just a problem with brackets, but I wouldn't know how to correct it. It is pasted word for word from what you gave me earlier.

I'm also assuming that you'd have to create multiple functions each time you wanted to make a link from page to page, which seems tedious. (only if you wanted to edit the link text, though? - which I definitely do).

2. When considering other forms of printing text (i.e, typewriter effect), how would I implement those into the current functions?

3. What about background colour? Changing that after a period of time?
Many thanks again!


OK, because I'm having a mini-breakdown and any kind of productivity might help me feel better, here's some more refined JS that will accept either <font delay="350">blah blah</font> or {delay:2000} constructs, and might work with them nested inside other elements.
(edit: silly mistake; brain was still in Perl mode. I'm told you can't use ||= in JS)

(function () {
  var delayTimer;
  addText = function (text) {
    var output = $("#pendingOutput").length ? $("#pendingOutput") : $("<div>", {id: "pendingOutput"}).data("target", $("#divOutput")).css({display: "hidden"}).appendTo("#divOutput");
    text.replace(/\{delay:\s*(\d+)\s*\}/i, '<span delay="$1" />');
    output.append(text);
    if (!delayTimer) {
      makeOutputAppear();
    }
  }
  var pendingContainer;
  makeOutputAppear = function() {
    if (delayTimer) {
      clearTimeout(delayTimer);
      delayTimer = undef;
    }
    pendingContainer = pendingContainer || $("#pendingOutput");
    var outputContainer = pendingContainer.data("target");
    pendingContainer.contents().each(function(i) {
      if (this.nodeType != Node.ELEMENT_NODE) {
        outputContainer.append($(this));
        return (1);
      } else if($(this).prop("delay")) {
        // if this is an element with a delay="5000" property, we remove that property, wait, then call this function again.
        var delay = $(this).prop("delay");
        $(this).removeProp("delay");
        // If the delay is less than 60, assume it's supposed to be in seconds.
        if (delay < 60) {
          delay *= 1000;
        }
        delayTimer = setTimeout(makeOutputAppear, delay);
        return (0);
      } else if( $(this).find("[delay]").length ) {
        pendingContainer = $("<span>").data("target", $(this)).prepend(pendingContainer);
        pendingContainer.append($(this).contents());
        $(this).appendTo(outputContainer);
        makeOutputAppear();
        return (0);
      } else {
        outputContainer.append($(this));
        return (1);
      }
    });
    if ((!delayTimer) && (!pendingContainer.contents().length)) {
      if (pendingContainer.parent().data("target")) {
        pparent = pendingContainer.parent();
        pendingContainer.remove();
        pendingContainer = pparent;
        makeOutputAppear();
      }
    }
  }
})();

(I'm dumb. I've effectively disabled createNewDiv there. I can probably put addText back to how it was but with makeOutputAppear at the end, and make createNewDiv put the new div in pendingOutput)


K.V.

Sorry, I just now saw that it wasn't working for you, AT.

Here's what it looks like for me:
image


Here are the codes:

  <function name="PrintDelayedLink" parameters="link">
    msg ("{page:"+link+":{color:purple:Delayed link to "+link+"}}")
  </function>

You can change purple to whatever colour you like. (Pink Floyd fan? I am.)

You can change Delayed link to "+link+" to whatever message you'd like for the link, but don't fool around with the }} or problems shall arise.


  1. Add this to your page's script in Code View:

JS.eval ("setTimeout(function(){ASLEvent(\"PrintDelayedLink\", \"page3\")}, 3000);")

You can change page3 to whatever the name of your page is.

You can change 3000 to whatever you like for the delay.


To link to your image, here's the syntax: ![alt message if image does not display](url)


Yours would be ![image](https://i.imgur.com/FCh4qiH.png), like this:

image


Could you post your code, or a screenshot of it?


K.V.

Try this in the PrintDelayedLink function:

msg ("{page:"+link+":{color:green:{back:yellow:{b:Delayed link to "+link+"}}}}")

image


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


EDIT:

You can also use the inline CSS method. This does the exact same thing:

msg ("{page:"+link+":<span style=\"color:green;background:yellow;font-weight:bold;\">Delayed link to "+link+"</span>}")


http://textadventures.co.uk/games/view/rb0hcflvfkab9lfbwlts7g/gamebook-tester


(sorry, think I'm rambling over people with actual problems here, I missed the post where you were still having trouble. I thought I should be able to come up with a script so that you can just put {delay:2000} in your text, or even in the middle of a link, and it might work)

Actually...

oldCurrentDiv = getCurrentDiv;
getCurrentDiv = function() {
  div = oldCurrentDiv();
  if (!div) {
    createNewDiv("left");
    div = oldCurrentDiv();
  }
  if (!div.closest("#pendingOutput").length) {
    var pendingOutput = $("#pendingOutput").length ? $("#pendingOutput") : $("<div>", {id: "pendingOutput"}).data("target", $("#divOutput")).css({display: "hidden"}).appendTo("#divOutput");
    div = $("<div>").data("target", div).appendTo(pendingOutput);
  }
  return (div);
}

addText = function(text) {
  getCurrentDiv().append(text);
  if (!delayTimer) {
    delayTimer = setTimeout(makeOutputAppear, 50);
  }
}

(yes, that's really ugly. But you should be able to see what I was thinking of. Intended to replace the addText function in the previous version, so it doesn't fall over if you start outputting a new section while the previous one is still pending)


K.V.

SIDENOTE:

I just now figured out how to use mrangel's function, even though he explained it... (I'm slow sometimes! (I like to read the code then go to town, without reading the instructions.))

mrangel's function will react correctly on-click, clearing the menu output section (or whatever it's called in a gamebook).


Using the exact copy-paste of what you gave me, it is unsuccessful and gives me: this

Clearly not what it should give. I'll also add I am using a gamebook offline, although there doesn't seem to a problem associated with that from what I can tell.

With both other solutions you gave me, the first yield to: this

Whilst the latter gave me this error message:

this

Assuming the problem is with "parenthesising" so I'll see if I can mess with it and solve it. Otherwise doesn't seem to work at all, which is strange, as the online links you gave me worked as intended.


K.V.

Hmm...

I'm using the offline version of Quest and creating a gamebook, too.

What version (or build) of Quest do you have?

Here's mine:

image


Also, just as an extra test, if you download my game and play offline, does it work correctly?

http://textadventures.co.uk/games/view/rb0hcflvfkab9lfbwlts7g/gamebook-tester


this

Exactly the same as yours, it seems. That's very strange, then. I would assume that my OS wouldn't have any interference whatsoever (like a browser would online)? Other than that, what differences could there be? I'm puzzled.


K.V.

I am also puzzled.

I'm on Windows 10. I haven't tried it on my Windows 7 machine...

Just out of curiosity, does the link work? (It's irrelevant. I just wonder. )


K.V.

If you can download my game and it works when you play it:

Could you post your code, if it's not too long (and if you don't mind anyone seeing it)?

Sometimes the forum can mess up a posted code, I think. (I guess some things are formatted that shouldn't be sometimes and things like that.)


If my game doesn't work when you download it:

We'll have to wait for someone wiser than me to suggest something.


I'm on Windows 8 (8.1? who knows?) but regardless. And yes (http://textadventures.co.uk/games/view/rb0hcflvfkab9lfbwlts7g/gamebook-tester) does work completely as intended, playing online.

a

Upon downloading your game, it seems to work completely fine. It'd be very easy for me to just take it from there, but of course that's a weak solution and doesn't explain why it wouldn't be working for me unless I've made a blatant and silly mistake. Here is my code:

<!--Saved by Quest 5.7.6404.15496-->
<asl version="550">
  <include ref="GamebookCore.aslx" />
  <game name="Gamebook Tester">
    <gameid>e8dd5758-0ab6-4f1b-a024-875e9ebc5e56</gameid>
    <version>1.0</version>
    <firstpublished>2017</firstpublished>
  </game>
  <object name="Page1">
    <inherit name="scripttext" />
    <description><![CDATA[This is page 1. Type a description here, and then create links to other pages below.<br/><br/>]]></description>
    <options type="stringdictionary">
      <item>
        <key>Page2</key>
        <value>This link goes to page 2</value>
      </item>
      <item>
        <key>Page3</key>
        <value>And this link goes to page 3</value>
      </item>
    </options>
    <script type="script">
      AddPageLink (Page1, Page2, "Begin Chapter One : Before The Storm.")
      JS.eval ("setTimeout(function(){ASLEvent(\"PrintDelayedLink\", \"Page3\")}, 3000);")
    </script>
    <object name="player">
      <inherit name="defaultplayer" />
    </object>
  </object>
  <object name="Page2">
    <description>This is page 2. Type a description here, and then create links to other pages below.</description>
  </object>
  <object name="Page3">
    <description>This is page 3. Type a description here, and then create links to other pages below.</description>
  </object>
  <function name="PrintDelayedLink" parameters="link">
    msg ("{page:"+link+":{color:purple:Delayed link to "+link+"}}")
  </function>
</asl>

Actually, this isn't mine, but the same problem exists as it is the exact same as what mine was before it died. My file suddenly decided that it doesn't want to open. Whoops.

And guess what happens if I publish it here?

This

This happens. Which means it seems exclusively only to lapse when I'm testing it in the offline mode:

http://textadventures.co.uk/games/view/erimj7doueokixzph_x2ja/test-on-link-colour

That's the game. Test it out. Works fine. Upon downloading this, it also works fine. Which means a mistake on my part in the above code! Problem solved?


K.V.

It was probably just a typo.

I make one, little typo that causes a big problem at least once a day.

(I'm usually either missing a ), or I have an extra }.)


I'm glad you got it working!


Aha, thank you all so much! I'll fix that right up, brackets are a nightmare especially with my eyesight as it is!


Hmm, this is very strange indeed. Upon successfully creating a colour change in a link online, I decided to download the file for offline use. Upon opening that and testing it (without edits), it displayed the same thing it has always done:


(Ignore the three pasted What Stays Behinds, that was me just noticing the problem in the middle of editing).


There must be an issue with Quest on my end: I figured it'd be something to do with the American English variance in the spelling of "color" (in England, we spell it "colour"), so I tried messing with that to no avail. This is quite frustrating! Seeing as all the other game files worked fine, I'm very much stuck. Considering playing the exact same file worked totally fine on the online editor...

I could just resort to exclusively using the online editor but that feels uncomfortable and clunky (personal preference), and of course it doesn't explain the problem. I tried changing the colour value to another colour, and to hex values, and neither worked.

I'm currently in the process of reinstalling Quest! Will let you know how it goes.


Wow! Upon reinstalling Quest, it seems to be working fine! That's actually very frustrating, but satisfying too! Thank you all for your help, I've definitely learnt a lot. One last question.

Regarding changing the colour/font/font-size, is there a table somewhere on the internet with all the names of the properties, so I can just paste it it?
So I can make:

"{page:"+link+":{color:Black:Begin Chapter One: Into The Storm.}}"

Any font, size, and colour I want? As well as change the colour of the underline. And things like typewriter effects. Thank you again!


K.V.

Glad it works now!


That example uses the text-processor to change the font color.

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


I think you'll need CSS (specifically, in-line CSS) to do everything you're wanting to do.

The text-processor stuff only works in Quest anyway, so you're better off learning the CSS.

Example (I'll change Black to Red so it shows up here):
Text-processor:

{color:Red:Begin Chapter One: Into The Storm}

Doesn't work in normal HTML:
{color:Red:Begin Chapter One: Into The Storm}


HTML with in-line CSS:

<span style="color:red">Begin Chapter One: Into The Storm</span>

Works in a normal HTML, like so:

Begin Chapter One: Into The Storm


Now, the tricky bit is the way Quest processes your text. You have to escape your double quotation marks with \ in front of them, like so:

<span style=\"color:red\">Begin Chapter One: Into The Storm</span>

Doesn't work in normal HTML:
<span style="color:red">Begin Chapter One: Into The Storm


NOTE: You could also go with single quotation marks:

<span style='color:red'>Begin Chapter One: Into The Storm</span>

Works in normal HTML:
Begin Chapter One: Into The Storm


This is where I learned quite a bit:
https://www.w3schools.com/css/


Also check out Pixie's docs:
https://github.com/ThePix/quest/wiki#ui

..and this site's docs and tutorials:

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

There's so much information, it's hard to find.

Remember: you can search the forum as well as the documentation with the Google search bar at the bottom of the main pages.


Not sure if you addressed this yet, but:

I'm also assuming that you'd have to create multiple functions each time you wanted to make a link from page to page, which seems tedious. (only if you wanted to edit the link text, though? - which I definitely do).

My thought was to make this function:

<function name="EchoMsg" parameters="text">
  msg (text)
</function>

Then you can freely do:

  JS.Eval("setTimeout(function(){ASLEvent('EchoMsg', '{page:page3:{color:pink:Click here to go to page 3!!!}}');}, 3000);")

Or whatever you want :p
Prints a message from javascript, that goes through Quest's text processor.


K.V.

I was close:

  <function name="PrintDelayedLink" parameters="stuff">
    //parameter should be link;color
    stuff = Split (stuff, ";")
    link = stuff[0]
    color = stuff[1]
    msg ("{page:"+link+":{color:"+color+":Delayed link to "+link+"}}")
  </function>
JS.eval ("setTimeout(function(){ASLEvent(\"PrintDelayedLink\", \"page3;red\")}, 3000);")

Or possibly (off the top of my head, untested):
(edited slightly to simplify)

<function name="MsgWithDelay" parameters="text, seconds">
  msg ("<p style=\"display: hidden\" onload=\"var pp=$(event.target);setTimeout(function() { pp.css('display', 'block').removeAttr('onload'); }, "+(seconds*1000)+");\">"+text+"</p>")
</function>

K.V.

I added the CDATA:

  <function name="MsgWithDelay" parameters="text, seconds"><![CDATA[
    msg ("<p style=\"display: hidden\" onload=\"var pp=$(event.target);setTimeout(function() { pp.css('display', 'block').removeAttr('onload'); }, "+(seconds*1000)+");\">"+text+"</p>")
  ]]></function>
MsgWithDelay("{page:Page3:{color:red:Delayed link to page 3}}", 5)

Everything works, except the delay.


Ooops, 'onload' working for arbitrary elements was a weird nonstandard thing.

  <function name="MsgWithDelay" parameters="text, seconds"><![CDATA[
    msg("<p style=\"display:none;\">"+text+"<script>(function(s){setTimeout(function(){s.parent().show();s.remove();}, "+(seconds*1000)+");})($(document.currentScript));</script></p>")
  ]]</function>

(slightly more complex than it could be; uses currentScript to avoid the hassle of keeping track of unique IDs for everything


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

Support

Forums