[SOLVED] error during reloading

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
M0ti
Regular
Posts: 66
Joined: Mon Aug 15, 2011 1:06 pm
Contact:

[SOLVED] error during reloading

#1 Post by M0ti » Tue Dec 22, 2015 3:06 am

Hi, I was trying to use function for the first time but now whenever a reload it crush.
I defined it with all my variables after start.

Code: Select all

label start:
    python:
        
        enemy_hp = 0
        enemy_maxhp = 0
        enemy_lv = 0
        enemy_mp = 0
        enemy_maxmp = 0
        ........

        def not_random(chance):
            r_number = renpy.random.randint(1,100)
            if r_number <= chance:
                return 'hit'
            else:
                return 'miss'
It seems that its working but now I can't use reloading because whenever I use it ...

Code: Select all

While running game code:
  File "renpy/common/00start.rpy", line 151, in script call
    call _load_reload_game from _call__load_reload_game_1
  File "renpy/common/00keymap.rpy", line 393, in script
    python hide:
  File "renpy/common/00keymap.rpy", line 403, in <module>
    renpy.load("_reload-2")
AttributeError: 'StoreModule' object has no attribute 'not_random'

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

Full traceback:
  File "renpy/common/00start.rpy", line 151, in script call
    call _load_reload_game from _call__load_reload_game_1
  File "renpy/common/00keymap.rpy", line 393, in script
    python hide:
  File "C:\Users\Emil\Desktop\PSP\Renpy\renpy-6.15.7-sdk\renpy\ast.py", line 805, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Emil\Desktop\PSP\Renpy\renpy-6.15.7-sdk\renpy\python.py", line 1460, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00keymap.rpy", line 403, in <module>
    renpy.load("_reload-2")
  File "C:\Users\Emil\Desktop\PSP\Renpy\renpy-6.15.7-sdk\renpy\loadsave.py", line 579, in load
    roots, log = loads(location.load(filename))
  File "C:\Users\Emil\Desktop\PSP\Renpy\renpy-6.15.7-sdk\renpy\loadsave.py", line 49, in loads
    return cPickle.loads(s)
AttributeError: 'StoreModule' object has no attribute 'not_random'

Windows-8-6.2.9200
Ren'Py 6.99.7.858
IO Finale 0.0
Last edited by M0ti on Tue Dec 22, 2015 3:45 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: error during reloading

#2 Post by PyTom » Tue Dec 22, 2015 3:15 am

A function like not_random needs to be defined in an init python block, not a python block.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
M0ti
Regular
Posts: 66
Joined: Mon Aug 15, 2011 1:06 pm
Contact:

Re: [SOLVED] error during reloading

#3 Post by M0ti » Tue Dec 22, 2015 3:48 am

Thank you. I though it would be something simple like this. Silly me.

Post Reply

Who is online

Users browsing this forum: No registered users