Can't figure out the error AttributeError: 'int' object has no attribute 'level'. What am I doing wrong?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
blewbyboy
Newbie
Posts: 1
Joined: Wed Jun 09, 2021 11:58 pm
Projects: Bukimi Ai, The Sliamevion Sea
Organization: Starsign Games
Deviantart: blewbyboy
itch: starsigngames
Location: Savannah, GA
Discord: dickweed#1207
Contact:

Can't figure out the error AttributeError: 'int' object has no attribute 'level'. What am I doing wrong?

#1 Post by blewbyboy »

Hey y'all, I'm having some problem with my code and I'm so burnt out I have no clue how to fix it and can't find anything on it, lmao. So basically I'm trying to do sort of a shop system, and here's the code for it:

Code: Select all

label chap1lunch:
    
    "I have the money that Mom and that lady gave me..."
    
    "%(yen)d yen left."
    
    "What should I get from the cafeteria?"
    
    menu:
        "A drink" if yen.level >= 120:
            "I got a drink.  It's hot out today."
            $yen.dec()
        "I don't have enough money" if yen.level < 120:
            "Nevermind."
            "Maybe I should get a job?"
            
        "Chocolate" if yen.level >= 102:
            "I got some chocolate.  Probably not the healthiest choice."
            $yen.dec()
        "I don't have enough money" if yen.level < 102:
            "Nevermind."
            "Maybe I should get a job?"
            
        "Curry rice" if yen.level >= 656:
            "I got some curry rice.  It looks delicious."
            $yen.dec()
        "I don't have enough money" if yen.level < 656:
            "Nevermind."
            "Maybe I should get a job?"
            
        "Ramen" if yen.level >= 550:
            "I got some ramen noodles.  They smell nice."
            $yen.dec()
        "I don't have enough money" if yen.level < 550:
            "Nevermind."
            "Maybe I should get a job?"
            
        "Sushi" if yen.level >= 1226:
            "I got some sushi.  My favorite."
            $yen.dec()
        "I don't have enough money" if yen.level < 1226:
            "Nevermind."
            "Maybe I should get a job?"
Everything works until I get to the menu. Here's the error I keep getting:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 694, in script
    menu:
  File "game/script.rpy", line 695, in <module>
    "A drink" if yen.level >= 120:
AttributeError: 'int' object has no attribute 'level'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 694, in script
    menu:
  File "/Applications/renpy-7.4.5-sdk/renpy/ast.py", line 1642, in execute
    choice = renpy.exports.menu(choices, self.set, args, kwargs, item_arguments)
  File "/Applications/renpy-7.4.5-sdk/renpy/exports.py", line 1028, in menu
    condition = renpy.python.py_eval(condition)
  File "/Applications/renpy-7.4.5-sdk/renpy/python.py", line 2249, in py_eval
    return py_eval_bytecode(code, globals, locals)
  File "/Applications/renpy-7.4.5-sdk/renpy/python.py", line 2242, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 695, in <module>
    "A drink" if yen.level >= 120:
AttributeError: 'int' object has no attribute 'level'

Darwin-20.3.0-x86_64-i386-64bit
Ren'Py 7.4.5.1648
Bukimi Ai 2.0
Sat Jul 17 20:34:07 2021
Any help here? I've been troubleshooting it for hours and it's probably the easiest fix, smh. :evil:

User avatar
Alex
Lemma-Class Veteran
Posts: 3090
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Can't figure out the error AttributeError: 'int' object has no attribute 'level'. What am I doing wrong?

#2 Post by Alex »

Check if you've set 'yen' value as integer somewhere.

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Can't figure out the error AttributeError: 'int' object has no attribute 'level'. What am I doing wrong?

#3 Post by rayminator »

Alex wrote: Sat Jul 17, 2021 10:04 pm Check if you've set 'yen' value as integer somewhere.
the main error is pointing to

AttributeError: 'int' object has no attribute 'level'

what's is wrong is the int

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]