Page 1 of 1

[Solved] SetVariable to copy a variable value to another variable's value?

Posted: Tue Aug 16, 2022 5:18 pm
by yon
Hi all,

I'm trying to copy a variable's value to a persistent variable at the end of a game playthrough.

Basically, the process is this:
  • Take value from variable
  • Copy variable to separate persistent variable
  • Start new game
  • Persistent variable's value is copied to non-persistent variable
  • That variable is now the same value it was when you finished the game
I'm doing this instead of just using the persistent variable the entire time to prevent the possibility of rewinding the game and passing through the variable value raising parts of the code multiple times, and essentially being able to "grind" that without doing it properly. That is to say, I only want the variable change to be carried over at the end of a game to NG+. How can I achieve that?

I've tried, but I'm somehow misunderstanding things.

Code: Select all

python:
    action SetVariable("persistent.v_mind_end", v_mind)
    action SetVariable("persistent.v_heart_end", v_heart)
    action SetVariable("persistent.v_soul_end", v_soul)
    action SetVariable("persistent.v_guts_end", v_guts)
    action SetVariable("persistent.v_quin_end", v_quin)
This keeps giving me a syntax error, but I don't understand what I'm doing wrong. Can I not use another variable in the "value" field of SetVariable? That's kind of the whole point of what I'm trying to achieve.

Re: SetVariable to copy a variable value to another variable's value?

Posted: Wed Aug 17, 2022 12:21 am
by m_from_space
The keyword python is the starting point of a block of python code. But you use renpy (screen related) code in your example.

Code: Select all

python:
    persistent.v_mind_end = v_mind
    ...

Re: SetVariable to copy a variable value to another variable's value?

Posted: Wed Aug 17, 2022 3:55 am
by yon
That looks like it works! Thank you!