#๐ I am having issues with my code!!!
68 messages ยท Page 1 of 1 (latest)
@little iris
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
https://paste.pythondiscord.com/YJ7Q heres my code!
'
What issues are you having?
Its not working the auto clicker in a def named Auto on line 61 and 106
iT also says on the error"IMPORT GAME CODE!/Clicker.py"
@broken goblet
Show the full output
Don't post a screenshot of output use copy/paste and a code block
Ok
Hello from the pygame community. https://www.pygame.org/contribute.html
The key E has been pressed!
Traceback (most recent call last):
File "c:\Users\User\Documents\IMPORT GAME CODE!\Clicker.py", line 106, in <module>
Auto(score)
TypeError: Auto() takes 0 positional arguments but 1 was given
PS C:\Users\User\Documents\Coding\Pygame\Car\Code\Images>
Remember code blocks
code blocks?
!code
What would i need to do to fix it and where on what line?
Edit this Traceback to use a code block
It's on the first and last lines of your message
But it looks like your Traceback and pasted code don't match. Maybe you didn't save your file?
What would I need to put in the code to fix it though?
If looks like you already fixed the exception you're getting
From your pastebin
See where your traceback says line 106?
yes
Then look at your code on line 106 and compare what the traceback says is on that line
ok
What difference do you see?
Auto(score) and Auto()
Right
I fixed that
The key E has been pressed!
The key X has been pressed!
The key E has been pressed!
Traceback (most recent call last):
File "c:\Users\User\Documents\IMPORT GAME CODE!\Clicker.py", line 106, in <module>
Auto()
File "c:\Users\User\Documents\IMPORT GAME CODE!\Clicker.py", line 64, in Auto
score = score + 1
^^^^^
UnboundLocalError: cannot access local variable 'score' where it is not associated with a value
PS C:\Users\User\Documents\Coding\Pygame\Car\Code\Images>```
Im now getting this
Remember to use code blocks for tracebacks
Please edit your message to use a code block
!code
That it?
No
I have no idea what you mean by code block and hwo I do it
It's three back ticks you only used one
Follow the instructions here carefully ^
done it
your auto() function isnt set up to any arguments
but you're passing one (score)
No the problem was the file wasn't saved
oh
You need to use the global keyword
where would I use that?
Is it global above def or no def ?
sorry I am still learning pygame
What i am trying to do with it is make it so every second the score goes up by 1
Well that's a bit complicated in pygame every frame you need to check the time and see how many seconds have passed since the last score update and then update the score
A while loop isn't correct
oh right
You would need to use the time module and do time.sleep(1) in the while loop, freezing it for one second then adding a score
I have made a game in pygame as well
That would freeze the game to all other inputs it's not the correct way to handle time in games
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.