foreword: Okay, my Doc will kill me (in short I'm supposed to stay away from codes, but well, I'm just talking, right ?) but I've been pinged and I'm tempted to say "also indirectly quoted"...
And also, hmm, I'm on med, the kind that have big red "do not operate heavy machinery" everywhere, so I hope I'll be able to write intelligibly; at least I should write real words, thanks to the auto spellcheck
[...] I read somewhere that "RenPy games are supposed to be written in RenPy, not python", took it to heart and wanted to RenPy-fy this. [...]
There's a difference between not using Python when Ren'Py can do it natively, and never using Python code. And the idiot who say, so often, that "Ren'Py games are supposed to be written in Ren'Py, not Python" should sometimes be more explicit and less grumpy...
What it mean is that there's no need to redo what PyTom and the guys have already done, but of course there's need to do what they haven't. And here, you're facing the last case, therefore
winterfire answers are correct: use Python.
Now, when said this, you answered, with reason, that
renpy.call()
will break everything.
But why the fuck using
renpy.call()
? :/
Python:
init python:
def skillCheck( what, min ):
# Assuming that the skills are in the store, because you said nothing regarding this.
return getattr( store, what ) >= min
label whatever:
if skill_check('stealth', 2) or skill_check('h2h', 2) or skill_check('guns', 2):
[do whatever there's to do]
Now, if really you want to be pure Ren'Py, while it's not necessary,
Gojira667 gave you the answer:
Python:
label skill_check(skillz):
$ renpy.dynamic('skill','value','temp')
$ temp = False
while skillz:
$ skill, value = skillz.pop(0)
# still assuming...
$ temp |= getattr( store, skill ) >= value
return temp
label whatever:
call skill_check( [ ('stealth', 2), ('h2h', 2), ('guns', 2) ] )
if _return:
[do whatever there's to do]
But, well, can this really be said "pure Ren'Py" ? The label have six lines, four of them being inline Python...
There's a bit more "pure" alternative:
Python:
label skill_check(skillz):
$ renpy.dynamic('skill','value')
while skillz:
$ skill, value = skillz.pop(0)
# still assuming...
if getattr( store, skill ) >= value:
return True
return False
label whatever:
call skill_check( [ ('stealth', 2), ('h2h', 2), ('guns', 2) ] )
if _return:
[do whatever there's to do]
But it really feel like overdoing it, because it's, at best, six lines label, plus a two lines condition test, to replace a one line function and a one line condition test. And, of course, the Ren'Py version is less explicit, because you've to look at the label code to see that it's a OR check. Something explicit right from the starts with the function approach.
Also, the function approach will works whatever the way you want to combine the checks:
if skillCheck( "stealth", 2 ) and skillCheck( "h2h", 2 )
if skillCheck( "stealth" 2 ) or ( skillCheck( "h2h", 2) and skillCheck( "guns", 2 ) )
This while working with a label force you to add another label each time there's a new combination.
A last word, when I say that Ren'Py games should be in Ren'Py, what come first in my mind is: "Do not over complicate your life".
Ren'Py come natively with a tons of useful features, all tested by thousands developers and millions players. Even if sometimes it need to pass few days finding how to bend Ren'Py to your will, it will always be easier to use those features than searching a way to do the same in Python, then how to integrate this in your Ren'Py code, and then praying each day that there's no bugs.
But this imply also that one should not over complicate his life by trying to do in Ren'Py something that would highly benefit to be done with Python. Like it's the case here, where the Python approach is shorted, more flexible, more explicit, and guaranty to be bug free.
And the meds having started to kick in, I'll stop while I still looks like a smart guy.