Disabling Left-Click Advance in Lieu of Hyperlink Navigation

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
Nephthys
Newbie
Posts: 5
Joined: Sun Jan 19, 2014 4:51 pm
Contact:

Disabling Left-Click Advance in Lieu of Hyperlink Navigation

#1 Post by Nephthys » Sun Jan 19, 2014 5:15 pm

I'm experimenting with writing a Ren'Py parser for TweeCode - a wholesale solution that would allow code from Twine to be imported and used without further modification.

To this end I'm trying to set up a system that largely avoids labels in their traditional Ren'Py usage and instead parses its own nodes that it reads from the TweeCode source - I was wondering if anyone has suggestions on what the best way to set this up would be.

The short of the question is this: I've looked at some of the previous threads on the topic of using hyperlinks with an override of the default 'config.hyperlink_callback' function. I'm using this in kind of a weird way in that I'm getting the hyperlink function to set a parameter for what scene it wants to display and always jump to the same 'blank' label, which has a function that gets the scene parameters and displays the appropriate text on the screen.

i.e. It's kind of this setup, where sceneDict is just a dictionary of single-screen labels with a string identifier such as 'start' and some text (with hyperlinks in it):

Code: Select all

    def hyperlinkCallback(hyperLink):
        global nextScene
        nextScene = hyperLink
        renpy.jump('blank')
    
    config.hyperlink_callback = hyperlinkCallback

    def playScene(scene):
        nvl_clear()
        narrator(sceneDict[scene])

label start:
    python:  
        playScene('Start')
        
label blank:
    $playScene(nextScene)
This has worked surprisingly well for me because it seems to allow saves and rollback to function correctly with no extra work.

My only problem is that left-clicking anywhere that's not a hyperlink advances the game - i.e. finishing the game because there are no more say functions left. I suspect I could circumvent this easily enough by adding a jump to 'blank' at the end of blank, but that would be a really dirty way of doing it and would probably duplicate the label lots of times in the rollback buffer =/

So ideally I'd like to figure out a way of disabling left-click to advance while keeping the hyperlinks around! Closest I've found is http://lemmasoft.renai.us/forums/viewto ... f=6&t=3461 which I've gotten to work, but it prevents me from clicking on anything - including the hyperlinks.

Alternatively, interested if anyone has a better idea on how to structure this sort of thing altogether ^^

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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: Disabling Left-Click Advance in Lieu of Hyperlink Naviga

#2 Post by PyTom » Sun Jan 19, 2014 6:06 pm

To answer the question, you'd probably want to do something like:

Code: Select all

        nvl_clear()
        narrator(sceneDict[scene], interact=False)
        ui.interact()
The interact=False will show the dialogue without interacting or calling ui.saybehavior - the result of which is that interaction is suspended.

That being said, I wonder if this is really the right approach. I think the real value here is would be from generating Ren'Py code from the Twine code, so people can then go in and edit the generated code to take advantage of Ren'Py features.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
Reikun
Miko-Class Veteran
Posts: 565
Joined: Tue Dec 20, 2011 9:57 pm
Completed: Mnemonic Devices, Ciikos Bridge, Helena's Flowers, The Madness
Projects: Fox in the Hollyhocks
Organization: skyharborr
itch: skyharborr
Contact:

Re: Disabling Left-Click Advance in Lieu of Hyperlink Naviga

#3 Post by Reikun » Sun Jan 19, 2014 6:26 pm

Have you taken a look at this topic? http://lemmasoft.renai.us/forums/viewto ... 51&t=19563

I'm not very good with code at all but maybe something there will be helpful.
ImageImageImage

fastest way to contact me: DM @skyharborr on twitter

Nephthys
Newbie
Posts: 5
Joined: Sun Jan 19, 2014 4:51 pm
Contact:

Re: Disabling Left-Click Advance in Lieu of Hyperlink Naviga

#4 Post by Nephthys » Sun Jan 19, 2014 8:43 pm

PyTom wrote:To answer the question, you'd probably want to do something like:

Code: Select all

        nvl_clear()
        narrator(sceneDict[scene], interact=False)
        ui.interact()
The interact=False will show the dialogue without interacting or calling ui.saybehavior - the result of which is that interaction is suspended.

That being said, I wonder if this is really the right approach. I think the real value here is would be from generating Ren'Py code from the Twine code, so people can then go in and edit the generated code to take advantage of Ren'Py features.
Thanks :D That's just what I was looking for. I had a feeling ui.interact() might come into it somehow, but just couldn't find anything pertinent on the matter.

I did consider going down the route of having some kind of pre-processor to generate Ren'Py code. It struck me as being somewhat needlessly complicated for my purposes - as my goal would be to keep all editing of the game script itself to within Twine, while keeping the Ren'Py side of it dedicated to handling macros, rather than having any bespoke code in it. It's enough of a task for me to write a parser for Twee, without then converting it all back into Ren'Py :?

That said, I would have preferred to do this in a more Ren'Py-ish way, creating a label for every Twine passage and using the standard structure of jumping about, but as far as I can tell there is no way to create new labels in Python at runtime?
Reikun wrote:Have you taken a look at this topic? http://lemmasoft.renai.us/forums/viewto ... 51&t=19563

I'm not very good with code at all but maybe something there will be helpful.
Thanks! I did a search to see if anyone had tried something like this before, but didn't find anything myself - this looks like it should help out in writing the Twee parser, actually, though it's taking a slightly different approach overall to what I'm doing :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], minyan