New features in ChoiceScript: *gosub_scene, *goto_scene label

  1. *goto_scene now optionally allows you to specify a label, like this:

*goto_scene invitations cordial

That would go to the invitations.txt file and automatically *goto cordial at the start of the file.

  1. There’s a new command, *gosub_scene, that allows you to visit a scene file and then *return from it.

  2. Like *goto_scene, you can use *gosub_scene to visit a specific label in another file and return from there.

*gosub_scene invitations cordial

These features are available only in the latest version of ChoiceScript up on github. Please let us know here or over email at support@choiceofgames.com if you encounter bugs in the new commands.

3 Likes

Woops

At last!
Thank you Dan :’)

Triple post :confused:

Sweet

This is brilliant, and it’ll make transitioning from a chapter with multiple exit points into a chapter with multiple entry points a lot easier.

1 Like

Amazing!!! I’ve been longing for this.

Very useful additions. Thank you. :slight_smile:

This is great. Thanks. :slight_smile: Particularly useful for a levelling up system. The one I’ve developed is several hundred lines of code (including empty lines) and it’s not nearly complete yet. Now I don’t have to copy and paste it anywhere.

It’s a great addition; It’ll shorten (and get rid of) some code of mine that was a placeholder for these features.

@dfabulich
You can’t seem to use *gosub_scene under a choice: “it is illegal to fall out… you must *goto or *finish”.
Is this intentional or a bug?

@CJW *gosub_scene is (or should be) identical to *gosub in that regard. After you *return to the *choice, you’ll need to *goto or *finish to avoid falling into the next #option.

@dfabulich
Ah, of course -how silly of me, thanks for that!

Excellent! These are some very useful additions. :slight_smile:

Fantastic! *gosub_scene will ease up several files in Blackraven!

Initially I thought that *gosub_scene would be useful for recalling code in multiple scene files (without copy and pasting), such as *gosub_scene myfunctions myfunc and it is - sort of.
I note that *gosub_scene does actually load the new scene, run the new code and then reload/restore the old one.
This means you can actually get a bit of a delay between code call and execution, I found it most noticeable on a mobile device using a data connection.

It’s not a HUGE problem and it won’t affect most games, but when we’re calling more “codey” routines (as opposed to just blocks of text), having loading bars appear and stuff isn’t ideal. What are the chances of an *import or *include command that actually appends the given scene’s code to your current scene? I think that prove more useful for the recalling of more complicated functions and the like, whilst *gosub_scene works well for calling large bodies of extra text.

In addition that would also allow you to “pass” temp variables to these functions (you don’t really pass them but since you never leave the scene you still access them), at the moment if you *gosub you’re need to make use of globals.

To clarify, I’d love to be able to do something like this:


*include functions
*temp return_val ""
Well done, Adventurer! You have completed the first part of your quest, your strongest was 
*gosub functions_highest_stat
${return_val}

functions_highest_stat would be a label inside functions.txt that compared and set “return_val” (or any other temp name you prefer) to the name of the highest stat.

IMO this doesn’t call for a new command, but rather we just need to improve performance of the *gosub_scene command. I’ve hypothesized that it’d run fast enough on a game that has been fully compiled with your compiler, for example.

@dfabulich
Fair point! I just tried with a compiled game and it worked wonderfully, even on a mobile device, so I’m happy. Well hypothesized! :slight_smile:

Speaking of, have you had any further thoughts on how to fix the compiler, either on my end or yours? I did roll something together that works, but only because it actually looks for and escapes that stray script tag itself (which isn’t ideal behaviour?).

Edit: Before I forget there is another bug with the compiler related to a stray character that appears, after some poking around I noticed that ui.js is UTF-8 encoded, and uti.js is ANSI encoded - changing them both to ANSI fixed this, is this is a mistake or something intentional that needs another work around?

I’m already using *gosub_scene as an easy way to put in checkpoints in a project. In this situation the added few seconds of the loading bar makes it look like it’s actually saving something, despite the fact it’s technically not.

I think I shall coin the term “smoke and mirrors” for this. Trademark pending.

@dfabulich I have encountered a problem with *goto_scene label. A page break encountered in the destination file doesn’t work. The “next” button simply doesn’t respond.

Page breaks in the files reached by a *goto_scene without specifying a label work fine.