• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

Modpath error - import=UnitType, existing=Unit

Trust

New member
Joined
Mar 8, 2019
Messages
3
Hello guys,

im new to Cerberus X and i am really confused why i get the following errors:

Modpath error - import=UnitType, existing=Unit
Modpath error - import=UnitTypeTable, existing=Unit


My filestructure looks like this:
main.cxs -> imports game
game.cxs -> imports mojo2, Unit, UnitType
Unit.cxs -> /
UnitType.cxs -> /
UnitTypeTable.cxs -> /

can somebody tell me whats wrong here?
 
I think you will need to post some code.
 
This is the code:

main.cxs
Cerberus:
Strict

Import Class_Game


Function Main:Int()
    New Game
    Return 0
End

Class_Game.cxs
Cerberus:
Strict

Import mojo2

Import Class_Unit
Import Class_UnitType
Import Class_UnitTypeTable


Class Game Extends App
...
...
...

Class_Unit.cxs
Cerberus:
Import Class_UnitType


#REM
    Represents an instance of any unit in the game.
#END

Class Unit
...
...
...

Class_UnitType.cxs
Cerberus:
#REM
    A general unit definition that could turn out to be anything
#END

Class UnitType
...
...
...

Class_UnitTypeTable.cxs
Cerberus:
Import Class_UnitType

#REM
    The unit type table stores the unit types the game can have.
    It also determines the attributes of each unit type.
    The unit type table determines the balance of the game.
#END

Class UnitTypeTable
...
...
...

Thats the import structure so far...
 
I've managed to recreate the problem.
You haven't made it very clear on how your file hierarchy is structured on disk. It's not clear what you mean by Unit.cxs -> /

A correct structure should look like this:
ProjectRoot/
main.cxs -> import sources.game​
sources/
game.cxs -> imports mojo2, unit, unittype​
unit.cxs​
unittype.cxs​

Note: sources becomes part of the name space for the module, so if you have for example two functions with the same name, but are completely different you must use the name space for that function you wish to call.

In case you do not already know, a name space is a way to access source files, classes and function with the same name. It is not recommended to have two files with the same name in the same project as the Import statement cannot differentiate between multiple imports of same named files even with a name space specifier.
e.g. Will throw an error for duplicate files.
Import game
Import sources.game

If you intend to make any module available to all your software. You should place it in the Cerberus\modules_ext directory in their own unique directories (name space).

Tip: All file and directory names should be lower case to avoid issues with file paths when considering cross platform.
 
Last edited:
A correct structure should look like this:

Ehmmm, that is your opinion.

1552077695463.png


Builds just fine here. At least that part of code which Trust showed. I guess it is something else.

Btw. welcome to the forum.
 
Thanks for the help.
It was in fact the wrong file structure. Didn't realize that the folder name becomes a part of the namespace (like in python).
Thanks to all of you for the help.
 
Ehmmm, that is your opinion.
With the error he was getting and figuring out from his first post what he was trying to accomplish. The directory structure I showed would have been the most easiest solution to solve the problem.

The project directory can look any way that you want it to, as long as you read the docs and remember to use name spacing for sub directories or creating a default import with the same name as the directory that imports all other files within. Just like what you see in the mojo module.
 
Back
Top Bottom