Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to include other files in the game #52

Open
GabrielTavarez opened this issue Dec 2, 2021 · 5 comments
Open

Impossible to include other files in the game #52

GabrielTavarez opened this issue Dec 2, 2021 · 5 comments

Comments

@GabrielTavarez
Copy link

It would be great to have 1 file that contains the game and include other files that contains the structs created in the game.

I was tring to make a game.jl that had "include(snake.jl)".

In game.jl, all the loops and conditions would be verified, while the snake.jl file would have the definition of the struct snake and its methods. But when i try to do "include(snake.jl)" I get "LoadError: UndefVarError: include not defined".

Apperantly, there's no function "include" in gamezero, or it erases the base function from julia. I don't uderstand exactly

@aviks
Copy link
Owner

aviks commented Dec 3, 2021

See the changes in this PR if it helps: #38

The stuff in that PR should probably be better documented.

@BatyLeo
Copy link

BatyLeo commented Jul 16, 2023

Hello, I have the same issue, everything works well when I have only one file, I face an error when trying to include other files.
I tried following the instructions in the linked PR, but I get a LoadError: UndefRefError: access to undefined reference.

@scottbigbrain
Copy link
Contributor

Hello, I have the same issue, everything works well when I have only one file, I face an error when trying to include other files. I tried following the instructions in the linked PR, but I get a LoadError: UndefRefError: access to undefined reference.

You can use game_include("yourefile.jl"), as was added in #22. Documentation should probably be added for that, sorry

@BatyLeo
Copy link

BatyLeo commented Jul 20, 2023

Thank you for your help, I'll try that !
Another solution I found is to put the external code inside a package/module.

@scottbigbrain
Copy link
Contributor

Yeah, that works too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants