2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
973 stars 83 forks source link

How to store a Vector3? #168

Closed scotmcp closed 9 months ago

scotmcp commented 9 months ago

Hi Shady,

I need to store a vector3, GDSqlite is complaining that is a data type 9 and that it can't handle it.

image

The Vector3 is the "P" dictionary item in the Output frame.

How should this be accomplished?

2shady4u commented 9 months ago

Hello @scotmcp

SQLite only supports the following types:

There's no Vector3 there so you'll have to be a bit more creative :) As far as I see these are your options:

  1. Store the Vector3 in its components instead. Meaning that you store X, Y and Z components of the Vector3 as REAL in the database instead.
  2. Store the Vector3 as a string by using the 'var_to_str()'-method and load it out of the database by using the 'str_to_var()'-method.
scotmcp commented 9 months ago

That is what I ended up doing as a workaround, but ... I thought it could be saved as a blob. Splitting it up works, but I would recommend improving blob support. String just seems so .... inefficient. Ok thanks for the help mate.