Rework data systems #78

Open
opened 2022-09-28 10:29:42 +02:00 by kazhnuz · 5 comments
Owner

The current "data" system use a really weird way of coverting list of arguments into file, it would be better to use a more "data-like" behaviour, with validator.

Core principle that it needs :

  • Not too much overhead, the result should be "pure" lua structure
  • It should just be a validating process on data loading, and maybe some class to handle better table/list/etc
  • Epervier should have a special launch option to be able to validate all datas and list every errors in a log file

Needed features

  • Structure-like instead of list-like
  • Support table and list
  • Validation file instead of parsers
  • Typing and slight validation ?
    • Nullable field (or multi-type ?)
  • Possibility of having different structure for a list of struct

Other

  • Could be used for "struct-like" arguments like coordinate in the new world system ?
  • Could also be used for metadata for sprites and stuff
  • Same for maps ?
The current "data" system use a really weird way of coverting list of arguments into file, it would be better to use a more "data-like" behaviour, with validator. Core principle that it needs : - Not too much overhead, the result should be "pure" lua structure - It should just be a validating process on data loading, and maybe some class to handle better table/list/etc - Epervier should have a special launch option to be able to validate all datas and list every errors in a log file Needed features - Structure-like instead of list-like - Support table and list - Validation file instead of parsers - Typing and slight validation ? - Nullable field (or multi-type ?) - Possibility of having different structure for a list of struct Other - Could be used for "struct-like" arguments like coordinate in the new world system ? - Could also be used for metadata for sprites and stuff - Same for maps ?
kazhnuz added this to the epervier 0.8.0 (beta 1) milestone 2022-09-28 10:29:42 +02:00
kazhnuz added the
1. Improvement
3. Need investigation
1. Feature
2. Epic
4. Birb Core
labels 2022-09-28 10:29:42 +02:00
Author
Owner

Exemple of validation

return {
  id = "number,min=0,integer",
  name = "string,optional",
  flags = "list,string,optional",
  attacks = {
    _type = "list,optional",
    name = "string",
    power = "number,optional",
    type = "value=physical,string|value=special,string",
  },
  stats = {
    pv = "number"
  }
}
return {
  id = 23,
  name = "Adventurer",
  description = "An adventurer",
  flags = {"test", "test2"},
  attacks = {
    {type = "physical", name="hit", power=2},
    {type = "special", name="hit2", power=2},
    {type = "physical", name="test"}
  },
  stats = {
    pv = 5
  }
}
Exemple of validation ```lua return { id = "number,min=0,integer", name = "string,optional", flags = "list,string,optional", attacks = { _type = "list,optional", name = "string", power = "number,optional", type = "value=physical,string|value=special,string", }, stats = { pv = "number" } } ``` ```lua return { id = 23, name = "Adventurer", description = "An adventurer", flags = {"test", "test2"}, attacks = { {type = "physical", name="hit", power=2}, {type = "special", name="hit2", power=2}, {type = "physical", name="test"} }, stats = { pv = 5 } } ```
Author
Owner

A "table" type would be usefull too

A "table" type would be usefull too
Author
Owner

Unifying the save handling, the gamedatas and maybe even the options could be an idea.

How it would work would be

  • dataset have a "path" and loading it will search the data.
  • options and save datas are loaded as dataset, and are marked as "writable" (maybe with a _filename property).
  • options datas are used by the framework directly to load important options.
  • save dataset will be defined as part of a "game" def, which will be used to create datas (and maybe replace the current love.conf used ?)
  • It's possible to replace and save a dataset if it is writable, the right file will be then written when the related save function is used (which save everything related to a savefile)

Other useful features:

  • Being able to load multiple dataset at once with a * replacing the last element *
  • Add a filter system, that can test a dataset and look up one of its variables
  • Add a "function" system where we can add a function and that'll
  • Add maybe a "template" system, where ${x} is replaced by a var
  • Add maybe an iteration system for saves that would automatically add the "save.n" at the beggining ?
Unifying the save handling, the gamedatas and maybe even the options could be an idea. How it would work would be - dataset have a "path" and loading it will search the data. - options and save datas are loaded as dataset, and are marked as "writable" (maybe with a `_filename` property). - options datas are used by the framework directly to load important options. - save dataset will be defined as part of a "game" def, which will be used to create datas (and maybe replace the current love.conf used ?) - It's possible to replace and save a dataset if it is writable, the right file will be then written when the related save function is used (which save everything related to a savefile) Other useful features: - Being able to load multiple dataset at once with a * replacing the last element * - Add a filter system, that can test a dataset and look up one of its variables - Add a "function" system where we can add a function and that'll - Add maybe a "template" system, where `${x}` is replaced by a var - Add maybe an iteration system for saves that would automatically add the "save.n" at the beggining ?
Author
Owner

APIs :

data:read(filename) -- read every datas related to a filename
data:write(filename) -- write every datas related to a filename

data:get("the.dataset.path.${var}", {var="test"}) -- return a singular data. Iteration of ${var} will be replaced by "test". If a function is used instead of a dataset path, call the function.
data:getList("the.dataset", vars, filters) -- get datas from a list of adata (need the datas to be a list)
data:get("functionName") -- call a function that return
data:getFromSave("path", saveid)

data:set("the.dataset.path", dataset) -- set the data (the data need to be writable)
APIs : ```lua data:read(filename) -- read every datas related to a filename data:write(filename) -- write every datas related to a filename data:get("the.dataset.path.${var}", {var="test"}) -- return a singular data. Iteration of ${var} will be replaced by "test". If a function is used instead of a dataset path, call the function. data:getList("the.dataset", vars, filters) -- get datas from a list of adata (need the datas to be a list) data:get("functionName") -- call a function that return data:getFromSave("path", saveid) data:set("the.dataset.path", dataset) -- set the data (the data need to be writable) ```
Author
Owner

Maybe a way to map something from the save to something from the gamedata would be usefull too. Maybe iterate the API from Radiance's game

Maybe a way to map something from the save to something from the gamedata would be usefull too. Maybe iterate the API from Radiance's game
Sign in to join this conversation.
No description provided.