Puzzled Over A Censor Toggle

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
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Puzzled Over A Censor Toggle

#1 Post by Obscura »

I'm wondering about the efficiency of the following setup and whether it makes logical sense.

The art folder contains 100 drawings all with unique names:
john_1.jpg,
john_2.jpg
sam_1.jpg, etc.

Also in the folder: 100 censored versions of those same drawings.

censored_john_1.jpg,
censored_john_2.jpg
censored_sam_1.jpg, etc.

The code:

Code: Select all


init -1 python: 
  if persistent.censored is None:
    persistent.censored = True
   else:
    persistent.censored = False

screen adult_preference:
  # bunch of code here, but basically the player, at any point
  # in time, can use a button to set persistent.censored to True or False
  
init python:

#### ***
  if persistent.censored:
    def cg(guyname, guy_number):
      global guy_name, guy_number
      guy_name, guy_number = "censored_"+guyname, guynumber
   
   else:
     def cg(guyname, guy_number):
       global guy_name, guy_number
       guy_name, guy_number = guyname, guynumber
       
    image cgcomposite:
      Live Composite(
        (1200, 800),
        (0,0), "cgs/%s_%s.jpg"%(guy_name, guy_number),
        #...+ lots of other layers)

#### ***

label start:

"Naked guy is naked."

$cg("john","1")
show cgcomposite with fade

"Naked guy is naked again."

$cg("john","2")
show cgcomposite with fade
Question:

The censor toggle seems before the game starts and mid-game as well, but I'm not sure this was the most logical way to code this. For example:

1. do I want to use "WHILE persistent.censored" instead of "IF persistent.censored"?

2. Should I be using the code below instead of everything between the ####*** above or are they essentially the same?

Code: Select all


    def cgi(guyname, cgnumber):
            if persistent.censored:
                global guy_name,cg_number
                guy_name,cg_number="x_"+guyname,cgnumber
            else:
                global guy_name,cg_number
                guy_name,cg_number=guyname,cgnumber
Still learning the nuances. Thanks!
Coming Out On Top - An Adult Gay Dating Sim
website

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Puzzled Over A Censor Toggle

#2 Post by Remix »

My viewpoint would be to make persistent.censored a string ( of either "" or "censored_" ) then compose your composites to include that in the image part names

Code: Select all

default persistent.censored = "censored_"

image cgcomposite = Composite(
    (1200, 800),
    (0,0), "cgs/[persistent.censored][guy_name]_[guy_number].png",
    # etc )
Frameworks & Scriptlets:

User avatar
Obscura
Eileen-Class Veteran
Posts: 1431
Joined: Fri Mar 09, 2012 6:58 pm
Projects: Coming Out On Top
Location: United States
Contact:

Re: Puzzled Over A Censor Toggle

#3 Post by Obscura »

Thank you for the perfect suggestion, Remix! This changes everything.
Coming Out On Top - An Adult Gay Dating Sim
website

Post Reply

Who is online

Users browsing this forum: Google [Bot]