- May 26, 2017
- 838
- 2,810
I wanted to have up to 4 buttons, with multiple images inside, which would create and set multiple variables at once. So I tried adapting some ren'py/python stuff.
Right now, all I have to do is create a spreadsheet per character per set of personnality/outfit.
Then, call this label:
Which itself calls this monstrosity, which I'll divide in 3 parts:
1) The init:
2) The label 'variables+images', which calls the screen 'SCREEN0':
3) The screen SCREEN0, which :
- sets all the variables to False
- show all the images
- creates the buttons
When clicked the button sets some variables to True then returns to the first label:
It works but my problem is:
Since I am currently using 1 column per variable, I can't use more than 5 variables without expanding initial the code and I also have to fill every empty column with an ugly 'jdmod'. I'd like to use only 1 column for all the variables.
Same thing for the images.
I have tried multiple things but way past my knowledge of ren'py and python. It's a miracle this thing works in the first place.
Also I'd like to create only one spreadsheet per character.
I have some ideas but if you can help for this one too, it would be great.
Thank you. You deserve it for getting this far.
You don't have permission to view the spoiler content.
Log in or register now.
Right now, all I have to do is create a spreadsheet per character per set of personnality/outfit.
You don't have permission to view the spoiler content.
Log in or register now.
Then, call this label:
Code:
label variables+images_spreadsheetX:
$ variables+images("spreadsheetX.tsv")
call variables+images
return
Which itself calls this monstrosity, which I'll divide in 3 parts:
1) The init:
Code:
init -1 python:
def clothingchoice(filename):
# Creates the variables and defines them as []
# Variable for all the data
global ALLTHEDATA
# Variable for line 0
global LISTLINE0
ALLTHEDATA = []
LISTLINE0 = []
# From the file defined by $ clothingchoice(filename)
with renpy.file(filename) as INTERNALNAMEFORTHETSVFILE:
# For each line:
for line in INTERNALNAMEFORTHETSVFILE:
line = line.decode("utf-8")
data = line.rstrip().split("\t")
# Ignore empty lines and lines starting with "#"
if data == "" or data[0][0] == "#": continue
# Add all the data to 'ALLTHEDATA'
ALLTHEDATA.append([data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11]])
# Add the data from column0 to 'LISTLINE0'
LISTLINE0.append(data[0])
# Then, for each line in column 1 create the variables 1 to 5
for i in range(0,len(data[1].split(","))):
try:
globals()["{}".format(data[7].split(",")[i].split()[0])]
except KeyError:
globals()["{}".format(data[7].split(",")[i].split()[0])] = []
try:
globals()["{}".format(data[8].split(",")[i].split()[0])]
except KeyError:
globals()["{}".format(data[8].split(",")[i].split()[0])] = []
try:
globals()["{}".format(data[9].split(",")[i].split()[0])]
except KeyError:
globals()["{}".format(data[9].split(",")[i].split()[0])] = []
try:
globals()["{}".format(data[10].split(",")[i].split()[0])]
except KeyError:
globals()["{}".format(data[10].split(",")[i].split()[0])] = []
try:
globals()["{}".format(data[11].split(",")[i].split()[0])]
except KeyError:
globals()["{}".format(data[11].split(",")[i].split()[0])] = []
init -1:
default LINE0 = []
# Transform for the images
transform transform_images:
size (320,536)
2) The label 'variables+images', which calls the screen 'SCREEN0':
Code:
label variables+images:
$ LINE0 = LISTLINE0
call screen SCREEN0
3) The screen SCREEN0, which :
- sets all the variables to False
- show all the images
- creates the buttons
When clicked the button sets some variables to True then returns to the first label:
Code:
screen SCREEN0:
modal True
for i in range(0,len(LINE0)):
$ SetVariable("{}".format(ALLTHEDATA[i][7]) , "False")
$ SetVariable("{}".format(ALLTHEDATA[i][8]) , "False")
$ SetVariable("{}".format(ALLTHEDATA[i][9]) , "False")
$ SetVariable("{}".format(ALLTHEDATA[i][10]) , "False")
$ SetVariable("{}".format(ALLTHEDATA[i][11]) , "False")
# Shows the images 1 to 5
hbox:
xfill
ysize 536
anchor (0.5,1.0) align (0.5,1.0)
# For each data in 'LINE0'
for i in range(0,len(LINE0)):
if ALLTHEDATA[i][2] != 'jdmod':
add "images/{}.png".format(ALLTHEDATA[i][2]) at transform_images
hbox:
xfill
ysize 536
anchor (0.5,1.0) align (0.5,1.0)
# For each data in 'LINE0'
for i in range(0,len(LINE0)):
if ALLTHEDATA[i][3] != 'jdmod':
add "images/{}.png".format(ALLTHEDATA[i][3]) at transform_images
hbox:
xfill
ysize 536
anchor (0.5,1.0) align (0.5,1.0)
# For each data in 'LINE0'
for i in range(0,len(LINE0)):
if ALLTHEDATA[i][4] != 'jdmod':
add "images/{}.png".format(ALLTHEDATA[i][4]) at transform_images
hbox:
xfill
ysize 536
anchor (0.5,1.0) align (0.5,1.0)
# For each data in 'LINE0'
for i in range(0,len(LINE0)):
if ALLTHEDATA[i][5] != 'jdmod':
add "images/{}.png".format(ALLTHEDATA[i][5]) at transform_images
hbox:
xfill
ysize 536
anchor (0.5,1.0) align (0.5,1.0)
# For each data in 'LINE0'
for i in range(0,len(LINE0)):
if ALLTHEDATA[i][6] != 'jdmod':
add "images/{}.png".format(ALLTHEDATA[i][6]) at transform_images
# Set the variables
hbox:
xfill
ysize 536
anchor (0.5,1.0) align (0.5,1.0)
# For each data in 'LINE0'
for i in range(0,len(LINE0)):
# Creates a button
button:
xysize (320,536)
#padding (0,0)
# Add on image on top (foreground) when hovered
hover_foreground Frame(highlight.png", left = 10, top = 10)
# When CLICKED, SetVariables to True and Return
clicked [SetVariable("{}".format(ALLTHEDATA[i][7]) , True) , SetVariable("{}".format(ALLTHEDATA[i][8]) , True) , SetVariable("{}".format(ALLTHEDATA[i][9]) , True) , SetVariable("{}".format(ALLTHEDATA[i][10]) , True) , SetVariable("{}".format(ALLTHEDATA[i][11]) , True) , Return]
# Add text
hbox:
ysize 720
anchor (0.5,1.0) align (0.5,1.0)
for i in range(0,len(LINE0)):
frame:
background Solid("#0000")
xsize 320 xmargin 60 anchor (0.5,0.5) align (0.5,0.15)
text "{}".format(ALLTHEDATA[i][1]) text_align 0.5 size 20 at truecenter
It works but my problem is:
Since I am currently using 1 column per variable, I can't use more than 5 variables without expanding initial the code and I also have to fill every empty column with an ugly 'jdmod'. I'd like to use only 1 column for all the variables.
Same thing for the images.
I have tried multiple things but way past my knowledge of ren'py and python. It's a miracle this thing works in the first place.
Also I'd like to create only one spreadsheet per character.
I have some ideas but if you can help for this one too, it would be great.
Thank you. You deserve it for getting this far.