Import not working
Monkey Forums/Monkey Programming/Import not working
| ||
I have my main file Dodgem.monkey. I have a class Player The following line of code in the Dodgem class is causing problems player = Player.Create() If Dodgem.monkey contains the class definition for Player, the above works fine. If I keep the Player class in a separate source file (Player.monkey) and include the code Import Player I get an error stating Player.Create() cannot be found. I know I must be doing something wrong because the Rockout example includes files and works. What am I missing? |
| ||
Import is working great. You're experiencing identifier clash in your example: "Classless" Functions can be accesed using modulename.classname, so Player.Create is expected to be a function inside the Player.mojo file. To avoid this kind of issues, be sure to use low-case for filenames, and Cased words for classes/functions, etc. (see naming convention on the Monkey documentation). If you do so, the Player class could be accesed as Player, or even as player.Player (being the first the module name of file where the class is defined, and the second one the class itself). |
| ||
Ahhh got ya thank you :) |