This is what I started with, and closest to my intentions. I'm trying to generate a bunch of variables based on two input values to the function. At first, without the global value code, the code wasn't working at all. After putting in the code, it returns monlvl = 8 and monhp = 80, seemingly to completely ignore the if statements?? Is it because I'm trying to use a renpy function within init python?
Code: Select all
init python:
monlvl = 8
def mgen1(x, lvl):
global monlvl
if lvl > 3:
monlvl = renpy.random.randint((lvl-3),lvl)
elif lvl == 3:
monlvl = renpy.random.randint(1, 3)
elif lvl == 2:
monlvl = renpy.random.randint(1, 2)
elif lvl == 1:
monlvl = 1
if x == 1:
monhp = monlvl*10
else:
pass
return monlvl, monhp
Code: Select all
"Text"
$ mclvl = 5
init python:
monlvl, monhp = mgen1(1, mclvl)
"mclvl is [mclvl]"
"monhp is [monhp]"
"monlvl is [monlvl]"
init python:
monlvl, monhp = mgen1(1, mclvl)
"monhp is [monhp]"
"monlvl is [monlvl]"
Code: Select all
init python:
monlvl = 8
def mgen1(x, lvl):
global monlvl
monlvl = renpy.random.randint(2,6)
if x == 1:
monhp = monlvl*10
else:
pass
return monlvl, monhp
Code: Select all
"Text"
$ mclvl = 5
init python:
monlvl, monhp = mgen1(1, mclvl)
"mclvl is [mclvl]"
"monhp is [monhp]"
"monlvl is [monlvl]"
init python:
monlvl1, monhp1 = mgen1(1, mclvl)
"mclvl is [mclvl]"
"monhp1 is [monhp]"
"monlvl1 is [monlvl]"