So, if you already played games like Factorio, Rimworld or Dwarf Fortress and tried to mod those games, you will find that it’s absurdly easy to mod them for simple things like changing the balancing, adding items, changing descriptions and etc. Because the data files of the games are simple raws and not binaries and things like that. This library pretty much makes the task of using raws as simple as possible.
Also, the library might have Panda3D in mind, however it’s not a dependency and can pretty much be used for any sort of software or game engine that uses python.
Internally the library use dataclasses to handle the data and TinyDB to load them from raws.
Let’s go for examples, shaw we
from panda_core_data.model import Model
class Items(Model, data_name="items"):
name: str
description: str
cost: int
In the code above we create a simple class that have Name, Description and Cost as fields. Then we can use this file:
data:
- name: "Copper"
- description: "Fragile material"
- value: 1
To hold the data of our class.
And then to load our data we can simply call
copper = Items.instance_from_raw("copper.yaml")
However, the library offers an automatic way of loading any raw and any Model without you even caring with you importing and setting the path to the raws. More information about the above example, how to use the automatic way or how to get started in general, just chek our documentation here:
https://pandacoredata.readthedocs.io/en/latest/tutorial/index.html