A Dictionary is flexible, it could be used to simulate a 2D array.
Mock-up for a non-interactive combat system for FreeOrion
In my roguelike, I keep a lot of objects confined to a virtual grid by assigning each of them a vector (of two integers) showing their position. I never store any of them in any structure. When I want to find one, I just loop through all the children of their parent object, looking for a particular coordinate (vector). Since the game is turn-based, it doesn't have to be especially fast.
If I needed more speed, I might take each and assign them to a Dictionary by "dic[Vector2(<x>, <y>)] = <object>". You can use 2D Arrays in gdscript, but I find it more complicated. That's just one way to do things.
store_var() is a method of File that stores a Variant in a binary format. It supports (as far as I know) all of the native godot objects, so it can be simpler than json.
You can also load CSV files into Godot. This gives you basically a 2D Excel spreadsheet. I used this for a project to store text and stats and stuff. It's a little harder to save in Godot, but for reading it works well and you can use LibreOffice Calc (or Excel) to write the data, then export as CSV. Sort of like a ghetto read-only database.
- Edited
cybereality A Dictionary is flexible, it could be used to simulate a 2D array.
Really ? How exactly ?
cybereality you can use LibreOffice Calc (or Excel) to write the data, then export as CSV.
Not really, except maybe for testing.
The idea is that the first phase (designing the tactical doctrine) should save each tactical doctrine, and that the tactical doctrine can then be used with various fleet composition.
So the ability to save to the format is paramount.
I guess JSON it is then, since I don't really need to save any Godot object.
Maybe I can use CSV for ship data though, since these ones are not to be modified by the combat system (in FreeOrion they are designed in separate panels), and the mock-up only needs to read them.
duane In my roguelike, I keep a lot of objects confined to a virtual grid by assigning each of them a vector (of two integers) showing their position. I never store any of them in any structure.
I downloaded your roguelike but it's quite huge.
Could you pinpoint one example of this more precisely ?
From what you write (without having seen the code) I don't understand the advantage of your way.
There's not much to see, really. The monsters are added through a slightly complicated chain of events as children of the dungeon, which inherits from TileMap. So, when I want to check a particular grid location I do
func map_unit(pos:Vector2):
for c in get_monsters():
if c.grid_position == pos:
return c
func get_monsters():
var out = []
for c in get_children():
if c.get('is_creature'):
out.append(c)
return out
That's a simplified version.
The advantage for me is that I don't have to maintain the objects in two places. They're always going to be part of the scene tree, so if I use another structure to track them, I'm duplicating effort, and creating the possibility of the two getting out of sync (which actually happened when I was doing it that way).
Note that I'm checking for an "is_creature" property instead of using "is Creature" to check the object type. That's just because gdscript 1.x still has huge issues with cyclic references. In a project with a lot of code, it becomes impossible to use typed variables with custom class names or even to use the "is" keyword without errors.
I just offer that as an alternative. There are lots of ways to do it.
- Edited
Since there are only tiles, tokens and cards in the game but all the player's actions will be on the cards, I guess I'd better use already existing card games resources.
But apparently there are many different ones, at least two : the Card Game Framework by dbo and the Card Engine by Braindead.
Which one is best to use ?
I really need only simple things :
1 - A list of different cards
2 - A few decks to draw from
3 - Animation to show the cards in each deck when one wants to draw (it's not random drawing in my game, the player chooses the card he wants - so I guess functionally it's more a "hand" than a "deck" but UI wise they'll be shown as decks on the board)
4 - Ability (and the corresponding animation I guess) to choose a card and play it on the board (on BoardPlacementSlots I guess).
5 - Ability for BoardPlacementSlots to hold (and show) many cards on it
6 - Ability (and the corresponding animation) to check which cards are on BoardPlacementSlot
And that's it.
I dabbled a little bit with one of them (dbo's I guess) before I changed computer and had to re-download everything (which led me to understand that there are more than one) and apparently the way to use it was to open it with Godot and then add my scenes inside of it ?
Isn't it a bit heavy and cumbersome ?
Do both framework (or others I don't know of) work that way ?
I'm much prefer have clear snippets of code/ressources that I could import into my project and then modify according to what I need.
Well, I tried BrainDeadBzh's framework CardEngine and looked a bit at its documentation.
But it says "To create a database press the "Create new database" button."
Where do I find this button ?
There's a screenshot of the button but on a panel I don't know where to look for.
Or is the addon just not working ?
I got "Impossible de charger le script de l’extension depuis le chemin : « res://addons/cardengine/card_engine.gd ». Cela peut être dû à une erreur de programmation dans ce script.
L'extension « res://addons/cardengine/plugin.cfg » a été désactivée pour prévenir de nouvelles erreures." when trying to enable it in the Project Settings/extensions panel.
I did try CardEngine in different versions of Godot but to no avail, I still get the same error message.
I also tried a different add-on to test whether I was doing something wrong, but this other add-on works.
The error message seems simple enough, but I don't understand why it appears : I checked that there is actually a card_engine.gd file in addons/cardengine and its syntax doesn't seem different than any other plugin's.
It's also, as far as i can see, correctly referred to in the plugin.cfg file.
- Edited
It would probably be more helpful if you could provide the error in english.
as per github repo :
Currently under development, do not expect it to work.
Everything is work in progress.
You can maybe open an issue on the repo tho. @braindeadbzh seems to be registered on the forums so perhaps they can confirm if this is the preferred way to move forward.
Hello. Yes opening an issue is the best way if you encounter a bug with CardEngine.
Megalomaniak more helpful if you could provide the error in english.
How ?
Godot gives it to me in French...
braindeadbzh
Is there a non-microsoft repository where to open this issue ?
LienRag How ?
Godot gives it to me in French...
I mean you could translate it, either yourself or using a translation app or such. As the one requesting help I'd say the onus is on you to make helping you as low barrier as possible. This is not limited to just translating errors given but also including things such as providing more info about how the relevant scene is built, what the node structure is like, what signals might be connected and to where, etc.
LienRag Is there a non-microsoft repository
Microsoft doesn't own the contents of the repo tho, they only acquired the service provider. It's one thing if you don't want to host any of your code there but reporting issues to the relevant repo shouldn't really be an issue realistically.
Oh, OK.
"Impossible to charge extension's script from path : « res://addons/cardengine/card_engine.gd ».
This may be due to a programming error in the script.
The extension « res://addons/cardengine/plugin.cfg » has been disactivated to prevent further errors".
No relevant scene is built since I get this error whether I try to activate the plugin in an already existing scene or on a completely brand-new one.
This from 3.3 to 3.5.0.
Megalomaniak Microsoft doesn't own the contents of the repo tho, they only acquired the service provider. It's one thing if you don't want to host any of your code there but reporting issues to the relevant repo shouldn't really be an issue realistica
Well, this requires an account in the devil's book, doesn't it ?
I do have one from before they were acquired (though they weren't free software at that time either) so I probably can soil my soul the way you recommend it, yes.
Done : https://github.com/BraindeadBZH/godot_card_engine/issues/20
Saint Ignucius have mercy on my poor soul !
Apparently the plugin works and I just don't understand how to use it.
Problem is, I still don't understand.
"this repo is supposed to be used as a template" : how to do that ?
- Edited
Well, lets go through it in order: Have you set up the appropriate autoloads as shown in the image?
Do you have the project.cardengine
file in your project root? You might have to poke @braindeadbzh about providing an example project.cardengine
file perhaps if there is no documented example of what paths it should hold.