Coding Help?

I’m actually just looking for an affirmation that this might work. So, I’m winging it here (which is a terrible idea, I know) but I just wanted to get something planned out atm.

I’m thinking of doing a less linear based section of my story and need to know if you’d think this idea would work. At a point in my story I wanted to have the player/reader have to go through a few arcs before proceeding to the final sections. Plot put aside, I’ve figured that out a general idea for the coding.

I’ve decided to have a hub scene, one where the player returns to after each arc. From there you finish an arc of the story, then return back to the hub. That’d be used with a combination of [*choice] and [*goto_scene] tags. Then after finishing an arc, a variable, likely boolean, will be [*set arc1 true] and then once all arcs are finished, I open the final path with something that looks likes [*if (arc1=true) and (arc2=true) and (arc3=true)]. What do you think?

Here’s a skeleton of the code.

(hub_scene)
*disable_reuse
*create arc1
*create arc2
*create arc3
*set arc1 false
*set arc2 false
*set arc3 false
`#choice
``#arc1

``#arc2
```*goto_scene arc2
``#arc3
```*goto_scene arc3
``*selectable_if (arc1fin=true) and (arc2fin=true) and (arc3fin=true)
```\*goto_scene finalarc


(arc?_scene)
blah,plot,blah
set arc? true
\*goto_scene hub

So ideas? Too confusing? Simpler ways to go about it? Questions?

The basic idea is sound and should work for the purpose intended, but the suggested implementation might have a problem. The way you have it there, it would actually be (re)setting the arcs to false again on each return to the hub (which makes the *selectable_if unworkable as intended–i.e. it would essentially never be true).

It would probably be better to ignore the (outdated) *create command and define the arc variables (with a default value of false) in mygame.js. That way you also don’t need to *set (or as the case would be here, reset) them in the hub scene itself, so once each has been *set to true it would remain so, allowing the *selectable_if to ultimately work as intended.

Other than that problem, the overall concept seems fine to me–although you’ll also need to look more closely at the parentheses used on the *selectable_if line (i.e. each pair of conditions should generally be enclosed within an additional set).

Ahhh. I see what you mean; I’m pretty much making a loop. I’ll fix the parentheses and use mygame.js. I don’t know why I’m keep using *create, I guess it just seems to flow better with me. The mygame.js file scares me a little because if I mess up anywhere the whole thing breaks on me, LoL. Thanks for your help!

Will someone explain mygame.js better for me? I keep getting errors like “Expected }” or something like that when I try to put my stats there instead. I kept looking for more in the Intro and Adv. guides, but it doesn’t go over the file too much there.

Not myself knowing anything about JScript either, the best advice I could offer any other complete novice is firstly to not create your own mygame.js from scratch. Take a fresh copy of the sample one provided and simply edit / add to it as required, and be careful to keep the exact same format when adding new lines. Problems only occur when you don’t follow the exact same format in adding scene or variable names, or if, when editing, you have removed something you shouldn’t have.

Some errors might include:

  • The first name in either list should never be preceded by a comma
  • The last name in either list should never be followed by a comma
  • Don’t use ANY UPPER CASE letters in scene or variable names, lower case only
  • Don’t include the “.txt” extension in the scene names list (navigation section at the top)
  • Don’t use any spaces in scene or variable names, although under_score_is_fine
  • Every variable name must be followed by a colon, a single space, then a default value, even if just:

“” (two double quotes, for a blank text variable, or put “Some Default Starting Text” in there)
0 (default numeric variable–can be any actual starting value)
false (default boolean variable–no quote marks around “false” or “true”)

  • Make sure you don’t have any extra spaces after each scene or variable entry, on the same line
  • Above all, don’t edit anything other than the actual list of scenes or variables

Hopefully someone else can better explain the workings of JScript itself, as it applies to mygame.js anyway, but taking care to follow the guidelines above should suffice for most of us.

Oh, thanks! I didn’t know that there weren’t supposed to be capitals in variable names. No wonder it didn’t work before.