Could you show an example of how that would work?PyTom wrote:You could also set a variable, and then modify the nvl screen to check that variable and lay itself out appropriately.
[Tutorial] Customizing the NVL Textbox
Forum rules
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Do not post questions here!
This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
- PyTom
- Ren'Py Creator
- Posts: 16088
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
Without actually indenting properly, the code would look like:
You could change the top and bottom parts to use different styles, etc.
Code: Select all
screen nvl:
if nvl_style == 1:
window:
style "nvl_window"
has vbox:
style "nvl_vbox"
# Display dialogue.
for who, what, who_id, what_id, window_id in dialogue:
window:
id window_id
has hbox:
spacing 10
if who is not None:
text who id who_id
text what id what_id
# Display a menu, if given.
if items:
vbox:
id "menu"
for caption, action, chosen in items:
if action:
button:
style "nvl_menu_choice_button"
action action
text caption style "nvl_menu_choice"
else:
text caption style "nvl_dialogue"
else:
window:
style "nvl_window"
has vbox:
style "nvl_vbox"
# Display dialogue.
for who, what, who_id, what_id, window_id in dialogue:
window:
id window_id
has hbox:
spacing 10
if who is not None:
text who id who_id
text what id what_id
# Display a menu, if given.
if items:
vbox:
id "menu"
for caption, action, chosen in items:
if action:
button:
style "nvl_menu_choice_button"
action action
text caption style "nvl_menu_choice"
else:
text caption style "nvl_dialogue"
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
I can't make it work because options.rpy will not accept 2 different nvl styles.PyTom wrote:Without actually indenting properly, the code would look like:You could change the top and bottom parts to use different styles, etc.Code: Select all
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
I have used Levrex's method to have multiple NVL screens, it uses a modified nvl screen like PyTom's example but also has a callback function:
http://lemmasoft.renai.us/forums/viewto ... vl#p229973
I used the callback in that post and was able to style size/background properties like so:
Then I modified the nvl screen directly for things like font, text color, etc.
http://lemmasoft.renai.us/forums/viewto ... vl#p229973
I used the callback in that post and was able to style size/background properties like so:
Code: Select all
style.nar_nvl = Style(style.nvl_window, properties=dict(xpadding=100,ypadding=100))
style.ims = Style(style.nvl_window, properties=dict(background = "terminal_box", left_padding = 10, right_padding = 10, top_padding = 10, bottom_padding = 10, left_margin = 200, right_margin = 200, top_margin = 100, bottom_margin = 100))
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
I've been trying this method, but I keep getting errors.saguaro wrote:I have used Levrex's method to have multiple NVL screens, it uses a modified nvl screen like PyTom's example but also has a callback function:
http://lemmasoft.renai.us/forums/viewto ... vl#p229973
I used the callback in that post and was able to style size/background properties like so:
Then I modified the nvl screen directly for things like font, text color, etc.
Code: Select all
I'm sorry, but an uncaught exception occurred.
While executing init code:
File "game/script.rpy", line 50, in script
File "game/script.rpy", line 52, in python
NameError: name 'st1' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\bootstrap.py", line 286, in bootstrap
renpy.main.main()
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\main.py", line 264, in main
game.context().run(node)
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\execution.py", line 294, in run
node.execute()
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\ast.py", line 732, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\python.py", line 1358, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 52, in <module>
nvl_var = st1,
NameError: name 'st1' is not defined
Windows-7-6.1.7601-SP1
Ren'Py 6.17.3.327
1280x720 Template 0.0
Code: Select all
$ story1 = Character(None,
kind=nvl,
nvl_var = st1,
callback=speaker("story1"),
ctc="ctc_blinkNVL",
ctc_position="fixed",
)
$ story2 = Character(None,
kind=nvl,
what_color="ffffff",
callback=speaker("story2"),
ctc="ctc_blinkNVL",
ctc_position="fixed",
)
Code: Select all
init -1 python hide:
nvl_var = None
def st1(name, event, **kwargs):
global nvl_var
nvl_var = st1
speaker = renpy.curry(st1)
def st2(name, event, **kwargs):
global nvl_var
nvl_var = st2
speaker = renpy.curry(st2)
This is the simplest function that goes into "init python" block:
Code:Code: Select all
nvl_var = None def blahblah(name, event, **kwargs): global nvl_var nvl_var = name speaker = renpy.curry(blahblah)
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
You only need one callback function. 'name' is the parameter you want, as opposed to the function name. Try:
And assuming "story1" is the name of the style you want to use:
See if the above changes work for you. I last worked with this stuff during last years Nano, so someone else may be able to chime in with a better solution.
Code: Select all
init -1 python hide:
nvl_var = None
def st1(name, event, **kwargs):
global nvl_var
nvl_var = name
speaker = renpy.curry(st1)
Code: Select all
$ story1 = Character(None,
kind=nvl,
callback=speaker("story1"),
ctc="ctc_blinkNVL",
ctc_position="fixed",
)
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
The function name doesn't matter? Okay, I changed it to:saguaro wrote:You only need one callback function. 'name' is the parameter you want, as opposed to the function name. Try:
Code: Select all
init -1 python hide: nvl_var = None def st1(name, event, **kwargs): global nvl_var nvl_var = name speaker = renpy.curry(st1)
Code: Select all
init -1 python hide:
nvl_type = None
def st1(name, event, **kwargs):
global nvl_var
nvl_var = name
speaker = renpy.curry(nvl_type)
Actually, the style names are nvl1 and nvl2.And assuming "story1" is the name of the style you want to use:
Code: Select all
style.nvl1 = Style(style.nvl_window, properties=dict(
## ----------- Framed NVL box -------------------
# style.nvl_window.background = Frame("ui/NVLbox.png", 0, 0),
## ---------- No Frame Nvl Box--------------------
background = "ui/NVLbox.png",
# margins ---------------------------------
top_margin = 80,
bottom_margin = 0,
left_margin = 0,
right_margin = 0,
# padding ---------------------------------
top_padding = 80,
bottom_padding = 30,
left_padding = 780,
right_padding = 80,
))
# --------------------------------------------------------------------------------------
style.nvl2 = Style(style.nvl_window, properties=dict(
## ----------- Framed NVL box -------------------
background = Frame("ui/NVLbox2.png", 0, 0),
## ---------- No Frame Nvl Box--------------------
# background = "ui/NVLbox.png",
# margins ---------------------------------
top_margin = 80,
bottom_margin = 0,
left_margin = 0,
right_margin = 0,
# padding ---------------------------------
top_padding = 80,
bottom_padding = 30,
left_padding = 780,
right_padding = 80,
))
Code: Select all
$ story1 = Character(None,
kind=nvl,
callback=speaker("nvl1"),
ctc="ctc_blinkNVL",
ctc_position="fixed",
)
$ story2 = Character(None,
kind=nvl,
callback=speaker("nvl2"),
what_color="ffffff",
ctc="ctc_blinkNVL",
ctc_position="fixed",
)
Code: Select all
While executing init code:
File "game/script.rpy", line 50, in script
File "game/script.rpy", line 52, in python
NameError: name 'speaker' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\bootstrap.py", line 286, in bootstrap
renpy.main.main()
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\main.py", line 264, in main
game.context().run(node)
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\execution.py", line 294, in run
node.execute()
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\ast.py", line 732, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\python.py", line 1358, in py_exec_bytecode
exec bytecode in globals, locals
File "game/script.rpy", line 52, in <module>
callback=speaker("nvl1"),
NameError: name 'speaker' is not defined
Windows-7-6.1.7601-SP1
Ren'Py 6.17.3.327
1280x720 Template 0.0
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
- saguaro
- Miko-Class Veteran
- Posts: 560
- Joined: Sun Feb 12, 2012 9:17 am
- Completed: Locked-In, Sunrise, The Censor
- Organization: Lucky Special Games
- itch: saguarofoo
- Location: USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
While I was messing with this I found the new version of Ren'Py throws a RevertableDict error for me that I think is related to the python styling, so head's up? But below works for me in 6.15, just also include the styles you posted.
Code: Select all
init python:
nvl_var = None
def st1(name, event, **kwargs):
global nvl_var
nvl_var = name
speaker = renpy.curry(st1)
# Declare characters used by this game.
define story1 = Character(None, kind=nvl, callback=speaker("nvl1"))
define story2 = Character(None, kind=nvl, callback=speaker("nvl2"),what_color="#c8ffc8")
##############################################################################
# Nvl
#
# Screen used for nvl-mode dialogue and menus.
# http://www.renpy.org/doc/html/screen_special.html#nvl
screen nvl:
if nvl_var == "nvl1":
window:
style "nvl1"
has vbox:
style "nvl_vbox"
# Display dialogue.
for who, what, who_id, what_id, window_id in dialogue:
window:
id window_id
has hbox:
spacing 10
if who is not None:
text who id who_id
text what id what_id
# Display a menu, if given.
if items:
vbox:
id "menu"
for caption, action, chosen in items:
if action:
button:
style "nvl_menu_choice_button"
action action
text caption style "nvl_menu_choice"
else:
text caption style "nvl_dialogue"
add SideImage() xalign 0.0 yalign 1.0
use quick_menu
else:
window:
style "nvl2"
has vbox:
style "nvl_vbox"
# Display dialogue.
for who, what, who_id, what_id, window_id in dialogue:
window:
id window_id
has hbox:
spacing 10
if who is not None:
text who id who_id
text what id what_id
# Display a menu, if given.
if items:
vbox:
id "menu"
for caption, action, chosen in items:
if action:
button:
style "nvl_menu_choice_button"
action action
text caption style "nvl_menu_choice"
else:
text caption style "nvl_dialogue"
add SideImage() xalign 0.0 yalign 1.0
use quick_menu
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
So... In other words, it used to work, but not anymore? (Back to square one...) LOL!saguaro wrote:While I was messing with this I found the new version of Ren'Py throws a RevertableDict error for me that I think is related to the python styling, so head's up? But below works for me in 6.15, just also include the styles you posted.
-- Thank you for trying so hard, but I don't think we can call this a viable solution. It Does work, but I seriously doubt anyone wants to go back to using a previous version of renpy just to do this. It's also a lot more complicated than the solution I originally suggested, (using a blank png for the nvl background, setting up the text padding in the nvl character definitions then showing the individual nvl boxes as needed.) It may not be so...automated, but it's easier for a beginner to actually use without messing something up.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
-
- Regular
- Posts: 161
- Joined: Wed Feb 19, 2014 5:05 pm
- Completed: Mage Wars
- Projects: Falling Star
- Organization: Star Guide
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
Hey thanks for this, it's helpful! But I just have one issue. An error occurred which said it expected a 'word' between style and .nvl_windows.background.
Also am I supposed to put the code in the game folder or was that just for the image?
Also am I supposed to put the code in the game folder or was that just for the image?
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
I'll need to see your code and the error message to tell you what isn't working right.dmasterxd wrote:Hey thanks for this, it's helpful! But I just have one issue. An error occurred which said it expected a 'word' between style and .nvl_windows.background.
The code goes in the same folder all your other code goes in. The image goes in the same folder your other images go in.dmasterxd wrote:Also am I supposed to put the code in the game folder or was that just for the image?
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
-
- Regular
- Posts: 161
- Joined: Wed Feb 19, 2014 5:05 pm
- Completed: Mage Wars
- Projects: Falling Star
- Organization: Star Guide
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
Okay here it is.
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
You have two problems here.
1) You cannot have style.nvl_window.background under a plain ordinary init: for the same reason you can't have config under one -- they're both written in Python. Copy/paste that whole line into your options.rpy page right under the rest of your textbox styles.
2) those numbers at the end of your code stand for space allowance for the CORNERS of a frame.
Example: This frame's corners need 51 pixels of allowance to keep the corners from stretching along with the rest of the frame.
Unless your textbox image has a Design on the corners, use '0' for both those numbers.
If you don't want the box to stretch at all, write it this way:
1) You cannot have style.nvl_window.background under a plain ordinary init: for the same reason you can't have config under one -- they're both written in Python. Copy/paste that whole line into your options.rpy page right under the rest of your textbox styles.
2) those numbers at the end of your code stand for space allowance for the CORNERS of a frame.
Example: This frame's corners need 51 pixels of allowance to keep the corners from stretching along with the rest of the frame.
Code: Select all
init -1 python hide:
## Frames ----------------------------------------------
style.frame.background = Frame("ui/frame.png",51,51) # numbers are size of corners, 'ui' is the name of the folder the image is in.
Code: Select all
init -1 python hide:
## Frame ------------------------
style.nvl_window.background = Frame("ui/NVLbox.png", 0, 0) # ui/ is the name of the folder the image is in.
Code: Select all
init -1 python hide:
## No Frame --------------------
style.nvl_window.background = "ui/NVLbox.png" # ui/ is the name of the folder the image is in.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
-
- Miko-Class Veteran
- Posts: 745
- Joined: Fri Nov 02, 2012 8:41 am
- Projects: Red eyes in the darkness
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
As this thread has been a livesaver time and again for me: Many of the things mentioned here won't work any longer in the current version of renpy, as nvl has changed a lot there. A new file: gui.rpy has been introduced which defines the values and many of the old style. need to be replaced with gui. in order to work again.
code example in the gui.rpy:
code example in the gui.rpy:
Code: Select all
## The borders of the background of the NVL-mode background window.
define gui.nvl_borders = Borders(0, 10, 0, 20)
## The height of an NVL-mode entry. Set this to None to have the entries
## dynamically adjust height.
define gui.nvl_height = 115
## The spacing between NVL-mode entries when gui.nvl_height is None, and between
## NVL-mode entries and an NVL-mode menu.
define gui.nvl_spacing = 10
## The position, width, and alignment of the label giving the name of the
## speaking character.
define gui.nvl_name_xpos = 430
define gui.nvl_name_ypos = 0
define gui.nvl_name_width = 150
define gui.nvl_name_xalign = 1.0
## The position, width, and alignment of the dialogue text.
define gui.nvl_text_xpos = 450
define gui.nvl_text_ypos = 8
define gui.nvl_text_width = 590
define gui.nvl_text_xalign = 0.0
## The position, width, and alignment of nvl_thought text (the text said by the
## nvl_narrator character.)
define gui.nvl_thought_xpos = 240
define gui.nvl_thought_ypos = 0
define gui.nvl_thought_width = 780
define gui.nvl_thought_xalign = 0.0
## The position of nvl menu_buttons.
define gui.nvl_button_xpos = 450
define gui.nvl_button_xalign = 0.0
- OokamiKasumi
- Eileen-Class Veteran
- Posts: 1779
- Joined: Thu Oct 14, 2010 3:53 am
- Completed: 14 games released -- and Counting.
- Organization: DarkErotica Games
- Deviantart: OokamiKasumi
- Location: NC, USA
- Contact:
Re: [Tutorial] Customizing the NVL Textbox
Glad to be of service!Ryue wrote:As this thread has been a livesaver time and again for me...
Thank you so much for this!Ryue wrote:Many of the things mentioned here won't work any longer in the current version of renpy, as nvl has changed a lot there. A new file: gui.rpy, has been introduced which defines the values and many of the old style. need to be replaced with gui. in order to work again.
-- I haven't bothered to figure out the adjustments to the New GUI style because: Laziness. The default style allows me to adjust just about everything I generally mess with. I have about half a dozen or so working Test games that I copy-paste all my coding from. So yeah: Laziness.
Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed:
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Most recent Games Completed:
- The Walk[Psychological][NanoWinter] ~ PG New!
- Trap! [ModernFantasy][VN] ~ PG16
- The Adventures of Prince Ivan [Fant/Adv/VN] ~ PG
"No amount of great animation will save a bad story." -- John Lasseter of Pixar
Who is online
Users browsing this forum: No registered users