#πŸ”’ For some reason my it doesn't accept my variable for math, it just returns 0

23 messages Β· Page 1 of 1 (latest)

ancient lintel
#

I'm very confused right now because by all means it SHOULD be doing math, I even put in the number the variable was equivalent to last time and everything else did its job as expected, yet at the same it seems to always return 0 whenever I put in a variable that clearly doesn't equal the same amount as the number I'm subtracting it from. Why is this, what's going on?

storm wraithBOT
#

@ancient lintel

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.

violet chasm
storm wraithBOT
#
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.

ancient lintel
# storm wraith

I'm relatively new so I'm still not entirely sure how to use that, I apologize πŸ˜…

#

here, it should be small enough

#
py
def calculateDefense(self, recipe):   #Calculte item defense
        defBonus = 0
        
        if (recipe.state == RecipeFood.STATE_SOLID and self.size == self.SIZE_SMALL):
            defBonus = defBonus + 50
            print("solid")
            print(defBonus)
            if (self.type == self.TYPE_WOOD):
                defBonus = defBonus - 5
                print("wood penalty")
                print(defBonus)
        if (recipe.state == RecipeFood.STATE_LIQUID and self.size == self.SIZE_LARGE):
            defBonus = defBonus + 50
            print("liquid")
            print(defBonus)
            if (self.type == self.TYPE_WOOD):
                defBonus = defBonus - 5
                print("wood penalty")
                print(defBonus)
        if (recipe.temp == RecipeFood.TEMP_HOT and self.type == self.TYPE_CLOTH):
            defBonus = defBonus + 50
            print("hot")
            print(defBonus)
        if (recipe.temp == RecipeFood.TEMP_COLD and self.type == self.TYPE_METAL):
            defBonus = defBonus + 50
            print("cold")
            print(defBonus)
        if (self.type == self.TYPE_WOOD):
            defBonus = defBonus + 30
            print("wood")
            print(defBonus)

        print("Final bonus is: ",defBonus)
        return defBonus
#

ah

fading wadi
violet chasm
#

``` vs '''

#

!code there's a screenshot of it on this

storm wraithBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

ancient lintel
#

That's the code containing the calculation for the values I showed in the terminal on my screenshot

#

So uh... yeah anyway, as it shows, it's calculating numbers but it's returning 0 every time. I realize now that that's a bad example so I'll run it again and give you a better example

#

It's... working as intended now, I'm not sure what was happening before but thank you guys for checking anyway.

cedar skiff
#

!paste

storm wraithBOT
#
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.

cedar skiff
#

It's currently impossible for us to know what the first variable in your code is, since player1Defense and its calculateDefense attribute are unknown.

#

```py
code goes here on a new line
```
the py must be on the same line as the backticks.

torn bay
#

@ancient lintel explain your question, and for player 1 damage calculation 100 - 100 = 0

storm wraithBOT
#
Python help channel closed

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.