Some time ago I posted asking how to create a menu linking to other game menus to replace the standard game menu. Now i got involved in a project where it became necesary to print variables inside a button and have it update whenever the variable is changed. Of course, this could be done through the use of if/else statements...
If only it was that easy. Problem is, the variable is the result of renpy.input(), and I cant limit nor foresee what values will be added to the variable by the user (name input code, can be whatever the user wants).
What I tried:
- Setting the button text as "%(var)s". Doesnt work, text on the buttom is the code itself, not the value nor "< var unbound >".
- Saving the value as persistent data and calling it as ui.text() on a background that matches the location of the button. Returns same problems as the other attempt.
Thanks in advance.
Variable Buttons
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
- Aleema
- Lemma-Class Veteran
- Posts: 2677
- Joined: Fri May 23, 2008 2:11 pm
- Organization: happyB
- Tumblr: happybackwards
- Contact:
Re: Variable Buttons
If your variable is a string, you can just set the button text to it, no %()s involved.
ui.textbutton(var, clicked=...)
If it's an integer (number) you can do it that way, or:
ui.textbutton("%d"%var, clicked=...)
ui.textbutton(var, clicked=...)
If it's an integer (number) you can do it that way, or:
ui.textbutton("%d"%var, clicked=...)
Re: Variable Buttons
Works great, tyvm for fast reply.
Who is online
Users browsing this forum: No registered users