Trying to figure out how to do this *gosub_scene is giving me a headache

Hi there! So I’m trying to code a hub where players can spend their day off doing various activities, and each activity moves time forward until the day ends. If they’re spending time with an NPC, I want to use a *gosub_scene command to direct them to the separate NPC files, and then a *return at the end of that NPC file to go back…

*label dayoffchoices
*choice
    #I'll spend some time with a companion.
        Which Shepherd will you spend time with? 
        *choice            
            *hide_reuse *if (bladedayoff = false) #Blade. 
                *set dayoff +1
                *goto_scene blade
            *hide_reuse *if (tallysdayoff = false) #Tallys. 
                *set dayoff +1
                *goto_scene tallys
            *hide_reuse *if (troubledayoff = false) #Trouble. 
                *set dayoff +1
                *goto_scene trouble
            *hide_reuse *if (sherydayoff = false) #Shery. 
                *set dayoff +1
                *goto_scene shery
    *hide_reuse #I'll do some strength and weapons training.
        *set dayoff +1
        *goto strength
    *hide_reuse #I'll study magic and spell-casting.  
        *goto magic
        *set dayoff +1
    *hide_reuse #I'll take a moment to pray. 
        *set dayoff +1
        *goto pray
    #I'll go shopping.
        *goto shop
    *hide_reuse #I'll run a few errands to earn some extra gold. 
        *set dayoff +1
        *goto parttime
    *hide_reuse #I'll rest until the end of the day.
        *set dayoff +5
        *goto rest

As you can see, right now I have it as *goto_scene, not *gosub_scene. The reason why I need *gosub is because going to a different scene (and then being redirected back to this scene and this label) “resets” the *hide_reuse command, so if you trained in strength or something, then hung out with an NPC, when you came back to this hub, you’d have the ability to train again (which you shouldn’t).

I’m hoping *gosub_scene will negate that, but my problem is the *return at the end of the NPC file takes them back to that nested choice, not to the top of the label (dayoffchoices). I could just not use *return and use *goto_scene dayoff dayoffchoices, but I’ve read that not having a *return for a gosub is game-breaking…

Can anyone help make sense of this, haha??

1 Like

What if you just had the blade, tallys, etc. bits within the same scene? Just stick those parts later in the file. Then you won’t have to worry about the resetting of *hide_reuse at all. It may make your file longer, but that’s ok.

3 Likes

It would make things a lot simpler, but also a huge pain for my own organizational purposes! Each interaction is 3000-5000 words long, there will be probably 10+ interactions per each NPC, and there are 11 NPCs altogether haha… It’s way easier to keep track of everything when they’re in separate files, so I’m hoping I can still do that!

If not, I’ll have to do as you said when everything’s all written out… :sweat_smile:

okay, where do you want the story to go when the player ‘return’ from the gosub?
The choice body?
A later label?

if the former do like this I think

choice 
#I'll spend some time with a companion. 
   Which Shepherd will you spend time with? 
   *choice 
      *hide_reuse *if (bladedayoff = false) #Blade. 
         *set dayoff +1
         *gosub_scene blade
         (flavortext telling the player time has passed yadda yadda)
         *goto dayoffchoices
2 Likes

Yes, I’d want the player to return to the main choice body (*label dayoffchoices)! I’ll try that, thank you! :grinning: (Seems obvious in hindsight, lol…)

2 Likes

Tell us if it worked

It works to get the scene to flow how it should (going back to the choices hub after *returning from an NPC scene) but it doesn’t stop other choices from resetting the *hide_reuse! I think the only way to make that work is to make a bunch of true/false toggles for those or do as @Gower said and just put it all in the same scene! :sweat_smile:

2 Likes

Wait. Which choices are messing with the *hide_reuse?

So if you choose to hang out with an NPC and use *gosub to go to their separate scenes, like this:

choice 
#I'll spend some time with a companion. 
   Which Shepherd will you spend time with? 
   *choice 
      *hide_reuse *if (bladedayoff = false) #Blade. 
         *set dayoff +1
         *gosub_scene blade
         (flavortext telling the player time has passed yadda yadda)
         *goto dayoffchoices

any other choice under *label dayoffchoices that might have been *hide_reused (any activity that’s not hanging out with an NPC) will have been reset:

    *hide_reuse #I'll do some strength and weapons training.
        *set dayoff +1
        *goto strength
    *hide_reuse #I'll study magic and spell-casting.  
        *goto magic
        *set dayoff +1
    *hide_reuse #I'll take a moment to pray. 
        *set dayoff +1
        *goto pray

In other words, if you hang out with an NPC, do strength training (which should be hide_reused after you do it), then hang out with another NPC, when you return to *label dayoffchoices, strength training pops up again as if you hadn’t already done it!

1 Like

Just got home. Working on a solution now.

1 Like

Mnnn… what happens if you don’t nestle the choice, but make that its own label like…

*label a
*choice
  *if (meetcounter !=4) #thing
    *goto b
  *hide_reuse #thing 2
    *goto c

*label b
*choice
  *hide_reuse #a 
    *set meetcounter +1
    Gosub stuff
    *goto a
  *if (meetcounter = 4) there is no one else.
    *goto a

Just tried it–same thing! I think whenever you leave the scene, the *hide_reuse will reset no matter what! (Unless you do everything as a true/false toggle)

1 Like

Disable reuse would wield the same problems then. So yeah. Variables it is.

1 Like

@rinari, this seems to work on my end. Please adjust as necessary.

Modified Code
*temp toggleblade 0
*temp toggletallys 0
*temp toggletrouble 0
*temp toggleshery 0
*temp togglestrength 0
*temp togglemagic 0
*temp togglepray 0
*temp toggleparttime 0

*temp bladedayoff false
*temp tallysdayoff false
*temp troubledayoff false
*temp sherydayoff false
*temp dayoff 0

*temp toga "toggle"
*temp togb ""
*temp togc ""

*label dayoffchoices
*choice
 #I'll spend some time with a companion.
  Which Shepherd will you spend time with? 
  *choice            
   *if ((bladedayoff = false) and (toggleblade = 0)) #Blade. 
    *set dayoff +1
    *set togb "blade"
    *gosub_scene blade
    *goto toggle
   *if ((tallysdayoff = false) and (toggletallys = 0)) #Tallys. 
    *set dayoff +1
    *set togb "tallys"
    *gosub_scene tallys
    *goto toggle
   *if ((troubledayoff = false) and (toggletrouble = 0)) #Trouble. 
    *set dayoff +1
    *set togb "trouble"
    *gosub_scene trouble
    *goto toggle
   *if ((sherydayoff = false) and (toggleshery = 0)) #Shery. 
    *set dayoff +1
    *set togb "shery"
    *gosub_scene shery
    *goto toggle
   #(Pick a different choice...)
    *goto dayoffchoices
 *if (togglestrength = 0) #I'll do some strength and weapons training.
  *set dayoff +1
  *set togb "strength"
  *gosub toggle
  *goto strength
 *if (togglemagic = 0) #I'll study magic and spell-casting.  
  *set dayoff +1
  *set togb "magic"
  *gosub toggle
  *goto magic
 *if (togglepray = 0) #I'll take a moment to pray. 
  *set dayoff +1
  *set togb "pray"
  *gosub toggle
  *goto pray
 #I'll go shopping.
  *goto shop
 *if (toggleparttime = 0) #I'll run a few errands to earn some extra gold. 
  *set dayoff +1
  *set togb "parttime"
  *gosub toggle
  *goto parttime
 #I'll rest until the end of the day.
  *set dayoff +5
  *goto rest

*label strength
strength text here
*goto dayoffchoices

*label magic
magic text here
*goto dayoffchoices

*label pray
pray text here
*goto dayoffchoices

*label parttime
parttime text here
*goto dayoffchoices

*label shop
shop text here
*goto dayoffchoices

*label rest
*gosub togglereset
*goto dayoffchoices

*label toggle
*set togc toga&togb
*set {togc} 1
*goto dayoffchoices

*label togglereset
*set toggleblade 0
*set toggletallys 0
*set toggletrouble 0
*set toggleshery 0
*set togglestrength 0
*set togglemagic 0
*set togglepray 0
*set toggleparttime 0
*return

*ending
5 Likes

Whoa! Thank you so much, @Carlos.R! :open_mouth: I think that should work!

3 Likes