[MacRuby-devel] require [was: [ANN] The Flying Camera (game)]

Gabriel Gilder gabriel at gabrielgilder.com
Fri Dec 17 11:13:35 PST 2010


I ended up solving this problem in my MacRuby app by writing a little class
to load dependencies - it keeps track of the full file paths of every
dependency in a class variable and makes sure to only load a file once even
if you request it again. Let me know if you would like me to post some
sample code...

-Gabriel


On Fri, Dec 17, 2010 at 2:09 AM, Thomas R. Koll <info at ananasblau.com> wrote:

>
>
>
> Am 16.12.2010 um 01:58 schrieb Matt Aimonetti:
>
> > FYI I'm getting a few error messages:
> >
> > unknown: warning: already initialized constant MIN_SPEED
> > unknown: warning: already initialized constant MAX_SPEED
> > unknown: warning: already initialized constant MAX_TURN
> > unknown: warning: already initialized constant SPEED_FACTOR
>
>
> That's because I have to require some files more than once
> as e.g. the Visibility class doesn't seem to be loaded
> early enough in the rb_main. Thus I have to load it from both,
> e.g. Enemy and then rb_main loads it again causing this error.
>
> What didn't help was putting lib and game_items in the $LOAD_PATH
> $LOAD_PATH << File.join(dir_path, 'lib') # doesn't work
>
> How's everyone else solving this? Requiring every file manually
> in rb_main?
>
> At the end I solved my problem with "unless const_defined?('MIN_SPEED')"
> but I'm not sure if I'm happy with this.
>
> I think I saw a require_once popping up in ruby 1.9.2, or am I wrong?
>
> ciao, tom
>
> PS: New version of the game coming Sunday. With 100% more fun :|
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101217/ed562aed/attachment.html>


More information about the MacRuby-devel mailing list