DSE Error

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
Nemo009
Newbie
Posts: 4
Joined: Mon Aug 16, 2010 12:57 am
Contact:

DSE Error

#1 Post by Nemo009 »

Hey, total newbie question which, I'm sure, has an easy answer.

I tried using the stat system from the DSE as an add-on the visual novel I'm creating. I defined the stats (Intelligence and Charm) and launched the game. But when it came time to display the stats, the game crashed and I got this traceback:

Note: I've abbreviated the file locations for privacy, but the full line is completely necessary, I'll post it.

Code: Select all

I'm sorry, but an exception occured while executing your Ren'Py
script.

AttributeError: 'module' object has no attribute 'charm'

While running game code:
 - script at line 220 of .../game/script.rpy
 - python at line 220 of .../game/script.rpy.
 - python at line 51 of .../game/stats.rpy.
 - python at line 39 of ...game/stats.rpy.

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

  File "...\renpy-6.10.0\renpy\bootstrap.py", line 260, in bootstrap
  File "...\renpy-6.10.0\renpy\main.py", line 308, in main
  File "...\renpy-6.10.0\renpy\main.py", line 92, in run
  File "...\renpy-6.10.0\renpy\execution.py", line 230, in run
  File "...\renpy-6.10.0\renpy\ast.py", line 557, in execute
  File "...\renpy-6.10.0\renpy\python.py", line 927, in py_exec_bytecode
  File ".../game/script.rpy", line 220, in <module>
  File ".../game/stats.rpy", line 51, in display_stats
  File ".../game/stats.rpy", line 39, in normalize_stats
AttributeError: 'module' object has no attribute 'charm'

While running game code:
 - script at line 220 of .../game/script.rpy
 - python at line 220 of .../game/script.rpy.
 - python at line 51 of .../game/stats.rpy.
 - python at line 39 of .../game/stats.rpy.

Ren'Py Version: Ren'Py 6.10.0e
The lines of code in the game was just:

Code: Select all

$ display_stats()
For easy reference, here are the lines of code (apparently) being referenced (Taken from the stats):

Code: Select all

def normalize_stats():
        for s in __dse_stats:

            v = getattr(store, s.var)

            if v > s.max:
                v = s.max
            if v < 0:
                v = 0

            setattr(store, s.var, v)


    def display_stats(name=True, bar=True, value=True, max=True):

       [b] normalize_stats()[/b]
        
        ui.window(style=style.stats_frame)
        ui.vbox(style=style.stats_vbox)
            
        layout.label("Statistics", "stats")
        
        for s in __dse_stats:
            [b]v = getattr(store, s.var)[/b]

            ui.side(['l', 'r', 'c'], style=style.stat_side)

            if name:
                layout.label(s.name, "stat")
            else:
                ui.nul()

            if value and max:
                layout.label("%d/%d" % (v, s.max), "stat_value")
            elif value:
                layout.label("%d" % (v,), "stat_value")
            elif max:
                layout.label("%d" % (max,), "stat_value")
            else:
                ui.null()

            if bar:
                ui.bar(s.max, v, style=style.stat_bar)
            else:
                ui.null()

            ui.close()
                
        ui.close()
If anyone here needs anything else, please let me know. And sorry if the answer is obvious - I'm really stumped and searching this forum didn't shed any light. Thanks!

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: DSE Error

#2 Post by Showsni »

Why are there tags around some of that code? Or is that just from jedit or something?
Um, could you post the bit where you define the charm stat?

Nemo009
Newbie
Posts: 4
Joined: Mon Aug 16, 2010 12:57 am
Contact:

Re: DSE Error

#3 Post by Nemo009 »

Whoops, sorry about that! The tags were meant to highlight the lines of code listed in the traceback, (that is, line 39 and line 51), but I guess it failed. (Which is bizarre, since those lines appeared bold in the previews... oh well.)

Here is where I defined the stats. Sorry, I guess these WOULD be kind of important too.

These were taken directly from the script.rpy file at the very top.

Code: Select all

    init:
        # Declare images below this line, using the image statement.
        # eg. image eileen happy = "eileen_happy.png"
        image bg city = "city.jpg"
  
        # Declare characters used by this game.

        $ s = Character('Stephanie', color="#66ff99")
        $ c = Character('Chaos', color="#3366ff")
            
    init python:
        register_stat("Charm", "charm", 10, 100)
        register_stat("Intelligence", "intelligence", 10, 100)

    
    # The game starts here.
    label start:
        
Since I'm really inexperienced with Python (all I know are HTML and some entry-level C++), I wouldn't catch any but the most obvious errors. Sorry if the answer is clear and I'm just not seeing it. :oops:

User avatar
Showsni
Miko-Class Veteran
Posts: 563
Joined: Tue Jul 24, 2007 12:58 pm
Contact:

Re: DSE Error

#4 Post by Showsni »

I'm not too savvy on Python, but I think that the "has no attribute" bit means that somewhere it's getting something like module.charm where the module object doensn't have anything defined for having a charm there. I don't know if the actual word module appears anywhere in your script, or if that's referring to something else or something... I guess you could look through your script for module and charm and see everywhere they occur. I don't think there's anything wrong with the code you've posted; hm, unless...

Ah, that might be the problem. The stat engine uses the letter s as a variable (or something); you're also using the letter s to refer to a character. See if changing that letter s referring to Stephanie (like, $ st = Character('Stephanie', color="#66ff99")) makes a difference.

Nemo009
Newbie
Posts: 4
Joined: Mon Aug 16, 2010 12:57 am
Contact:

Re: DSE Error

#5 Post by Nemo009 »

You know, that was a good thought. I'd honestly never have thought of something like that... :oops: Oddly enough, though, it didn't work.

I took that 'stats.rpy' file from the dse Framework, since all I wanted were stats (as in, without the day planner aspect). However, I take it that at least one thing in that must need SOMETHING that I'm just not giving it. Do you (or does anyone else) have any advice?

Nemo009
Newbie
Posts: 4
Joined: Mon Aug 16, 2010 12:57 am
Contact:

Re: DSE Error

#6 Post by Nemo009 »

...actually, you're not going to believe this, but it seems there was a big misunderstanding with file management. I had never thought of starting a NEW game save-file - I'd just been reloading from the part of the story where the game first displays the stat values. Of course it had crashed - that file hadn't had the stats defined yet. I started a new file and made my way back to that particular place; since the stats were now defined, that fixed everything!

Sorry for that. And thank you for all your help!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]