


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