ConditionSwitch and Gallery

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
User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3808
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

ConditionSwitch and Gallery

#1 Post by Imperf3kt »

I'm using ConditionSwitch to control which character image shows based on a variable called "score", different poses, outfits, etc. I eventually plan to make these animated, but that shouldn't matter.

This works great and as player score goes up and down, the image shown changes accordingly.

However I also have a gallery in my game to showcase the stuff you unlock. This works great if I just show the individual images but as this was giving me trouble with logic, I started using ConditionSwitch.
The trouble here is that this does not work well, none of the images unlock after being seen.

I scoured the documentation for some clues, but couldn't work out why, so instead looked for some kind of renpy.MarkImageAsSeen("imageName") , but didn't find anything.

The best thing I found was

Code: Select all

    show myImage
    hide myImage
But this seems hacky.

Is there any better way to do this?
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

User avatar
deltadidirac
Regular
Posts: 123
Joined: Fri Nov 30, 2018 5:00 am
Projects: Artworks and Comics
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: ConditionSwitch and Gallery

#2 Post by deltadidirac »

Imperf3kt wrote: Wed Dec 04, 2019 6:17 pm I'm using ConditionSwitch to control which character image shows based on a variable called "score", different poses, outfits, etc. I eventually plan to make these animated, but that shouldn't matter.

This works great and as player score goes up and down, the image shown changes accordingly.

However I also have a gallery in my game to showcase the stuff you unlock. This works great if I just show the individual images but as this was giving me trouble with logic, I started using ConditionSwitch.
The trouble here is that this does not work well, none of the images unlock after being seen.

I scoured the documentation for some clues, but couldn't work out why, so instead looked for some kind of renpy.MarkImageAsSeen("imageName") , but didn't find anything.

The best thing I found was

Code: Select all

    show myImage
    hide myImage
But this seems hacky.

Is there any better way to do this?
I solved my problem (perhaps not in an elegant way) giving a boolean variable to each stuff; if uou unlock is True, on contrary false; so you can use or if/else or condition switch

..... I suppose....
bye

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

Re: ConditionSwitch and Gallery

#3 Post by Imperf3kt »

No other suggestions?
Using a boolean would work, but I could probably get the same effect by using https://www.renpy.org/doc/html/rooms.ht ... lock_image

Maybe ConditionSwitch is the wrong function to use?
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

User avatar
deltadidirac
Regular
Posts: 123
Joined: Fri Nov 30, 2018 5:00 am
Projects: Artworks and Comics
Tumblr: deltadidirac
Deviantart: Deltadidirac67
Location: Europe
Contact:

Re: ConditionSwitch and Gallery

#4 Post by deltadidirac »

(sorry for the message before I crashed)
You could write a label (or a Function based on a list if you are able to do it), building one single variable and link the different value of it on each single image.

example:

Code: Select all

define img1  = "loock" 
define img2 = ..... etc...  ####### all your images will be loock at start ( but for not define every single image, you could create a function with a list to define this in one step)
define im_val == 0  ##### value == 0 no image
label list_img:
	if img_val >0:
		$ img1 == unlock
	elif img_val >1:
		$ img2 == unlock
	elif.....
		etc.......
	else:
		return  ##### in conditionSwitch you will use the variable img_val
but if you are able to create a list in witch you find all your imagine and an operation that search the img_val value and read the lable list_img to define if and how images are unlock; when you call your function, this last will do all.


Sorry if is not a clear and define msg, I hope you understand the idea...

see you

Post Reply

Who is online

Users browsing this forum: Baidu [Spider], Google [Bot], Semrush [Bot]