Problem importing pointer into module script (SOLVED)

Started by mode7, Sun 19/09/2010 13:09:35

Previous topic - Next topic

mode7

I want to customize the keyboard movement module, so it responds to joysticks also.

So in the global script i do:

Joystick *joy;
export joy;


In the module header I add:

import Joystick *joy;

When I try to use joy in the module script I get an error which says Script Link failed: runtime error: unresolved import "joy"
Joy works fine in the global script so I figure it has to do something with the import.

I hope someone can help me with this!

-mode7

Pumaman

Scripts can only reference things exported from other scripts before them in the list.

So the global script can access things that a module exports, but a module cannot access something that the global script exports.

The solution is to move your code into a higher up module script instead of having it in the global script.

mode7

Thank you very much Pumaman! This a very good thing to keep in mind for the future.

Well after all, I put the values I wanted into a global variable and voilá - it worked.

SMF spam blocked by CleanTalk