Basically I’m making a choose your own adventure type game, and in the beginning you invest points into skills like the beginning of Fallout. I successfully made the point system function and I wanted to make sure the points would translate out of the function instead of being local. So as a test, I made it so if asked to lift weights, and input ‘Lift’ if strength above 17 it would print you lifted it, if below it would print weak
Strength = 0
Perception = 0
Luck = 0
agility = 0
print("This is the skill tree, whichever abilities you invest in shall change the story and what you are able to do and how you solve situations and fight. Strength allows one to wield bigger weapons, solve situations with brute force, and will make fights easier. Perception allows secrets, chests, and many secret items to be found, and solutions ones with lesser perception might not spot otherwise. Luck allows certain situations to be bypassed, enemies to miss, and is the wild card of the abilities. Agility allows to bypass situations using acrobatics, and is useful in every situation. Create your character how you want, as long as the points add up to 20 \
")
def Point_sys(Strength,Perception, Luck, agility ):
P_all= Strength + Perception + Luck + agility
if P_all>20 or P_all<20:
display(HTML('<h1>Error! make sure all the points add up to 20</h1>'))
if P_all == 20:
display(HTML('<h1>Character correctly made, loading game<h1> '))
story(Strength,Perception, Luck,agility )
interact_manual(Point_sys, Strength=widgets.IntSlider(min=0, max=20,steps=1,value = 0), Perception=widgets.IntSlider(min=0, max=20,steps=1, value=0), Luck=widgets.IntSlider(min=0, max=20,steps=1, value=0), agility= widgets.IntSlider(min=0,max=20,steps=1, value=0))
#Problems, my strength is not translating from my point system code, need to make my attributes global
#giving choice before interact_manual
def story(Strength, Perception,Luck,agility):
choice=input("lift weight")
if choice == 'Lift' and Strength >= 17:
print("you lifted the weight")
if choice != 'Lift':
print ("you left")
if choice == 'Lift' and Strength<17:
print('weak ')
story(Strength, Perception, Luck, agility)
I want it so if someone makes their character, say with 20 strength, it allows them to do certain stuff later when i program the story. So should someone have 20 strength, they can lift weight, below 17 however, they cant lift weight. However, the point system and weight lift test are 2 different functions, as I will replace the weight test with my whole story code. I've tried specifying the input as an integer, but that gives a value error stating invalid literal for int() with base 10: 'Lift'
and without specifying as an integer it resulted in an EOL error when reading line. I've also tried try except
.