Renpy don't get python function if it not in the same rpy

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Renpy don't get python function if it not in the same rpy

#1 Post by Eliont »

Hello and good time of day.
Tryed to migrate to new version and encountered a bug:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 12, in script
    python:
  File "game/script.rpy", line 30, in <module>
    work_actions_desc = load_work_action_descriptions('db/work actions descriptions')
NameError: name 'load_work_action_descriptions' is not defined

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

Full traceback:
  File "game/script.rpy", line 12, in script
    python:
  File "D:\Soft\renpy-6.99.11-sdk\renpy\ast.py", line 805, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\Soft\renpy-6.99.11-sdk\renpy\python.py", line 1641, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 30, in <module>
    work_actions_desc = load_work_action_descriptions('db/work actions descriptions')
NameError: name 'load_work_action_descriptions' is not defined

Windows-7-6.1.7601-SP1
Ren'Py 6.99.11.1749
Legends_of_Alkion 1.0
This function is located in lib - functions.rpy.
If i copy her to script.rpy, it works, but this is not acceptable.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Renpy don't get python function if it not in the same rp

#2 Post by xela »

Privet :)

Delete all .rpyc files and try again.
Like what we're doing? Support us at:
Image

Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Re: Renpy don't get python function if it not in the same rp

#3 Post by Eliont »

Hi. Did not work. Lol, i tried it in the first place, and tried again just now, problem still exist.

"Force Recompile" also did not help.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Renpy don't get python function if it not in the same rp

#4 Post by xela »

:(

It's not Ren'Py 6.99.11 in off itself... maybe the func is defined twice or was moved at some point. When you deleted .rpyc, did you use windows search to locate all files? This has happened to me a couple of times after major refactoring as code was moved between files.
Like what we're doing? Support us at:
Image

Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Re: Renpy don't get python function if it not in the same rp

#5 Post by Eliont »

In 6.11 worked just fine.
Function has one and only place and one and only use.

If i copy her to script.rpy then launch break on next function call - load_content.

Hmm, just noticed, it not next. Functions that defined in lib - common.rpy was loaded succesfully.
Copied lib - functions.rpy content to the end of lib - common.rpy and game launched succesfully.

IDK what the hell it is.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: Renpy don't get python function if it not in the same rp

#6 Post by PyTom »

You do have to care about init order here. While functions in a single file are defined from top to bottom, files can be loaded in any order. So you probably want to define functions in an init python block, but call them in an "init 1 python" block, to make sure the functions are defined before being called.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Re: Renpy don't get python function if it not in the same rp

#7 Post by Eliont »

i dont think its about init order...

Code: Select all

# The game starts here.
label start:
    show screen debugTools
    python:    
        work_actions_desc = load_work_action_descriptions('db/work actions descriptions')

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: Renpy don't get python function if it not in the same rp

#8 Post by PyTom »

That should work. What's the error, and what file is the code in?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Re: Renpy don't get python function if it not in the same rp

#9 Post by Eliont »

Error code in the first post.

Well, idk what was there, but when i deleted lib-functions.rpy and placed its content in a new file with the same name error gone. May be the file itself been corrupted at filesystem level (but Notepad++ operated with them with no problem).
Attachments
lib - functions.rpy
old (broken) file
(17.23 KiB) Downloaded 111 times

Post Reply

Who is online

Users browsing this forum: No registered users