Jul-05-2019, 12:56 AM
(This post was last modified: Jul-05-2019, 01:02 AM by somerandomguy123.)
I tried to create a random leveling system for mobs in my game, however, when I tried to check the output of a returned value It shows un in the console as "Undefined". Does anyone know why and how to solve it? I am sorry if the function seems complicated.
oh I forgot to put this line in the paragraph, there is suppose to be
def monsterpower(): import random weakmonsterlevel = random.randrange(1, 10, 1) normalmonsterlevel = random.randrange(5, 20 ,1) strongmonsterlevel = random.randrange(10, 40, 1) bosslevel = random.randrange(20, 80,1) weakmonsterhealth = weakmonsterlevel*1 +10 normalmonsterhealth = normalmonsterlevel*1 +10 strongmonsterhealth = strongmonsterlevel*1 +10 bosshealth = bosslevel*2 + 20 weakmonsterdamage = 2 normalmonsterdamage = 4 strongmonsterdamage = 6 bossdamage = 10 return weakmonsterhealth, normalmonsterhealth, strongmonsterhealth, bosshealth, weakmonsterdamage, normalmonsterdamage, strongmonsterdamage, bossdamage print(weakmonsterhealth)This is the error I got when I tried to print a returned value
NameError: name 'weakmonsterhealth' is not defined
oh I forgot to put this line in the paragraph, there is suppose to be
monsterpower()before [python]print(weakmonsterhealth)[/p