How to use *redirect_scene to edit variables in the Stats Screen

I have been researching ways to edit variables in the Stats Screen and recently I came across how someone can use the *redirect_scene command to make changes.

There isn’t that much information about the command itself and I don’t really see how I can use it to edit variables in the Stats Screen since it apparently "Works just like *goto_scene but for choicescript_stats.txt"

I am aware that stat changes in the Stats Screen after the Next button has been pressed, I want the stat changes to take immediate effect.

So, has anyone used *redirect_scene to any extent? And if so, how can I use it to edit variables in the Stats Screen and have these changes take immediate effect?

For example, how can I get edited variables in the Stats Screen like this?

*In startup.txt* 

*create latest_fruit "NULL"

latest_fruit: ${latest_fruit}

*finish
*In choicescript_stats.txt*

*fake_choice 
    #Set latest_fruit to apples 
        *set latest_fruit "apples"
    #Set latest_fruit to oranges 
        *set latest_fruit "oranges"

*finish

IIRC for using *redirect_scene you have to enter specific scene file name like *redirect_scene chap_2
and this will start chapter at the beginning of that chapter if you haven’t setup variables for checkpoints frankly, I don’t recommend using it, as you will have to set up variables for checkpoints to know where the chapter has to load, its a bad idea frankly. I’d just go with setting up stats in stats screen and clicking next, as *redirect_scene will mean more trouble than its worth.

2 Likes

That’s what I said. @MonkeyLottery, you have to pass to *redirect_scene the current scene and current label. You’d have to manually keep track of it. Like I said, more trouble than it’s worth I my opinion. Not to mention you’d have to be more careful, because *redirect_scene will erase all temporary variables.

If you’re really serious about using it, I’d suggest only allowing to change variables at certain checkpoints. This would drastically facilitate your life.

In your example, include a label right before where you print the value of the variable, in the startup file. Then, in the stats file, replace *finish with *redirect_scene startup your_label_name and see it action.

3 Likes

Frankly I would go with this @MonkeyLottery unless you plan on creating a game like ‘War for the West’ in that case you can just create a dedicated inventory.

1 Like

By the way, don’t do it inside the subroutine. I think it will break the callstack. But I’m not sure.

Thanks for the information, especially your tip about using a *label in startup. However, the system I am trying to create is essentially an “Evidence Menu” for a mystery game, and I feel like it would be a lot better if the player could view this menu at any time.

I can definitely see a use for this in the future and for other authors, but I feel like having the Evidence Menu only update at certain points (unless I create a label for every *page_break, of course. But that’s kind of a hassle) would be a pretty glaring design inconsistency. Not only that but this could also be circumvented if the player presses the “Return to the Game” button.

Still though, thanks for the information regarding *redirect_scene. I feel like it could be pretty useful for some authors, and probably deserves a dedicated entry in the ChoiceScript wiki.

I think I understand what you’re trying to say, but I haven’t played “War for the West” yet so could you elaborate on what you mean by that?

Thanks to you both @cup_half_empty @HWKEye for helping me out with this. It saved me a lot of time instead of spending hours doing trial and error with mock code.

1 Like

To be clear, if you change a variable in the stats screen and then use *redirect_scene, the variable will remain changed in the game, rather than being reset when you leave the stats screen?

As far as I know, *redirect_scene is used to completely close and change from stats page to the main page, because if author used a *goto_scene instead, then the game is still technically in the stats page.

Even with this command, the changes done to a variable from within the stats page will not immediately applied, and player still need to press the Next button for the changes to take effect.

1 Like

That’s it. If you affect any change on any variable in the stats page, the change is permanent. The problem is that the game page will not display the change, because it has been rendered already, so you’d have to go to the next page to see the change in effect.

*redirect_scene forces the game flow into a specific scene from the stats page. It was necessary because of how the stats page was implemented in the game engine. If you use *goto inside the stats page, it’s like a parallel universe, once the player clicks Return to the game, they’ll return to the same page as before they entered the stats page, but any change made to variables will persist.

The solution I proposed was to use *redirect_scene to redirect back to the same spot, because this would force the engine to re-render the page, making the change visually immediate. But there are all the caveats mentioned.

2 Likes

Basically what @cup_half_empty just replied, but I would to suggest something.

If you want any additional clarification, try reading through “Grr…More restrictions found on the stats screen” which is a thread about being unable to edit variables in the Stats Screen and other limitations. Dan Fabulich, the creator of ChoiceScript, has a lot of comments there regarding the issue.

Do note that the thread was made in July 2014 and the last post was in February 2019, so read through it with a pinch of salt because some details may be outdated.

In War for the West, it was a turn-based game where there was a main screen from where all interaction flew, so if you are making a game like that you can add a inventory in the main screen itself and users will be able to change it without going in the stats screen.

2 Likes

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