u/Content_Office_7610

Image 1 — How can I add draggables to a screen from a dictionary.
Image 2 — How can I add draggables to a screen from a dictionary.
Image 3 — How can I add draggables to a screen from a dictionary.
▲ 4 r/RenPy

How can I add draggables to a screen from a dictionary.

I try to add draggable objects to the screen "backgroundscreen" from a dictionary of imaged with position data, that I have populated with a selection screen. I could add one object but not more with the for loop.

Can you loop trough a dictionary with a for loop and add draggable objects to a screen in runtime? And how should I do this?

I have another problem how do I stop the game from showing the say window and progress the dialog. I have hidden it but it reappears.

Sorry for the long code snippet. I trimmed it down as much as possible I think.

Thank you very much

define e = Character("Eileen")

default img_file = "skip.png"
default dict_index = 1
default my_dict = {}


screen dashboard():
    zorder 90
    grid 2 2:
        
        xalign 0.5
        yalign 0.1
        spacing 10 
        # deleted buttons for other stuff
        textbutton "load image":
            action Show ("list_screen")
            
label start:
    show screen backgroundscreen 
    call screen dashboard   
    
init python:
    import os
    import re
    def file_list(dir=""):
        list = renpy.list_files()
        # list = os.scandir(config.gamedir)
        rv = []
        for f in list:
            if re.match(dir,f):
                rv.append(f[(len(dir)):])


        return rv
    
screen list_screen:    
    $ files = file_list("")
    viewport:
        draggable True 
        mousewheel True
        vbox:
                xalign 0.5
                text(str(len(files)))
                textbutton ("Hide!"):
                    action Hide(screen="list_screen")
                for i in files:
                    textbutton ("{size=25}"+i+"{/size}") action [[SetVariable("img_file", i),Hide(screen="list_screen",immediately=True),Call("add_image")]] xfill True
                 
window hide
pause 1.0
e""   



label hide_list_screen:
    $ renpy.hide_screen("list_screen",immediately=False)
    $ renpy.show_screen("dashboard")


label add_image:    
   
    $ zorder_value += 1
    $ dict_index += 1
    $ my_dict["[dict_index]"] = ("[img_file]",800, 100, zorder_value)

    screen backgroundscreen:
        zorder 1
        fixed:           
            draggroup:                             
                
                for img, val1 in my_dict.items():
                    $ img_name, xpo, ypo, zpo = val1
                   
                    drag:
                        drag_name "[img_name]"
                        draggable True
                        droppable True    
                        xpos xpo ypos ypo                         
                        add([img_file])                                     
                            
    jump start                      
    
label a:

return 
u/Content_Office_7610 — 1 day ago
▲ 2 r/RenPy

Cant call function because game crashes without a error message.

I tried to call the function and the game crashes, even with only a return statement. What did I do wrong. And can I do a input call in a function? Thank you for your help.

(solution is I used / instead of \ in my code and that crashed my program.) Thank you "Draw-Flesh-Games"

u/Content_Office_7610 — 11 days ago
▲ 1 r/RenPy

I tried the tutorial screen in a new project but it didnt work.

The simple screen dosnt show its text or button and is in the wrong position. I dont know whats missing or what I do wrong, please help me to understand my mistake.

u/Content_Office_7610 — 12 days ago