Imagebutton custom path

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.
Message
Author
User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Imagebutton custom path

#16 Post by Luxliev »

Thanks for answers. Both works. I have few questions in your code trooper6 can I swap lists? I'm thinking about

Code: Select all

current_player = 1
player01_roster = list

if player == 1:
    curr_roster = player01_rooster
I think about few players and I wonder can I easliy swap lists without making entirely new screens for each player
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Imagebutton custom path

#17 Post by trooper6 »

Luxliev wrote: I think about few players and I wonder can I easliy swap lists without making entirely new screens for each player
I don't see why not. Try it out, it should work.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Imagebutton custom path

#18 Post by Luxliev »

It works but Ren'py screen doesn't show that list is empty.

Code: Select all

def purge_list():
    global curr_roster

    curr_roster = []
When I run this code I can see result in trooper6's code after I close and again open screen. How can I make it show result at the same moment list is purged?

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")


init -1 python:
    class Char():
        def __init__(self, name, but_idle, but_hover, port, info):
            self.n = name
            self.awpi = but_idle
            self.awph = but_hover
            self.port = port
            self.info = info

screen top_gui():
    frame:
        hbox:
            textbutton "Inventory" action NullAction()
            textbutton "Characters" activate_sound 'click.wav' action If(renpy.get_screen("char_roster"), Hide("char_roster"), Show("char_roster", list=curr_roster))
            textbutton "Spells" action NullAction()
        
screen char_roster(list):
    frame:
        align (0.0, 0.5)
        xysize (400, 300)
        vbox:
            text "Character Roster"
            text "-----"
            spacing 10
            for c in list:
                imagebutton:
                    idle c.awpi
                    hover c.awph
                    focus_mask True 
                    activate_sound 'click.wav'
                    action If(renpy.get_screen("info_screen"), Hide("info_screen"), Show("info_screen", who=c))
        
screen info_screen(who):
    frame align (1.0, 0.5):
        vbox:
            text "[who.n]"
            add who.port
            text "-----"
            text "[who.info]"

default curr_roster = []
default d = Char("Diana", "dianab_idle", "dianab_hover", "dianaport", "Diana is the science officer.")
default l = Char("Lydia", "lydiab_idle", "lydiab_hover", "lydiaport", "Lydia is the security officer.")
default j = Char("Juliet", "julietb_idle", "julietb_hover", "julietport", "Juliet leada the resistance.")

# The game starts here.
label start:
    scene black
    show screen top_gui()
    "Rignt now, no one should be in the roster."
    $curr_roster.append(d)
    "Diana should be in the list."
    $curr_roster.append(l)
    "Diana and Lydia should be in the list."
    $curr_roster.append(j)
    "Diana, Lydia, and Juliet should be in the list."
    $purge_list
    "..."
I just added purge_list function at the bottom.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Imagebutton custom path

#19 Post by trooper6 »

Try this for your function, which actually deletes all the items in the list rather than assigns the variable to an empty list:

Code: Select all

    def purge_list():
        global curr_roster
        
        del curr_roster[:]
And then try calling the function properly--with parentheses--in your label:

Code: Select all

    show screen top_gui()
    "Rignt now, no one should be in the roster."
    $curr_roster.append(d)
    "Diana should be in the list."
    $curr_roster.append(l)
    "Diana and Lydia should be in the list."
    $curr_roster.append(j)
    "Diana, Lydia, and Juliet should be in the list."
    $purge_list()
    "List purged."
Side Note: Have you done the free Beginner's Python course from CodeAcademy.com? Because if you haven't, I recommend it.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: Imagebutton custom path

#20 Post by Luxliev »

It works. Thanks for quick reply.
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

Post Reply

Who is online

Users browsing this forum: Google [Bot]