Hide layer?

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
ishify
Newbie
Posts: 23
Joined: Thu Aug 15, 2013 5:25 pm
IRC Nick: Ishy
Contact:

Hide layer?

#1 Post by ishify »

Hi. I have been wondering if there's a way to hide every image that is within a layer? ie: screens
ImageI'm a bored potato so come talk to me pleaseImage

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Hide layer?

#2 Post by xela »

How about scene statement over the screens layer (funny as it is, I never tried that but there should be no reason for it not to work). I know there bound to be Ren'Py script statement for this but you'll have to look for it yourself.

Code: Select all

$ renpy.scene("screens")
is the python function.
Like what we're doing? Support us at:
Image

User avatar
ishify
Newbie
Posts: 23
Joined: Thu Aug 15, 2013 5:25 pm
IRC Nick: Ishy
Contact:

Re: Hide layer?

#3 Post by ishify »

Mmm. I can't do the scene over the layer.

This is how the set up is. the life bars are on layer 'screens'
Image
And this is my dilemma during the attack phase
Image
ImageI'm a bored potato so come talk to me pleaseImage

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Hide layer?

#4 Post by xela »

I thought there was a callback function that you can use with the say statements. Can you find out if it is possible to bind hide/show screen function to it? You could supply events to it, like om show and on hide.

There are too many options here and it's almost impossible to tell which one will get the job done best just from three picture :(
Like what we're doing? Support us at:
Image

User avatar
ishify
Newbie
Posts: 23
Joined: Thu Aug 15, 2013 5:25 pm
IRC Nick: Ishy
Contact:

Re: Hide layer?

#5 Post by ishify »

Uhm. O n O I'm not code savvy so I can't really tell which syntax is which.
I come here with very little knowledge from basic c++ and is just trying to apply that in python TT - TT

Code: Select all

 # hide hp_red_scout
 # hide hp_red_demo
 # hide hp_red_spar
 
 # hide hp_green_scout
 # hide hp_green_demo
 # hide hp_green_spar

label fighter_profile:
 
    image fighter com = "character/commander.png"
    image fighter sco = "character/scout_bat.png"
    image fighter dem = "character/demo_bat.png"
    image fighter spa = "character/sparrow_bat.png"
 
init:

    # there's always only 1 enemy
    $ en_life = 5
    $ en_type ="Tech"
    $ en_move ="Tech"
    
    #unit lives
    $ dem_life = 10
    $ spa_life = 10
    $ sco_life = 10
    
    $ command = ""
    
    #=========== enemy inflict player damage ===========================================================================
    define EN_DAMAGE = [("Wild", "Tech"), ("Tech", "Ammo"), ("Ammo", "Wild")]
    
    #=========== player inflicts enemy damage ==========================================================================
    define INFLICT_HIGH = [("Wild", "Tech"), ("Tech", "Ammo"), ("Ammo", "Wild")]
    define INFLICT_LOW = [("Wild", "Wild"), ("Tech", "Tech"), ("Ammo", "Ammo")]
    
label update_stat:

    hide fighter with moveoutright
    show fighter com behind battlebox, hp_green_scout, hp_green_demo, hp_green_spar, hp_red_spar, hp_red_demo, hp_red_scout at right with moveinright

    show hp_red_scout at hp_scout 
    show hp_red_demo at hp_demo
    show hp_red_spar at hp_sparrow

    label sco_life: 
        if sco_life==10:
            show hp_green_scout at hp_scout onlayer screens
        elif sco_life==9:
            show hp_green_scout 9 at hp_scout onlayer screens
        elif sco_life==8:
            show hp_green_scout 8 at hp_scout onlayer screens
        elif sco_life==7:
            show hp_green_scout 7 at hp_scout onlayer screens
        elif sco_life==6:
            show hp_green_scout 6 at hp_scout onlayer screens
        elif sco_life==5:
            show hp_green_scout 5 at hp_scout onlayer screens
        elif sco_life==4:
            show hp_green_scout 4 at hp_scout onlayer screens
        elif sco_life==3:
            show hp_green_scout 3 at hp_scout onlayer screens
        elif sco_life==2:
            show hp_green_scout 2 at hp_scout onlayer screens
        elif sco_life==1:
            show hp_green_scout 1 at hp_scout onlayer screens
        elif sco_life < 1:
            hide hp_green_scout onlayer screens
    label dem_life:
        if dem_life==10:
            show hp_green_demo at hp_demo onlayer screens
        elif dem_life==9:
            show hp_green_demo 9 at hp_demo onlayer screens
        elif dem_life==8:
            show hp_green_demo 8 at hp_demo onlayer screens
        elif dem_life==7:
            show hp_green_demo 7 at hp_demo onlayer screens
        elif dem_life==6:
            show hp_green_demo 6 at hp_demo onlayer screens
        elif dem_life==5:
            show hp_green_demo 5 at hp_demo onlayer screens
        elif dem_life==4:
            show hp_green_demo 4 at hp_demo onlayer screens
        elif dem_life==3:
            show hp_green_demo 3 at hp_demo onlayer screens
        elif dem_life==2:
            show hp_green_demo 2 at hp_demo onlayer screens
        elif dem_life==1:
            show hp_green_demo 1 at hp_demo onlayer screens
        else:
            hide hp_green_demo
    label spa_life:
        if spa_life==10:
            show hp_green_spar at hp_sparrow onlayer screens
        elif spa_life==9:
            show hp_green_spar 9 at hp_sparrow onlayer screens
        elif spa_life==8:
            show hp_green_spar 8 at hp_sparrow onlayer screens
        elif spa_life==7:
            show hp_green_spar 7 at hp_sparrow onlayer screens
        elif spa_life==6:
            show hp_green_spar 6 at hp_sparrow onlayer screens
        elif spa_life==5:
            show hp_green_spar 5 at hp_sparrow onlayer screens
        elif spa_life==4:
            show hp_green_spar 4 at hp_sparrow onlayer screens
        elif spa_life==3:
            show hp_green_spar 3 at hp_sparrow onlayer screens
        elif spa_life==2:
            show hp_green_spar 2 at hp_sparrow onlayer screens
        elif spa_life==1:
            show hp_green_spar 1 at hp_sparrow onlayer screens
        else:
            hide hp_green_spar

 
jump battle

label hide_stat:
    
    hide hp_green_scout
    hide hp_green_demo
    hide hp_green_spar
    
    hide hp_red_scout
    hide hp_red_demo
    hide hp_red_spar
    
    jump battle_result


screen Battle:
    imagemap:
        auto "system/battle_%s.png" xalign 0.505 yalign 0.97
        
        hotspot (3, 4, 89, 92) clicked Return("Scout")
        hotspot (100, 3, 93, 93) clicked Return("Demo")
        hotspot (200, 6, 91, 90) clicked Return("Sparrow")
    
label battle_start:

    $ renpy.block_rollback()

    hide speaker with moveoutleft
    
    show battlebox onlayer screens with moveinbottom
    
    show fighter com at right with moveinright
    
    show hp_red_scout at hp_scout onlayer screens
    show hp_red_demo at hp_demo onlayer screens
    show hp_red_spar at hp_sparrow onlayer screens
    
    show hp_green_scout at hp_scout onlayer screens
    show hp_green_demo at hp_demo onlayer screens
    show hp_green_spar at hp_sparrow onlayer screens
    
    show speaker entech at left with moveinleft
    
    
label battle:
 
    call screen Battle
    
    $ result = _return
 

 
    #=========== [1] player decides who gets pitted in ===========================================================================
    jump hide_stat

label battle_result:

    hide fighter with moveoutright
    
    if result =="Sparrow":
        $ command = "Wild"
        show fighter spa at right with moveinright
    elif result == "Demo":
        $ command = "Tech"
        show fighter dem at right with moveinright
    elif result == "Scout":
        $ command = "Ammo"
        show fighter sco at right with moveinright
  
#=========== [2] declaring and choosing what type of move an enemy type could do ===========================================================================
    if en_type =="Tech":
        $ en_move = renpy.random.choice(["Tech", "Wild"])
    elif en_type == "Ammo":
        $ en_move = renpy.random.choice(["Ammo", "Tech"])
    elif en_type == "Wild":
        $ en_move = renpy.random.choice(["Wild", "Ammo"])
 
#=========== script for enemy phase ================================================================================
    if en_move == "Tech":
        bat "The creature released electrifying attacks."
    elif en_move == "Ammo":
        bat "Projectiles were released from the creature's body."
    elif en_move == "Wild":
        bat "The creature moved with great speed and insight."

 
 
#=========== printing enemy damage -> player =======================================================================

    if (en_move, command) in EN_DAMAGE:
        bat "Your unit took considerable damage."
    
        if command == "Wild":
            $ spa_life -= 1
        
        elif command == "Tech":
            $ dem_life -= 1
        
        elif command == "Ammo":
            $ sco_life -= 1
        
    else:
        bat "Your unit survived the attack, unscathed."

 
#=========== printing player damage -> enemy ===========================================================================

    if (command, en_type) in INFLICT_HIGH:
        bat "You've inflicted considerable damage."
        $ en_life -= 2
    
    elif (command, en_type) in INFLICT_LOW:
        bat "The creature was barely hurt. "
        $ en_life -= 1
    
    else:
        bat "You weren't able to inflict any damage."
    
    if en_life <= 0:
        bat "The enemy is dead"
        jump battle_end
    else:
        bat "The enemy still stands %(en_life)d "
        jump update_stat
    
 
#=========== Player attack result dialogue pool ===========================================================================
 
# You've inflicted considerable damage.
# The enemy was barely hurt. 
# Your attack was repelled. 
# You weren't able to inflict any damage. 

label battle_end:
 
     hide fighter with moveoutright 
     hide battlebox with moveoutbottom
     $ renpy.block_rollback()
     
     if anchor=="SparrowChoice":
        jump SparrowChoice
ImageI'm a bored potato so come talk to me pleaseImage

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Hide layer?

#6 Post by xela »

This is almost criminal misuse of Ren'Py script, I've never seen anyone trying to mimic screen language with it :)

Can't you just hide the screen layer (or hide hp_green_spar and the others for example) and jump to the "healthbar" labels to recreate it?

Notes:

Usually declaring a label in a label is not a good idea.

Images should be declared in the init or without any per-statements at all. Declaring them inside of a label should not even work but I guess that it does.

You bars should be bars... in a screen to be shown and hidden at your command.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot], Semrush [Bot]