------------------------------------------------------
I need to run a for loop in a screen that uses eval to check conditions in a dictionary. Unfortunately, eval has a major problem:
When you run eval ten times in a row in a for loop within a screen. It will fail one out of ten times, EVEN THE THOUGHT CONDITION IS EXACTLY THE SAME, making it unreliable to use.
You can reproduce the problem in a brand new renpy project:
Code: Select all
default weirdproblem = False
default boolVarEval = "weirdproblem == False"
screen test50():
# expected behavior is to print true 10 times, but one loop results in printing false, despite condition being the same
for i in range(0,10):
#if boolVarEval: WHAT THE HELL, DOING THIS CAUSES THE SAME PROBLEM? SO IT'S NOT UNIQUE TO EVAL?!
if eval( boolVarEval ) == True:
$ print "true"
else:
$ print "false"
label start:
call screen test50
return
Someone in the discord said I need to do this:
Code: Select all
on 'show' action If(boolVarEval , Function(print, "True"), Function(print, "False"))