get member variables from another verse file

I decided I wanted to move some functions over to another file, getmoves.verse. But how would I have access to the AllPieces var without passing this as a parameter to the functions?

image

Your main class is a creative_device and it’s purpose is to be created “spawned” and put into the game.

AllPieces is a member variable that is part of a single instantiated creative_device

It looks like you made some public floating functions. The point of functions in Verse are to be available without having to be tied to an instance of a class. Therefore, they can’t modify a member of an instantiated class directly.

You’ll want to create an argument for AllPieces if you really want those public functions.

So I think:
Option 1: Move your functions back into the main class OR
Option 2: Modify those functions to take a parameter for AllPieces : [ ] chess_piece

Your issue isn’t a Verse thing as much as it is a code design thing (this same situation would happen in most compiled languages)

2 Likes