[SOLVED] How to show a Notify screen when player points at some words in a textbox?
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.
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
[SOLVED] How to show a Notify screen when player points at some words in a textbox?
Hello there! I already have some semi-complex mechanics related to hovering things and showing Notify screen with a variable-based text, but I would like to find out if there is an option to introduce something like this:
player sees dialogue textbox with some text, something like
"blah blah blah Random Words blah blah blah"
and if the player points their mouse at "Random Words" that belong to this text, the notify screen will appear with a customized text. Ideally, variable based.
My programming skills are quite limited, so do you know a way to do this without rewriting the entire engine?
player sees dialogue textbox with some text, something like
"blah blah blah Random Words blah blah blah"
and if the player points their mouse at "Random Words" that belong to this text, the notify screen will appear with a customized text. Ideally, variable based.
My programming skills are quite limited, so do you know a way to do this without rewriting the entire engine?
Last edited by Aureus on Sun Mar 04, 2018 4:36 pm, edited 3 times in total.
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.
- Ocelot
- Lemma-Class Veteran
- Posts: 2400
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
You can (ab)use a tag for that:
Create a new project, then do the following:
First, change default style in screens.rpy:(If anyone knows the names of default first two functions for hyperlink_functions, let me know)
It will disable ability to click on embedded links, so, if you need that, let me know, and I will think of the solution.
Then, replace script.rpy content with this:
Test it.
Create a new project, then do the following:
First, change default style in screens.rpy:
Code: Select all
style default:
properties gui.text_properties()
language gui.language
hyperlink_functions (lambda x: style.hyperlink_text, None, notifier)
It will disable ability to click on embedded links, so, if you need that, let me know, and I will think of the solution.
Then, replace script.rpy content with this:
Code: Select all
init python:
def notifier(arg):
data = arg.split(':')
if data[0] == 'notify':
renpy.show_screen('notify', data[1])
renpy.restart_interaction()
label start:
"You've created a new {a=notify:Ren'Py is a cool VN creation engine!}Ren'Py{/a} game."
"Once you add a story, pictures, and music, you can release it to the world!"
return
< < insert Rick Cook quote here > >
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
That's absolutely amazing. Thank you so much.
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
Uh... I have a problem. : )
It still kind of works, but if I use notify for some other thing, and then try to use the solution from above, the game crashes.
I made a gif showing how does it look like.
Any ideas? : (
It still kind of works, but if I use notify for some other thing, and then try to use the solution from above, the game crashes.
I made a gif showing how does it look like.
Any ideas? : (
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/dialogues/fabel_day1bstabulus.rpy", line 118, in script
stab "Some cities, like {a=notify:Vates took me to Berytus only once, and after a week this place gave me a headache. There is so much going on, so many people come and go every day, so many things to do... But there is also so loud I couldn’t hear my own thoughts.}Berytus{/a}, have huge ironworks where temperatures are so high they can melt even the cold iron, what for many centuries was thought to be impossible."
File "game/script.rpy", line 153, in notifier
data = arg.split(':')
AttributeError: 'NoneType' object has no attribute 'split'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/dialogues/fabel_day1bstabulus.rpy", line 118, in script
stab "Some cities, like {a=notify:Vates took me to Berytus only once, and after a week this place gave me a headache. There is so much going on, so many people come and go every day, so many things to do... But there is also so loud I couldn’t hear my own thoughts.}Berytus{/a}, have huge ironworks where temperatures are so high they can melt even the cold iron, what for many centuries was thought to be impossible."
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\ast.py", line 643, in execute
renpy.exports.say(who, what, interact=self.interact, *args, **kwargs)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\exports.py", line 1176, in say
who(what, *args, **kwargs)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\character.py", line 1013, in __call__
self.do_display(who, what, cb_args=self.cb_args, **display_args)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\character.py", line 817, in do_display
**display_args)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\character.py", line 566, in display_say
rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\ui.py", line 287, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\display\core.py", line 2624, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\display\core.py", line 3414, in interact_core
rv = renpy.display.focus.mouse_handler(ev, x, y)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\display\focus.py", line 385, in mouse_handler
return change_focus(new_focus, default=default)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\display\focus.py", line 333, in change_focus
current.unfocus(default=default)
File "C:\Users\Aureus\Desktop\renpy-6.99.14.1-sdk\renpy\text\text.py", line 1678, in unfocus
return hyperlink_focus(None)
File "game/script.rpy", line 153, in notifier
data = arg.split(':')
AttributeError: 'NoneType' object has no attribute 'split'
Windows-8-6.2.9200
Ren'Py 6.99.14.1.3218
0.1
Wed Feb 28 17:46:10 2018
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.
- Ocelot
- Lemma-Class Veteran
- Posts: 2400
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
Change notifier function:
Code: Select all
# . . .
def notifier(arg):
if arg is None:
return
data = arg.split(':')
# . . .
< < insert Rick Cook quote here > >
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
Thank you, Ocelot, it's almost there! Currently, the part where the game was crashing out is replaced with highlighting and underlining the word and showing no Notify screen at all. The game doesn't crash and I can show the Notify message during the next attempt (even on the same word), but I was wondering if you have a solution how to make it more fluent. (In other words - how to avoid this "nothing happens" pause.)
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
Bump! : )
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.
- Ocelot
- Lemma-Class Veteran
- Posts: 2400
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
Notify screen was not created to handle stuff like that. Maybe problem is in that, maybe something with how you display it for your name. It is hard to say exactly. Can you make an SSCCE?
< < insert Rick Cook quote here > >
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
I never heard about it, but I think I can do this - tomorrow or the day after tomorrow, my hands are currently completely full. Nevertheless, thank you very much for your help.
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
So... Here is the build with the bug description. The most important parts of the code:
Code: Select all
from Script:
define au = Character("Aure")
define aur = Character("Aureus") # to see that it works for more than one name
default npcs.speaker = None # npcs.speaker is taken from "say screen" with: "if who is not None: / on 'show' action SetField(npcs, 'speaker', who)"
default npcdescription = 0 # the button activating the Notify screen is activated only if npcdescription != 0
init python:
def notifier(arg): #from the style default: "hyperlink_functions (lambda x: style.hyperlink_text, None, notifier)". it replaces the basic links
if arg is None:
return
data = arg.split(':')
if data[0] == 'notify':
renpy.show_screen('notify', data[1])
renpy.restart_interaction()
label start:
show screen button_hover_example # the screen that shows hovering
$ npcdescription = 0
$ npcs.speaker = None
$ npcs = {"Aure" : "Hovering works fine!", "Aureus" : "Even with a different name!"} # we attach shown names to their descriptions
scene bg room
# first we have an empty message, so the game can start without crying that "npc.speaker" is unknown
au "Hi there! So here is my bug description, at first everything works fine:"
$ npcdescription = 1
au "1) Please point your mouse at my namebox. As you can see, it's showing the Notify screen whenever you hover it!"
au "2) Now, please point your mouse at {a=notify:Link also works fine!}this link{/a}. It does nothing when clicked, but it also shows a new Notify screen! Cool!"
# {a=notify:message}name{/a}
aur "3) Also, if you hover {a=notify:Link is still cool!}this link{/a} first and the namebox second, it all works as intended!"
# the bug starts here
au "4) However... if you first point on my namebox and then {a=notify:See the bug? : (}this link{/a}, at first it highlights the text and doesn't show Notify screen at all. You need to re-hover it to show the Notify screen."
aur "I can live with that, but it is really annoying and will confuse my players. : ( Can you help me?"
$ npcdescription = 0
au "Thank you so much for your time!"
return
Code: Select all
from Screens:
style default:
properties gui.text_properties()
language gui.language
hyperlink_functions (lambda x: style.hyperlink_text, None, notifier) ## MY CHANGES
####### NPC DESCRIPTION MENU - MY CHANGES
# show screen button_hover_example
screen button_hover_example():
if npcdescription != 0:
if (npcs[npcs.speaker]) != 0:
button:
xpos gui.name_xpos
xanchor gui.name_xalign
xsize gui.namebox_width
ypos 865 #1467
ysize gui.namebox_height
action Null
hovered Notify(npcs[npcs.speaker])
unhovered Hide('notify')
screen say(who, what):
style_prefix "say"
if who is not None:
on 'show' action SetField(npcs, 'speaker', who) ## MY CHANGES
window:
id "window"
if who is not None:
window:
id "namebox"
style "namebox"
text who id "who"
text what id "what"
- Attachments
-
- ScreenBug1-1.0-pc.zip
- (28.5 MiB) Downloaded 19 times
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.
- Ocelot
- Lemma-Class Veteran
- Posts: 2400
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
Remove unhovered Hide('notify') function. Notify screen hides itself. I think, it happens because for some reason your button start taking whole screen and button unhovered even fired after link hovered event. Strange.
https://i.imgur.com/OhFycWj.png
https://i.imgur.com/OhFycWj.png
< < insert Rick Cook quote here > >
- Aureus
- Veteran
- Posts: 278
- Joined: Sun Aug 06, 2017 4:49 am
- Completed: The Tavern, Tales From Windy Meadow
- Projects: Roadwarden
- Organization: Moral Anxiety Studio
- itch: moral-anxiety
- Location: Breslau, Poland
- Contact:
Re: How to show a Notify screen when player points at some words in a textbox?
I can't express how huge help it was for me. I spent so many hours (spread through many days) trying to make it work. Thank you, Ocelot!
Tales From Windy Meadow - slice of life, pixel art Visual Novel set in a fantasy village. now available on Steam.