Adding a the choice to change the textbox in preferences.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
-
crimsonnight
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Adding a the choice to change the textbox in preferences.
I'd like to add the option to select a second, plain textbox to my novel in the preferences screen. Is this possible? If so, how would I accomplish it? I can't find any documentation on the subject.
Thanks,
Thanks,
alwaysthesamebluesky.com
- kitsalai
- Regular
- Posts: 65
- Joined: Wed Jan 08, 2014 11:05 pm
- Projects: Imaginatum
- Location: US
- Contact:
Re: Adding a the choice to change the textbox in preferences
Haven't tested it but here's my advice.
Textboxes are defined using styles, right? I saw this link in another thread where you can change styles in the middle of the game: http://www.renpy.org/doc/html/style.html#style.rebuild With this it should be possible to change the UI in the middle of the game. Insert another textbutton in your preference screen where the action changes the variable style.window.background and also calls the style.rebuild() function.
Textboxes are defined using styles, right? I saw this link in another thread where you can change styles in the middle of the game: http://www.renpy.org/doc/html/style.html#style.rebuild With this it should be possible to change the UI in the middle of the game. Insert another textbutton in your preference screen where the action changes the variable style.window.background and also calls the style.rebuild() function.
- Milkymalk
- Miko-Class Veteran
- Posts: 752
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Adding a the choice to change the textbox in preferences
Styles aren't part of savegames, so if you change a style mid-game, the preferences will be reset every time you load a game.
What you CAN do is make a separate style and apply a variable to determine which one to use.
What you CAN do is make a separate style and apply a variable to determine which one to use.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
-
crimsonnight
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Adding a the choice to change the textbox in preferences
I don't think it's a massive deal if it's reset every time to be honest, it's a short novel, so it shouldn't be too much of a hassle. Thanks for the advice - how would I go about doing that exactly? I know the coding used for preferences is quite different.Milkymalk wrote:Styles aren't part of savegames, so if you change a style mid-game, the preferences will be reset every time you load a game.
What you CAN do is make a separate style and apply a variable to determine which one to use.
alwaysthesamebluesky.com
- Milkymalk
- Miko-Class Veteran
- Posts: 752
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Adding a the choice to change the textbox in preferences
Sorry, I'm not particularly good with styles...
I just did know that changing styles mid-game is not a good idea because I caught that info somewhere.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- kitsalai
- Regular
- Posts: 65
- Joined: Wed Jan 08, 2014 11:05 pm
- Projects: Imaginatum
- Location: US
- Contact:
Re: Adding a the choice to change the textbox in preferences
You make a good point. However, it isn't hard to save a variable eg "style_number" in persistence and add a conditional statement in the init block to select the saved style at run time. Not sure if there's any tutorials on this but it's definitely possible.Milkymalk wrote:Styles aren't part of savegames, so if you change a style mid-game, the preferences will be reset every time you load a game.
What you CAN do is make a separate style and apply a variable to determine which one to use.
I wrote some code for this cause I was curious. It works like crap because when you click on the style button, it exits the perference screen. I couldn't find how to execute python statements from screen actions so it's really dirty... Anyway, here it is:crimsonnight wrote:I don't think it's a massive deal if it's reset every time to be honest, it's a short novel, so it shouldn't be too much of a hassle. Thanks for the advice - how would I go about doing that exactly? I know the coding used for preferences is quite different.
screens.rpy:
Code: Select all
screen preferences():
...
frame:
style_group "pref"
has vbox
label _("Style")
textbutton _("Style 1") action Jump('pick_style1')
textbutton _("Style 2") action Jump('pick_style2')Code: Select all
label pick_style1:
$style.window.background = Frame("background1.png", 12, 12)
$style.rebuild()
return
label pick_style2:
$style.window.background = Frame("background2.png", 12, 12)
$style.rebuild()
return-
crimsonnight
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Adding a the choice to change the textbox in preferences
That's great, thanks a lot for taking the timekitsalai wrote:You make a good point. However, it isn't hard to save a variable eg "style_number" in persistence and add a conditional statement in the init block to select the saved style at run time. Not sure if there's any tutorials on this but it's definitely possible.Milkymalk wrote:Styles aren't part of savegames, so if you change a style mid-game, the preferences will be reset every time you load a game.
What you CAN do is make a separate style and apply a variable to determine which one to use.
I wrote some code for this cause I was curious. It works like crap because when you click on the style button, it exits the perference screen. I couldn't find how to execute python statements from screen actions so it's really dirty... Anyway, here it is:crimsonnight wrote:I don't think it's a massive deal if it's reset every time to be honest, it's a short novel, so it shouldn't be too much of a hassle. Thanks for the advice - how would I go about doing that exactly? I know the coding used for preferences is quite different.
screens.rpy:anywhere you want (might be good to put it with your other styles):Code: Select all
screen preferences(): ... frame: style_group "pref" has vbox label _("Style") textbutton _("Style 1") action Jump('pick_style1') textbutton _("Style 2") action Jump('pick_style2')Code: Select all
label pick_style1: $style.window.background = Frame("background1.png", 12, 12) $style.rebuild() return label pick_style2: $style.window.background = Frame("background2.png", 12, 12) $style.rebuild() return
alwaysthesamebluesky.com
-
crimsonnight
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Adding a the choice to change the textbox in preferences
Actually, would it also be possible to also change the name boxes for the different characters (to plain versions) using an if statement or something?
*EDIT* Here's what I've tried:
It only seems to be only picking up the style set for the characters under 'label pick_style2:', (I'm guessing because it's later in the script,) even if I change the preference to 'pick_style2'. I guess instead of the 'define' command, I need one that'll update the defined characters?
*EDIT* Here's what I've tried:
Code: Select all
define narrator = Character(None, what_outlines=my_n)
define stw = Character(None, show_two_window=True)
define k = Character("Kira", color="#ffffff", kind=stw, what_outlines=my_k, show_custom_who_background="Namebox1.png", who_outlines = [(3, "#b6a472", 0, 0)],)
define k2 = Character(None, what_outlines=my_k)
define r = DynamicCharacter("player_name", color="#ffffff", show_two_window=True, what_outlines=my_r, show_custom_who_background="Namebox2.png", who_outlines = [(3, "#79003f", 0, 0)],)
define g = Character("Grant", color="#ffffff", kind=stw, what_outlines=my_g, show_custom_who_background="Namebox2.png", who_outlines = [(3, "#50697f", 0, 0)],)
define gs = Character("Kimmy", color="#ffffff", kind=stw, what_outlines=my_gs, show_custom_who_background="Namebox2.png", who_outlines = [(3, "#c95f8c", 0, 0)],)
label pick_style1:
$style.window.background = Frame("Textbox1.png", 12, 12)
define k = Character("Kira", color="#ffffff", kind=stw, what_outlines=my_k, show_custom_who_background="Namebox1.png", who_outlines = [(3, "#b6a472", 0, 0)],)
define k2 = Character(None, what_outlines=my_k)
define r = DynamicCharacter("player_name", color="#ffffff", show_two_window=True, what_outlines=my_r, show_custom_who_background="Namebox2.png", who_outlines = [(3, "#79003f", 0, 0)],)
define g = Character("Grant", color="#ffffff", kind=stw, what_outlines=my_g, show_custom_who_background="Namebox2.png", who_outlines = [(3, "#50697f", 0, 0)],)
define gs = Character("Kimmy", color="#ffffff", kind=stw, what_outlines=my_gs, show_custom_who_background="Namebox2.png", who_outlines = [(3, "#c95f8c", 0, 0)],)
$style.rebuild()
return
label pick_style2:
$style.window.background = Frame("Textbox2.png", 12, 12)
define k = Character("Kira", color="#ffffff", kind=stw, what_outlines=my_k, show_custom_who_background="Namebox1A.png", who_outlines = [(3, "#b6a472", 0, 0)],)
define k2 = Character(None, what_outlines=my_k)
define r = DynamicCharacter("player_name", color="#ffffff", show_two_window=True, what_outlines=my_r, show_custom_who_background="Namebox2A.png", who_outlines = [(3, "#79003f", 0, 0)],)
define g = Character("Grant", color="#ffffff", kind=stw, what_outlines=my_g, show_custom_who_background="Namebox2A.png", who_outlines = [(3, "#50697f", 0, 0)],)
define gs = Character("Kimmy", color="#ffffff", kind=stw, what_outlines=my_gs, show_custom_who_background="Namebox2A.png", who_outlines = [(3, "#c95f8c", 0, 0)],)
$style.rebuild()
returnalwaysthesamebluesky.com
- kitsalai
- Regular
- Posts: 65
- Joined: Wed Jan 08, 2014 11:05 pm
- Projects: Imaginatum
- Location: US
- Contact:
Re: Adding a the choice to change the textbox in preferences
The define command is analogous to changing a variable's value but only works at runtime. I heard it's more robust.
Anyway, use $g = ... in your labels and it should work.
Anyway, use $g = ... in your labels and it should work.
-
crimsonnight
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Adding a the choice to change the textbox in preferences
So like this for example?:kitsalai wrote:The define command is analogous to changing a variable's value but only works at runtime. I heard it's more robust.
Anyway, use $g = ... in your labels and it should work.
Code: Select all
$g = Character("Grant", color="#ffffff", kind=stw, what_outlines=my_g, show_custom_who_background="Namebox2A.png", who_outlines = [(3, "#50697f", 0, 0)],)*EDIT* My bad, it does work, it just doesn't switch instantly - also, if you scroll backwards at any point, it reverts to the default definitions. Any idea on a way around this? It's just a small bug though, so don't worry too much.
Cheers,
alwaysthesamebluesky.com
- SinnyROM
- Regular
- Posts: 166
- Joined: Mon Jul 08, 2013 12:25 am
- Projects: Blue Birth
- Organization: Cosmic Static Games
- Contact:
Re: Adding a the choice to change the textbox in preferences
The style can stay changed by using a persistent variable, even with rollback, but it'll be the same throughout all saves.
I think this may be easier in screen language, but it does make the say screen script look bloated. I gave this a try and it works (using coloured Frames - same idea though).
This is only with the textbox/namebox background image - if this works out for you, you can edit it to add the outlines too.
A good way I thought of would be to create styles for each and instead of changing the background for each if result, it would change the style instead. But I can't get it working for the what textbox. It works for the who namebox though, so it's not me, I hope! I might take another stab at this and figure out a better way.
I think this may be easier in screen language, but it does make the say screen script look bloated. I gave this a try and it works (using coloured Frames - same idea though).
This is only with the textbox/namebox background image - if this works out for you, you can edit it to add the outlines too.
A good way I thought of would be to create styles for each and instead of changing the background for each if result, it would change the style instead. But I can't get it working for the what textbox. It works for the who namebox though, so it's not me, I hope! I might take another stab at this and figure out a better way.
Code: Select all
### script.rpy
# Declare characters used by this game.
define e = Character('Eileen')
define k = Character('Kira')
# The game starts here.
label start:
e "You've created a new Ren'Py game."
e "Once you add a story, pictures, and music, you can release it to the world!"
k "The textbox should change because I'm talking."
e "The textbox changes back."
return
Code: Select all
### screens.rpy (say)
init python:
# Default style
persistent.style = "1"
init python:
# namebox1 = "Namebox1.png"
namebox1 = Frame("#f00",0,0)
namebox2 = Frame("#00f",0,0)
namebox1A = Frame("#f008",0,0)
namebox2A = Frame("#00f8",0,0)
# textbox1 = "Textbox1.png"
textbox1 = Frame("#ff0",0,0)
textbox2 = Frame("#0ff",0,0)
textbox1A = Frame("#ff08",0,0)
textbox2A = Frame("#0ff8",0,0)
screen say(who, what, side_image=None, two_window=False):
if who:
window:
style "say_who_window"
if persistent.style == "1":
if who == "Kira":
background namebox1
else:
background namebox2
else:
if who == "Kira":
background namebox1A
else:
background namebox2A
text who:
id "who"
window:
id "window"
if persistent.style == "1":
if who == "Kira":
background textbox1
else:
background textbox2
else:
if who == "Kira":
background textbox1A
else:
background textbox2A
vbox:
style "say_vbox"
text what id "what"
Code: Select all
### screens.rpy (preferences)
screen preferences():
# ...
# Add this wherever you want
frame:
has vbox
text "Textbox Style"
textbutton "Style 1" action SetField(persistent, "style", "1")
textbutton "Style 2" action SetField(persistent, "style", "2")-
crimsonnight
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Adding a the choice to change the textbox in preferences
Thanks a lot for this, and apologies for the delay. I've added the code, but when starting the game I'm getting the following error:SinnyROM wrote:The style can stay changed by using a persistent variable, even with rollback, but it'll be the same throughout all saves.
I think this may be easier in screen language, but it does make the say screen script look bloated. I gave this a try and it works (using coloured Frames - same idea though).
This is only with the textbox/namebox background image - if this works out for you, you can edit it to add the outlines too.
A good way I thought of would be to create styles for each and instead of changing the background for each if result, it would change the style instead. But I can't get it working for the what textbox. It works for the who namebox though, so it's not me, I hope! I might take another stab at this and figure out a better way.Code: Select all
### script.rpy # Declare characters used by this game. define e = Character('Eileen') define k = Character('Kira') # The game starts here. label start: e "You've created a new Ren'Py game." e "Once you add a story, pictures, and music, you can release it to the world!" k "The textbox should change because I'm talking." e "The textbox changes back." returnCode: Select all
### screens.rpy (say) init python: # Default style persistent.style = "1" init python: # namebox1 = "Namebox1.png" namebox1 = Frame("#f00",0,0) namebox2 = Frame("#00f",0,0) namebox1A = Frame("#f008",0,0) namebox2A = Frame("#00f8",0,0) # textbox1 = "Textbox1.png" textbox1 = Frame("#ff0",0,0) textbox2 = Frame("#0ff",0,0) textbox1A = Frame("#ff08",0,0) textbox2A = Frame("#0ff8",0,0) screen say(who, what, side_image=None, two_window=False): if who: window: style "say_who_window" if persistent.style == "1": if who == "Kira": background namebox1 else: background namebox2 else: if who == "Kira": background namebox1A else: background namebox2A text who: id "who" window: id "window" if persistent.style == "1": if who == "Kira": background textbox1 else: background textbox2 else: if who == "Kira": background textbox1A else: background textbox2A vbox: style "say_vbox" text what id "what"Code: Select all
### screens.rpy (preferences) screen preferences(): # ... # Add this wherever you want frame: has vbox text "Textbox Style" textbutton "Style 1" action SetField(persistent, "style", "1") textbutton "Style 2" action SetField(persistent, "style", "2")
Code: Select all
While running game code:
File "game/script.rpy", line 2193, in script
g "Are you going on this adventure as a male or female?"
Exception: Unknown keyword arguments: custom_who_backgroundalwaysthesamebluesky.com
- SinnyROM
- Regular
- Posts: 166
- Joined: Mon Jul 08, 2013 12:25 am
- Projects: Blue Birth
- Organization: Cosmic Static Games
- Contact:
Re: Adding a the choice to change the textbox in preferences
Could you post your code surrounding the error line, line 2193? Also how you changed the say screen, and if you changed how you defined your characters.
-
crimsonnight
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Adding a the choice to change the textbox in preferences
I have changed anything yet, I've just added the code as-is for now to try and get it working first.SinnyROM wrote:Could you post your code surrounding the error line, line 2193? Also how you changed the say screen, and if you changed how you defined your characters.
Here's the traceback:
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 2193, in script
g "Are you going on this adventure as a male or female?"
Exception: Unknown keyword arguments: custom_who_background
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 2193, in script
g "Are you going on this adventure as a male or female?"
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\ast.py", line 593, in execute
renpy.exports.say(who, what, interact=self.interact)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\exports.py", line 1021, in say
who(what, interact=interact)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\character.py", line 826, in __call__
self.do_display(who, what, cb_args=self.cb_args, **display_args)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\character.py", line 688, in do_display
**display_args)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\character.py", line 465, in display_say
what_text = show_function(who, what_string)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\character.py", line 672, in do_show
**self.show_args)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\character.py", line 275, in show_display_say
return renpy.display.screen.get_widget(screen, "what", layer)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\display\screen.py", line 988, in get_widget
screen.update()
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\display\screen.py", line 556, in update
self.screen.function(**self.scope)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\ast.py", line 148, in apply_arguments
return parameters.apply(args, kwargs, ignore_errors)
File "G:\Google Drive\Crimson Night LTD\Always The Same Blue Sky\Visual Novel Project\Ren'Py\Ren'Py\renpy\ast.py", line 136, in apply
raise Exception("Unknown keyword arguments: %s" % ( ", ".join(values.keys())))
Exception: Unknown keyword arguments: custom_who_background
Windows-8-6.2.9200
Ren'Py 6.99.4.467
Always The Same Blue Sky... 2.16
Code: Select all
return
label startchoices:
g "Are you going on this adventure as a male or female?"
menu:
"♂ Male":
$ gender = 0
$ steam.unlock_achievement('Mars')
$ achievement.grant("Mars")
"♀ Female":
$ gender = 1
$ steam.unlock_achievement('Venus')
$ achievement.grant("Venus")alwaysthesamebluesky.com
- trooper6
- Lemma-Class Veteran
- Posts: 3712
- Joined: Sat Jul 09, 2011 10:33 pm
- Projects: A Close Shave
- Location: Medford, MA
- Contact:
Re: Adding a the choice to change the textbox in preferences
The error says the problem is an "unknown keyword custom_who_background"
So that says to me, you have used the keyword custom_who_background without defining it.
So, where do you use custom_who_background?
Where do you define it? Do you define it?
So that says to me, you have used the keyword custom_who_background without defining it.
So, where do you use custom_who_background?
Where do you define it? Do you define it?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?) Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

