I did a class ResourcesFields in a specific file named ResourcesFields_class.rpy And now I want to create a child class Buildings inheriting from ResourcesFields but I want to place it in an other file (in the same folder).
When I put my child class Buildings in a new file Buildings_class.rpy the game return an error
Code: Select all
## Here we are on a specific file name Buildings_class.rpy
## The ResourcesFields() is in another file name ResourcesFields_class.rpy in the same folder. The path from the main folder => /class/ResourcesFields_class.rpy
init python:
class Buildings(ResourcesFields):
def __init__(self, name, wood_init_cost=0, rock_init_cost=0, iron_init_cost=0, food_init_cost=0, workers = 0):
ResourcesFields.__init__(self, name, wood_init_cost, rock_init_cost, iron_init_cost, food_init_cost, workers) [code]
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/class/buildings_class.rpy", line 1, in script
init python:
File "game/class/buildings_class.rpy", line 3, in <module>
class Buildings(ResourcesFields):
NameError: name 'ResourcesFields' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/class/buildings_class.rpy", line 1, in script
init python:
File "/home/moi/renpy-7.3.5-sdk/renpy/ast.py", line 914, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "/home/moi/renpy-7.3.5-sdk/renpy/python.py", line 2028, in py_exec_bytecode
exec bytecode in globals, locals
File "game/class/buildings_class.rpy", line 3, in <module>
class Buildings(ResourcesFields):
NameError: name 'ResourcesFields' is not defined
Linux-5.4.0-40-generic-x86_64-with-debian-bullseye-sid
Ren'Py 7.3.5.606
Sat Jul 4 13:57:42 2020
Code: Select all
init python:
from resourcesField_class.rpy import ResourcesFields
class Buildings(ResourcesFields):
def __init__(self, name, wood_init_cost=0, rock_init_cost=0, iron_init_cost=0, food_init_cost=0, workers = 0):
ResourcesFields.__init__(self, name, wood_init_cost, rock_init_cost, iron_init_cost, food_init_cost, workers)
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/class/buildings_class.rpy", line 4, in <module>
from resourcesField_class.rpy import ResourcesFields
ImportError: No module named ResourcesFields
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/class/buildings_class.rpyc", line 3, in script
���v��;�>�;W�?Nh��.��#��d���ڦw1|H��A��u��\d�8~V�&�^B�XV1�ۿ~�{�
File "/home/moi/renpy-7.3.5-sdk/renpy/ast.py", line 914, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "/home/moi/renpy-7.3.5-sdk/renpy/python.py", line 2028, in py_exec_bytecode
exec bytecode in globals, locals
File "game/class/buildings_class.rpy", line 4, in <module>
from resourcesField_class.rpy import ResourcesFields
ImportError: No module named ResourcesFields
Linux-5.4.0-40-generic-x86_64-with-debian-bullseye-sid
Ren'Py 7.3.5.606
Sat Jul 4 14:08:14 2020