Calling a subroutine

Discussion in 'Site Feedback' started by robyna, Apr 13, 2021.

  1. robyna

    robyna Virgin

    Hi Everyone,

    I think it would be super-useful if there was a capability here, similar to call in Renpy, that would let us create a chapter that could be called from a variety of locations and then return to the calling page (or a specific landing page based on the calling page). I have some date scenes that may be triggered on a variety of occasions but, as far as I can tell, I'll have to copy the same chapter over and over to allow it to return to the appropriate chapter after the date. If this capability already exists, please clue me in.

    Thanks.
     
  2. Almax

    Almax Really Experienced

    I'm not sure precisely what you're askin' here, so I'm gonna give you two answers and the first one might be totally useless to ya. Sorry if it is!



    --------------------------------------------------------------
    FIRST!

    If you just mean to have multiple chapters link to the same chapter, then you should know that link chapters do exist! When you're editing a chapter, you can click a thing on the right that says "Create link chapter", then pick which chapter you want it to link to. When you do this, be careful! It deletes all content in the chapter. You don't want to type up a chapter and then hit "Click link chapter", you want to add a chapter and then make THAT one the link chapter. It does exactly what it sounds like -- links to said existing chapter, no sweat! So you could just write up the date scene somewhere and have a buncha opportunities for link chapters to reach it.

    Note that the link chapters don't automatically carry the variable requirements of the chapter they link to, but that's a good thing, because worst-case scenario you can just copy over the same requirements. It also frees you up to have different requirements at different times and places -- maybe going on the date after saving person x's life requires 50% or more of an affection stat, where in other cases it requires 70% or more. It also lets you artificially use "or" scenarios. Here's an example of that, because it'll hopefully be easier to follow than me trying to explain it with words:

    Time to fight!
    option 1: Walk up and hit it hard (requires Weapon = 1, the baseball bat)
    option 2: Shoot it (requires Weapon = 2, the rifle)

    ^In a situation like this, if you only want the chapter options to be based on if you're going up to melee range or if you're staying back, then you could add a third option to let you use a second melee weapon:

    option 3: Walk up and hit it hard (requires Weapon = 3, the sword) [links to option 1]

    This way, you get to artificially have an "or", that the chapter requirements don't allow -- you're essentially barring one chapter behind "If Weapon == 1 or Weapon == 3". And of course, you can totally do this for entirely different variables, as well! "If Weapon == 1 or Strength >25", for example. It's also worth knowing that, while link chapters can change variables just like a normal chapter, it's added on top of the variable changes of the chapter they're being linked to. Think of link chapters like a chapter the user visits before going over to the linked chapter, without seeing the link or needing whatever variables the linked chapter would usually require, but still picking up whatever changes the link itself has. This can be really useful as well, but it can also cause problems if you're not aware of it (like doubling up on variable changes).

    ((Also, on an unrelated note, that "three weapons example" sometimes can't be avoided, but it's worth planning your variables out so that in cases where it can be avoided, you get to. For example, if the sword was Weapon = 2 and the rifle was Weapon = 3, then "Weapon < 3" would mean "melee weapons". This can save a lot of time if you're able to plan it in advance!))



    --------------------------------------------------------------
    SECOND!

    This one's super easy, and if you already know what link chapters are, it's basically just a way to use 'em better. It'll let you link to the same chapter multiple times, but always link back to the place you came from no matter where it was (or the place you intend to go next, based on where you came from). Here's the example:

    Hey, hope you're ready for your lunch break. It's time for a date!
    Link to date chapter (sets "DateStatus" to 4)

    Wow, that date was awesome!
    Back to the office, then! (requires DateStatus == 1)
    Well, off to have your weekend. (requires DateStatus == 2)
    Now you've got to go to Jane's party! (requires DateStatus == 3)
    Go have the rest of your Lunch Break (requires DateStatus == 4)


    Obviously, that variable can also be whatever in the world you desire it to be. I'd recommend having a notepad document or some other form of data dictionary to keep track of what all of the numbers mean, and to make sure you don't double up by accident. If you wanted, you could even hide reminders to yourself in the chapter itself -- like having "{if MerryChristmasI'mTheAuthor = True}" before defining what each number means. Be sure not to write "{if@" by accident!

    Also, using this, it's not just that you can link back to an appropriate spot from where you started, but you can also have custom text in the chapter like normal depending on where you just came from, as well as outside variables that might exist. Like "{if DateStatus == 3} Boy oh boy, are you excited for Jane's party! {endif}". Having stuff like this takes extra time and work, and might not be worth it depending on what exactly you're doin', but it can also make the readers feel really like their game state matters and is being taken into account, and I love doing it.

    Hope that helped! Lemme know if anything wasn't clear or if there's anything else you're wonderin' about.
     
  3. robyna

    robyna Virgin

    I was aware of the first option and use it a lot but it doesn't let me go to a chapter and then return to a specific designated spot. It sounds like option 2 may do exactly what I need... i.e., have a date option on multiple days and then return to the next event on that day. I.e., "It's evening #1 Do you want to go on a date or stay home and play games." If you pick play games, you will get the option of the first date the following evening. If you pick the date, you'll have a second date option on the second evening. If you pick the first date on the second evening, you'll return to the second evening after the date. I will experiment with this and make sure I can make it work. Will this work if the reader did not select the game mode?

     
    Almax likes this.
  4. Almax

    Almax Really Experienced

    Variables and hidden chapters only apply in game mode -- I'd recommend either putting a message at the bottom of the chapter, hidden behind an "if@" for a fake variable so you can only see it out of game mode, that explains each link leads to a different place, or just make it naturally obvious that that's what's goin' on with the chapter titles so that you don't need a note.

    People reading a Game Mode story out of Game Mode will always break the systems you're planning for, and there's no way around it other than to let them know so that they can keep enjoying the story, unfortunately. That's sort of just the way it is. I think it's still important to be accommodating for that though, because I don't like the idea of forcing people to click through a bunch of chapters anytime they want to reread something they liked/disallowing people from playing in "dev mode" and checking out all the options in one go. If people wanna enjoy your stuff, you should make it as easy for them as possible, and not decide for them how they're allowed to enjoy it, y'know?
     
  5. DeviantChalice

    DeviantChalice Really Experienced

    Although you may get to a point where it just makes more sense to make it in an actual text adventure app with more functionality, like Twine.

    As much as CHYOA is great and all.
     
  6. robyna

    robyna Virgin

    Hi DeviantChap, thanks for the suggestion. I have worked on doing a version of this story as a visual novel with Renpy, so I'm familiar with different options but I really appreciate the community and feedback I get from Chyoa. Still, I may get to the point where I need more flexibility. I downloaded Twine a while ago but haven't really spent much time with it. I have had fun with Renpy but creating all of the art is time consuming and the game balloons to be huge in a hurry.

     
  7. DeviantChalice

    DeviantChalice Really Experienced

    Yeah the community stuff is definitely a huge plus.