#๐ Help
39 messages ยท Page 1 of 1 (latest)
@quaint nebula
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.
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
I'm sorry
Are you there?
Yes
Can you paste a link to the code?
The problem sounded like you were calling a callback function instead of passing it, but I need to see the code.
You need to paste the URL here.
Yep
And what exactly was the problem again? Your original message is gone
player.update_status()
if player.update_status():
This is surely wrong.
You're calling update_status twice.
Ok so I'm trying to make a python adventure game. I made a rooms class and added events as one of the attributes of the rooms and set it to None. I made a function for a room event but it calls the event immediately the game is run and I only want the event to print when the player enters the room
Ok ill fix that
Rooms("You're at the backyard", 7, None, 4, None, pool_incident())
This is the problem.
Please can you explain?
pool_incident() has a () at the end. So you're calling the function there.
Ohk
If you want to pass it as an argument, you need to omit the () so it isn't called
Then, it's called later when you do .event()
(Note the ())
So if I remove it, it will run normally
If you remove the () from pool_incident(), it will pass the function as an argument like any other object.
If you have the (), it gets called right away, and the return value of pool_incident (None) is passed to Room instead once pool_incident returns.
Ok. I just tested it. It works now.
God bless. I've been on this for hours ๐ญ๐
You're welcome.
This help channel has been closed. 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.