How the import works? ("duplicate/missing" errors)

BlitzMax Forums/BlitzMax Beginners Area/How the import works? ("duplicate/missing" errors)

gameproducer(Posted 2008) [#1]
For starters, could somebody shed light on doing the import? How it works & what it exactly does?

Secondly, I thought I could have my "characterManager.bmx" class and my "character.bmx" class and use "characterManager from character.bmx" and also use "character from characterManager" (for example "local character:TCharacter") but for some reason I cannot do this.

If I have a line "import 'character.bmx'" in my characterManager.bmx and if I have a line "import 'characterManager.bmx'" in my character.bmx things won't work.

Any n00b help on this?


gameproducer(Posted 2008) [#2]
I tried writing new classes and was starting to get notes like this:

Compile Error: Duplicate identifier 'TWeapon'
Compile Error: Identifier 'TCharacter' not found


tonyg(Posted 2008) [#3]
What are you doing now and what error are you getting? Example code really helps know how to answer such as open-ended question.


Brucey(Posted 2008) [#4]
for some reason I cannot do this.

You cannot have circular imports.

You can get around this by re-thinking your design, so that types do not reference each other.


gameproducer(Posted 2008) [#5]
okaydokie. it makes sense.

I'm doing a "character shoots other character" type of action, and I thought I could handle it with two classes:
- CharacterManager (holds list of all characters, handles character creation, and updates all characters)
- Character

Then I thought that "Character.shoot(entity)" method could call "CharacterManager.getCharacter(entity)" (which would go through all characters) and return the character object based on shot (picked) entity.

Tips on how this should be designed in an intelligent way...?


ziggy(Posted 2008) [#6]
Pass the charactermanager as a parameter to the character.shoot method? this way you avoid circular dependencies?