[Solved]Option to disable side sprites?

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
Vodka
Regular
Posts: 33
Joined: Sun Apr 29, 2012 10:53 pm
Contact:

[Solved]Option to disable side sprites?

#1 Post by Vodka »

How would someone go about adding a 'disable side spite' option to their game?

I'm thinking a toggle button that changes a boolean variable True/False, but how would I check against that variable?
Last edited by Vodka on Fri Apr 26, 2019 6:14 pm, edited 2 times in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Option to disable side sprites?

#2 Post by Imperf3kt »

Such a variable already exists, its found in the say screen.

A button with the action ToggleScreenVariable("var"), or ToggleVariable("var"), where var is the name of the variable that controls the side image, should do the trick.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Vodka
Regular
Posts: 33
Joined: Sun Apr 29, 2012 10:53 pm
Contact:

Re: Option to disable side sprites?

#3 Post by Vodka »

I'll give that a shot, thank you.

Vodka
Regular
Posts: 33
Joined: Sun Apr 29, 2012 10:53 pm
Contact:

Re: Option to disable side sprites?

#4 Post by Vodka »

What about this is incorrect?

say screen:

Code: Select all

screen say(who, what, side_image=None, two_window=False):

... default say code

$ side_image = SideImage()
    add side_image xalign 0.04 yalign 1.15
and then in the preferences menu:

Code: Select all

hotspot (980,418,365,40) action ToggleScreenVariable("side_image")
It's giving me an error:

Code: Select all

KeyError: u'side_image'
I take it my thinking is wrong about how the side image variable is meant to be set up?

Vodka
Regular
Posts: 33
Joined: Sun Apr 29, 2012 10:53 pm
Contact:

Re: Option to disable side sprites?

#5 Post by Vodka »

Double posting to share this:

Code: Select all

define e = Character("Eileen", image="eileen")

init python:
     config.side_image_tag = "eileen"
which i got from https://www.renpy.org/doc/html/side_image.html

If I'm reading this right, I should be able to define a python variable to associate with the side images. However, nothing I've tried seems to work for disabling it.

I will play with this more over the weekend and post an update if I figure it out.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Option to disable side sprites?

#6 Post by Imperf3kt »

Sorry, after checking the screen, the variable I was thinking of cannot be used how I imagined.

I don't have the time right now, but I'll take a look later at this more thoroughly.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Vodka
Regular
Posts: 33
Joined: Sun Apr 29, 2012 10:53 pm
Contact:

Re: Option to disable side sprites?

#7 Post by Vodka »

The issue seemed a lot easier at first glance for me. Going back to my original strategy: would it be possible to make image declarations dependent on a global variable? I could set a variable for side sprites in the main script, and then have conditional loading of images (or declaration of characters) to disable it.

Vodka
Regular
Posts: 33
Joined: Sun Apr 29, 2012 10:53 pm
Contact:

Re: Option to disable side sprites?

#8 Post by Vodka »

Okay, finally had some time to work on this and I got it.

In the Say screen:

Code: Select all

screen say(who, what, side_image=side_image, two_window=False)
...
if side_image == True:
        add SideImage() xalign 0.04 yalign 1.15
This means the side image is only displayed if the variable is True.

And then in the script, before declaring characters:

Code: Select all

side_image = True
We set the variable to be true by default. And then lastly in the options menu:

Code: Select all

hotspot (980,418,365,40) action SetVariable("side_image", False)
The only problem with this is that the game will reset the variable to True on startup, due to that second definition. Is there any way to store this variable in persistent data, and then check if it exists before setting it to True in script.py? That's really the only thing left to do with it.

Vodka
Regular
Posts: 33
Joined: Sun Apr 29, 2012 10:53 pm
Contact:

Re: Option to disable side sprites?

#9 Post by Vodka »

Turns out it was as easy as making the variable persistent.side_image and changing the option's action to ToggleVariable

Marking this solved!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot]