Ask coding questions

← Back to all posts
How in the He11 do i fix the fight cycle
Sholohz (29)

so when you fight a monster and kill them, they can still attack and i dont know how to fix it i got help from @DouglasGoodyear but 'win' is not defined, i cant work much on the repl because im in class but i will try my best, pls halp

Answered by LukeWright (114) [earned 5 cycles]
View Answer
Comments
hotnewtop
LukeWright (114)

try making it a global variable with

global var = "yeet"
print(var)

click the checkmark next to my comment if this helped!

Sholohz (29)

@LukeWright maybe show me what you mean? im running on 3, 5 hour energys and my brain cant work for sum reason

LukeWright (114)

where you declare the variables, instead of

variablename = variablevalue

put

global variablename = variablevalue

@Sholohz

DouglasGoodyear (0)

@LukeWright That's how it's defined in my changes, but it's saying that the 'true' value is invalid. Trying to figure out python from C++ is moderately funky...

LukeWright (114)

Are you trying to say true as in boolean or true as in string @DouglasGoodyear

LukeWright (114)

Well you can declare it and then assign a value later.

global win
win = True

@DouglasGoodyear

DouglasGoodyear (0)

@LukeWright Let me try that real quick...

DouglasGoodyear (0)

@LukeWright Yeah, just tried that. It solved the problem. I probably wouldn't have thought of that. Python isn't exactly my 'specialty', so-to-speak.

Sholohz (29)

@DouglasGoodyear send me photo of the corrected script and ill fix it, i cant stay on repl for a long time because my teacher loves to walk around the classroom and look at ppls screens

Sholohz (29)

@LukeWright pls show me a picture of the script because i fixed everything and they still attack after being killed

DouglasGoodyear (0)

@Sholohz Well, if it makes you feel any better. Mine is outputting a random attack from a monster, then saying that 'repl has unexpectedly died' It got the 'no-declaration' piece fixed. But something else is broke, still working on it.

DouglasGoodyear (0)

@Sholohz Trying to implement an if-statement to fix it, but still incomplete. Still trying to learn Python from scratch.

LukeWright (114)

Send me a join link and I could try to help you. I know a bit of python. @DouglasGoodyear

IntellectualGuy (685)

Why are you importing the modules multiple time?

Sholohz (29)

@IntellectualGuy wait what module i might have done that on accident