Adding Constantly accessible switches [SOLVED]

Hi all, I’d really like some help and/or advise on this. I want to give my readers the ability to change two main variables no matter their point in the game.
I had previously been attempting to do this using the stats screen, not realising until I was pretty sure I’d got the whole thing working perfectly that it wouldn’t ‘stick’, and that variables are reset to their game state upon exiting the stats screen.

I briefly had a quick look at when I could add extra options to the settings button, but I’m not sure whether a game could be published with these custom additions in the long run, and due to my skill level with javascript is going to take up a hefty amount of time to get anything like that working in the first place.

The two variables in question control the display of unicode symbols allowing me to drop non immersion breaking hints into dialogue trees, this is basically with an ‘on’ ‘off’ state currently set to “1” or “2” and making use of the multireplace function, and the other variable controls the readers exposure to scenes depicting extreme panic and anxiety, this has three states and opperates using *if 's to skip over or redirect to alternate text.

So, two main questions really:

  • Is it possible to change a variable in the stat screen and carry that change back to the main game?

  • What are the rules on publishing finished choice script stories with additional, or changed, script files?

Sorry if this has been covered in another post somewhere, please redirect me if so.

2 Likes

Worked for me with this kind of code in the choicescript_stats file:

*label ch_var1
*fake choice
  #Setting the variable
    *goto ch_var2

*label ch_var2
What's the variable?
*fake_choice
  #1
    *set var1 1
    *goto ch_var1
  #2
    *set var1 2
    *goto ch_var1

It can be simplified, *fake_choice can be changed to *choice, etc., but in general it should work. The only errors I can think about is the variable being created with *temp in the beginning of the choicescript_stats (in this case it will disappear upon leaving the stat screen) or the variable’s value being set somewhere outside of this loop in the same file.

Additional or changed scripts are not allowed, if I remember correctly. To publish under HG or COG you have to use their default scripts and files.

1 Like

With the *fake_choice branch that you’ve written up there, did your chosen amount remain after you left the stats screen?

If you were to add a ‘print out’ of the variable value like this:

*label ch_var1
var1 currently holds a value of: ${var1}
*fake choice
  #Setting the variable
    *goto ch_var2

*label ch_var2
What's the variable?
*fake_choice
  #1
    *set var1 1
    *goto ch_var1
  #2
    *set var1 2
    *goto ch_var1

Would that newly assigned value remain changed if you left and re-entered the stats screen?

I’ve had no luck so far in that regard, and the choicescript wiki does mention that the *set function doesn’t ordinarily work in the stats screen.

Changes done in the choicescript_stats.txt will only ‘stick’ after the reader pressed the Next button when outside the choicescript_stats.txt. Afaik, this is the only way to make the changes stick.

Perhaps you can tell the reader to do that, or you can try tricking them to press the next button by utilizing *redirect_scene to jump out of the choicescript_stats.txt into a “yes or no” confirmation page. The problem with the second option is, you have to figure out how to bring the reader back to the exact story page.

What about allowing the reader to set them up at the beginning of the story? Sure there’ll be no changing the setting midway.

5 Likes

I have never encountered this error, but all the permanently available choices I have put in the stats screen are not actually in the stats screen at all. They’re in a file that is accessible through the stats screen via *gosub_scene. Have you tried doing that?

3 Likes

Ohhhhhh!
I’m kicking myself that I didn’t make a testing space to try out the Next button cycle before now.

Yes, that works!

Thank you so much for pointing that out to me.

I wonder if it would work if the Next button was in a gosub_scene as @sviyagin mentions:

I’ll have to run a few tests and see what happens and if I can make it run relatively smoothly.

I do have an initial setup section where the reader has access to the technical switches for both variables, but the more I write of the story, the more I realise how long the thing is going to be, and the harsher it feels to make someone pick something like that without context, then have to either restart to fix it, or playthrough as is, possibly getting more and more frustrated as time goes on.

It’s all a bit finicky but if it makes the story more accessible to people it’s got to be good right?
Or at least that what I keep telling myself…

Thanks for the answers, that all worked out to be much simpler than I was making it out to be!

1 Like

Oh? I’m not so sure anymore. But I vaguely remember that if you immediately go back to the stats screen, the change will revert back.

Usually the code within my gosub scene looks something like:

*label blah
*fake_choice
  #Option 1
    *set var x
    *page_break
    *goto blah
  #Etc
  #Return to the previous screen
    *page_break
    *return

The game is forced to go through various page_breaks/next buttons, so hopefully that would work?

Absolutely. An option like that would be nice to have.

I just ran a real speedy test through and can confirm two things.

  1. The *gosub_scene method works fine to change the switch, no bugs and the change does ‘stick’ when you navigate out of the stat screen.
  2. However it still requires a Next button in the main scene file to register the difference. Having a Next button in the *gosub_scene file does not count it appears.

Does this mean that if a player flips the switch (let’s say from helpful hints off to on), when they return to the main screen, even if there are helpful hints, they still won’t appear?

Pretty much. It makes sense really when you think about it (which makes me even more frustrated with myself that I didn’t see it sooner tbh). The original page would need to refresh to take in the changed variable and therefore change the display of the text.

But this does work in a sense. And in all honesty, it might actually be better that the hints don’t turn up immediately, it’s kind of an anti cheating system, you can’t flip the switch in time to get the hints unless its already on, or you know what’s coming.

Saying that, I could build it a system for those scenes that could hypothetically store the switches state at the start of a key scene, then if at any point that state changed in the course of the dialogue I could restart the conversation for the player… Shouldn’t be too difficult to do…

All it would take would be an *if function just after the *choice option…

Or I could add an option to the stat screen switch that asks if the player would like to restart the dialogue. That might be better…

1 Like

I’m going to put this in a new post and within a details bracket as it’s rather long. But I managed to work out a system that effectively resets the dialogue (hypothetical in this case since this is from my testing scene) if the player chooses to replay the scene with the changed settings:

ChoiceScript Code

This is in the game scene file:
`

Please choose your test:
*choice
    #Personality Checker
        *goto Personality_Values_checker
    #Name Capitalizer
        *goto Name_Capitalization_Checker
    #Name Conflict Checker
        *goto Name_Conflict_Checker
    #Nested if statements without labels
        *goto nested
    #Unicode Tester
        *set key_scene true
        *goto unicode_tester

*label unicode_tester
The switch is currently set to @{unicode On|Off}.

♡ Romantic Relationship Route @{unicode ♡|}

☼ Platonic Relationship Route @{unicode ☼|}

☓ Unfriendly Relationship Route @{unicode ☓|}

☼♡ Multiple Outcomes Route @{unicode ☼♡|}

Does the above text display properly?

*choice
    #No
        *if (key_scene_restart = true)
            *set key_scene_restart false
            *goto unicode_tester
        Then lets try it again.
        *page_break
        *goto unicode_tester
    #Yes
        *if (key_scene_restart = true)
            *set key_scene_restart false
            *goto unicode_tester
        Great!

        Taking you back to the main menu.
        *page_break
        *set key_scene false
        *goto start`

And this is the stats screen switch:

[b]Unicode Choice Hints[/b]

	In order to make the story as clear as possible, without breaking the immersion of the narrative, there are little Unicode symbols used to highlight the long term effects of choices. 

	♡ Romantic Relationship Route @{unicode ♡|}

	☼ Platonic Relationship Route @{unicode ☼|}

	☓ Unfriendly Relationship Route @{unicode ☓|}

	☼♡ Multiple Outcomes Route @{unicode ☼♡|}

	These do not appear on all choices in the game, only in key moments where relationships between the characters can split.

	Would you like to switch the unicode choice hints @{unicode off|on}?

	*choice
		*if (unicode = 1) #Turn Unicode Hints Off
			*set unicode 2
			Unicode Hints are now switched Off.
			
			*if (key_scene = true)
				You will not see the Unicode hints if you are already in a choice situation. Would you like to restart the current dialogue?
				*choice
					#Yes
						*set key_scene_restart true
						The dialogue will restart once you return to the game either move to the next page, or make a choice. Don't worry this first choice will not effect your story, and you will be able to remake the choice once the scene resets.
						*page_break
						*goto main
					#No
						The scene will continue without interruption when you return to the game. Please be aware that you will not see the Unicode hints if you are already in a choice situation.
						*page_break
						*goto main
			*if (key_scene = false)
				*page_break
				*goto main
		*if (unicode = 2) #Turn Unicode Hints On
			*set unicode 1
			Unicode Hints are now switched On.

			*if (key_scene = true)
				You will not see the Unicode hints if you are already in a choice situation. Would you like to restart the current dialogue?
				*choice
					#Yes
						*set key_scene_restart true
						The dialogue will restart once you return to the game either move to the next page, or make a choice. Don't worry this first choice will not effect your story, and you will be able to remake the choice once the scene resets.
						*page_break
						*goto main
					#No
						The scene will continue without interruption when you return to the game. Please be aware that you will not see the Unicode hints if you are already in a choice situation.
						*page_break
						*goto main
			*if (key_scene = false)
				*page_break
				*goto main
		#Return to main menu
			
			*goto main

And that all seems to work okay! All I need to remember to do is ‘braket’ my key scenes in *set key_scene true & *set key_scene false and everything should work quite smoothly.

Hopefully this thread can help out folks in a similar position.

4 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.