#๐Ÿ”’ Help

39 messages ยท Page 1 of 1 (latest)

reef turtleBOT
#

@quaint nebula

Python help channel opened

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.

minor stag
#

Please post the code as text

#

!paste

reef turtleBOT
#
Pasting large amounts of code

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.

quaint nebula
#

I'm sorry

minor stag
#

Are you there?

quaint nebula
#

Yes

minor stag
#

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.

quaint nebula
#

Ok I'm trying to paste it

#

I think I pasted it

#

Do you see it

minor stag
#

You need to paste the URL here.

quaint nebula
#

Oooh

#

Ley me try that again

#

This url?

minor stag
#

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.

quaint nebula
#

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

quaint nebula
minor stag
#
 Rooms("You're at the backyard", 7, None, 4, None, pool_incident())
#

This is the problem.

quaint nebula
#

Please can you explain?

minor stag
#

pool_incident() has a () at the end. So you're calling the function there.

quaint nebula
#

Ohk

minor stag
#

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 ())

quaint nebula
#

So if I remove it, it will run normally

minor stag
#

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.

quaint nebula
#

Ok. I just tested it. It works now.

#

God bless. I've been on this for hours ๐Ÿ˜ญ๐Ÿ™

minor stag
#

You're welcome.

reef turtleBOT
#
Python help channel closed for inactivity

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.