Import classes to the main game manager device

Hey, I come mostly from a Node.js/Python Background.

I wanted to structure my Code, but i dont know how to import another class.

This is my GameManagerDevice in Gungame/main_game_manager.verse:

game_manager_device := class(creative_device):
    @editable 
    var GunGamePlayers : []gungame_player = array{}

In another file in Gungame/GungamePlayer/gungame_player.verse
I have my player:

gungame_player := class<concrete>():

I am literally too stupid to import this class.
VS Code tells me to import /localhost/Gungame/GungamePlayer, but after doing that it tells me using clause must not use paths in “/localhost”

What is the best way to import that?

This post needed a few hours to be accepted, so i fixed it by

using { Gungame.GungamePlayer }

Sadly, this resulted in more errors.

Content package resolver failed to resolve package for projext:xyz, module:@0

The map wont start and nothing works now

Try removing var from the manager device’s array. I think it has to be a constant.

I believe you don’t even need to import any classes in another file, so long as both files are in the same working directory. For example if I have a class definition in a player.verse file

coolPlayer := class:
# Cool player stuff

Then in, say, my main game_device.verse file (in the same directory

# I can just instantiate a coolPlayer object since they're in the same directory
Player1 : coolPlayer = coolPlayer{}
1 Like

But it is in a subfolder (GungamePlayer), and it works now,
using { GungamePlayer }

The other issues got resolve by recreating a fresh project. Maybe something broke down during the testing idk

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.