JSON based IF language

It seems SugarCube at least has a construct for gotos, but there are multiple warnings not to use them.

Using <<goto>> to automatically forward players from one passage to another with no input from them will both create junk moments within the story history and make it extremely difficult for players to navigate the history. It is strongly recommended that you look into other methods to achieve your goals instead—e.g., Config.navigation.override.

WARNING: <<goto>> does not terminate passage rendering in the passage where it was encountered, so care must be taken to ensure that no unwanted state modifications occur after its call.

These behaviors don’t seem optimal (and I don’t really see what an “alternative” would be), but as another person mentioned I might be able to just code it in with some extra js.

Give us a specific use case scenario. Be concise, but thorough.

2 Likes

Yes, but as it says just above that:

NOTE: In most cases, you will not need to use <<goto>> as there are often better and easier ways to forward the player.

Again, what are you trying to do in a story sense? Usually there are decent ways to do it.

1 Like

I guess… to me, that’s not how you usually do goto in Twine. That functionality is split up in a bunch of different ways depending on what exactly you’re doing.

And any tool that you use or make is going to have these kinds of quirks. You might notice it less if you make your own tool because you’re going to design it to fit the way you want to think… or you might have more problems because you’re running into all the little gotchas that existing tools have figured out over the years. Who knows?

Dunno. I like making tools, personally. If that’s what you enjoy, go for it. But if you just want to make a game and ChoiceScript is close in some ways but not quite what you’re looking for, then it’s probably not too hard to tweak Twine to do what you’re looking for.

1 Like

To be fair, every language and toolset I’ve ever used that had goto support also came with at least three warnings, so this is kinda par for the course.

1 Like

Well, in choicescript at least they’re used in invisible stat checks, where you don’t want the player to know you did a stat check on something. Then, based on the stat check, you redirect them elsewhere. I would rather not have to have them click on something to do the goto in this scenario.

That’s very curious. The two big ones I’ve used - choicescript and ink - both had very straightforward goto rules that the language was based on. No warnings either because, well, that’s just how you wrote your story. It was a big culture shock to see twine being so inflexible with them.

1 Like

I am very much not an experienced Twine user, but I would expect those invisible stat checks to be attached to the link itself (you click it and it sends you to the appropriate place in one go), rather than the link sending you to a separate “stat check” passage which redirects you on to your actual goal.

Well, you might have the stat check in the middle of a passage is the point. If it’s just at the beginning of the page just redirecting to the right spot would be easy enough.

GOTO have been considered evil in programming language for 50 years and twine was created by someone whose primary job (correct me if i’m wrong) was (still is ?) software engineering : no surprise GOTO is unadvised.
It’s cool that it’s allowed though, because as you say, goto are the heart of stories.

Ink have explicit GOTO and there are many people (mainly programmer types) that are terrorized by it for this very reason.
As for the question of “GOTO with no clik”, ink has tunnels, default choices and a variety of things to do invisible stat-check if that’s your use case.

1 Like

Well, yes ink has it for sure. I was wondering about Twine. And I also agree that in computer programming, goto is frowned upon. But I can’t think of a better way to do what I’m hoping to do. If you have a better construct let me know, though.

EDIT: Also, I don’t see the evil of goto in state machines (and if you have another way to abstractly represent IF stories, let me know!). They’re the most straightforward and easy-to-conceptualize translation of that logic. I’d go so far as to say they’re the most readable compared to other approaches (honestly, any other approach I can think of just simulates gotos anyways).

We still don’t know what you want to achieve. I believe you are hung up on how it’s achieved vs. what is achieved. We need to know “the what” in order to tell you how it can be achieved within the coding paradigm of Twine.

:arrow_forward: Run us through a story logic scenario that has you worried about the capabilities of Twine.

And I don’t fault you for wanting to find a coding language that works the way your brain works. That’s the sweet spot where you can honestly say that a story format becomes intuitive. I’m still struggling to find the story format that works for me and I’ve been at this for months.

You have a steep hill to climb, I fear, if you keep beating the same drum though. Everything you want to do can be achieved with almost any Twine story format. You just need to stop assuming that you need things to work a certain way and let us show you how it can be done another way. You’re focused on the process, when you should be more focused on the outcome.


Edit:

Sorry I missed this response, but I’ll keep my comments above anyway because it still carries an important sentiment.

I know in Harlowe, you can redirect (or have intermittent passages that don’t draw to the browser window at all)… the user doesn’t know that you’ve visited potentially five other passages of just coding logic before displaying the final one at the end. I also know that SugarCube is more than capable of this as well, though I’ve not used SugarCube (I done research on most story formats).

I would say, just get your feet wet. Choose a story format and make a simple working short story of 3 or so passages. Then jump into the Twine section of these forums and ask specific questions on any problems you are experiencing. I can’t possibly imagine any scenario that Twine can’t handle since you don’t want to do a parser story.

Just jump in, man! :wink:

Thanks for the edit, I was very confused by the first part haha. Definitely important though.

I’ll give twine another chance. I believe it was harlowe that I tried and someone told me it was straight up impossible without going into the javascript directly, which was what drove me away. If you know the construct in harlowe please let me know, that’s been bothering me forever.

Thanks for the response, that’s exactly what I was looking for!

#macro_redirect

This is exactly the macro you want to use. You can also make your own custom macros once you get more familiar with Harlowe, but you might not ever need to.


Edit:

Just to further clarify, link to the “logic” passage and then within the logic passage, adjust your variables and then (redirect:) as needed. You can redirect many times, but eventually you’ll end up on a passage that draws to the user’s screen with the desired output.

It’s been a while since I used Harlowe in this manner, but I have some working code of this exact scenario so let me know if you need any help and I’ll open that old story and see the exact code used.

Oh yeah that’d be really helpful! The macro actually looks like just what I need, too.

I recommend you start posting specific questions in the Twine forum from here on out, but here is the code based on redirecting (or using go-to).

In the first passage that the player sees, you have a link to your logic passage:

[[ Continue ->Figure Stuff Out]]

…then when the user clicks that link, the passage will disappear and Harlowe will load the “Figure Stuff Out” passage:

{
(set: $something to "whatever")
(set: $number to 42)
(go-to: "Present Stuff")
}

…however, because there is no actual information to display to the user and the passage has a (go-to:) macro, it goes to the next “Present Stuff” passage without making it noticeable to the user:

See if the variables came through:
(if: $something is "whatever")[ The answer is $number ]

I used (go-to:) instead of (redirect:) because some variables didn’t update properly when hitting the refresh in the browser. I’m not sure why I had some issues with redirecting over go-toing, but read up on both to understand them better. However, remember that the user should be able to refresh the browser and the game should not skip a beat.

Of course, this is only useful if you wish to put a lot of code into a logic passage. Most authors will simply calculate what they need and then move on all in one chunk on the passage that requires it, such as:

(link:"Continue")[ 
(set: $something to "whatever")
(set: $number to 42)
(go-to: "Present Stuff")
]

…and bypass the need for a passage that merely redirects. Still, you can embed a passage within another using (display:) and just use that code again if need be. This is useful for re-using visible chunks of code that the player sees, for example.

I don’t really see the need for using a separate passage for just story logic though. If you did find yourself re-using a block of logic code over and over again, just make a your own custom (macro:) for it and save it to a $story variable.

Again, seek the result, do not look for a specific process. Otherwise, you’ll miss the obvious answers in most cases. There are a lot of Harlowe questions online that have already been solved many times over. There is nothing in what you’ve described thus far as difficult to do in Harlowe or Twine.

Good luck!

It’s really not “inflexible”, it just has a disclaimer. I used goto in my game to force a user to a new passage every half second and nothing broke. it’s fine and allowed.

2 Likes

images

(if you see a pencil icon near the title on the first post you can edit title/category/tags)

2 Likes

Ah, as a new user do I have that ability? I saw you already did it, but I tried just now as an experiment and couldn’t figure it out. Probably just me being dumb if so.

Yes! I was just worried since the last time I asked I got one answer and if there’s the same person there as well I might keep getting the answer again, but for sure I’m going to ask the twine-specific questions in the appropriate place moving forward.

By the way, the issue wasn’t with having a separate logic passage (though I have that too), but rather redirecting the use silently in the middle of a passage. So we’d have an initial passage A that goes to B or C depending on some variable values, and we want to either print both A and B on the same page or A and C on the same page. As you mentioned, macros would be one way to do this, but I’m only using A twice, and only in this one location, so organization-wise that doesn’t seem to make sense.

If this is still confusing, we can continue our conversation in dms or I can move to the twine forum.