summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-05-02 19:34:54 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-05-02 19:34:54 -0400
commitd37298c12ebc3d001c55d66b2319aeeda09dafd2 (patch)
treeaac87080202383ae2e57c3b359061fe6ddc4eb5f
parent79a5901ce9206f27090c590393838232fc23be62 (diff)
downloadgmstranded-d37298c12ebc3d001c55d66b2319aeeda09dafd2.tar.gz
gmstranded-d37298c12ebc3d001c55d66b2319aeeda09dafd2.tar.bz2
gmstranded-d37298c12ebc3d001c55d66b2319aeeda09dafd2.zip
Started work on databaseing engine
-rw-r--r--gamemode/itemsystem/items/aaaItemExample.lua1
-rw-r--r--gamemode/server/database.lua59
2 files changed, 60 insertions, 0 deletions
diff --git a/gamemode/itemsystem/items/aaaItemExample.lua b/gamemode/itemsystem/items/aaaItemExample.lua
index ee67639..872e93e 100644
--- a/gamemode/itemsystem/items/aaaItemExample.lua
+++ b/gamemode/itemsystem/items/aaaItemExample.lua
@@ -12,6 +12,7 @@ ITEM.Description = "Why did I even write this? No one will ever read it!"
ITEM.Icon = "test.png"
--If this item has "unique data", for example batteries that run out of charge
+--If true, then the item must define a table .UniqueFields, an array of strings that tell what fields are unique.
ITEM.UniqueData = false
--A table of strings to functions that show up when the player clicks the item in their inventory.
diff --git a/gamemode/server/database.lua b/gamemode/server/database.lua
index 5ebce8e..3a40fe5 100644
--- a/gamemode/server/database.lua
+++ b/gamemode/server/database.lua
@@ -1 +1,60 @@
--Provides an interface to store data in a database of some kind
+--[[
+Uses:
+ GM.StorageMethod
+ Can be: "Text", "Static Map", "LZWCompressed"
+ If method is "Static Map", then GM.StoreageStaticMap must be a table of strings to string ID's.
+ GM.StorageBackend
+ Can be: "File"
+ GM.StorageDebug
+ Can be: true, false
+ Enables extra debugging to find errors easily
+]]
+
+function loadTable(uniqueIdentifier)
+
+ return nil
+end
+
+function storeTable(uniqueIdentifier, table)
+ if(GM.StorageDebug) then
+ print("Asked to store:")
+ PrintTable(table)
+ end
+ if(GM.StorageDebug) then
+ for k,v in pairs(tbl) do
+ if(isfunction(v)) then
+ print("Database.lua error: tried to save a table that has a function in it!")
+ PrintTable(tbl)
+ print("At field:")
+ print(k)
+ end
+ end
+ end
+
+end
+
+local function convertTableToText(tbl)
+ if(GM.StorageMethod == "Text") then
+
+ elseif(GM.StorageMethod == "Static Map") then
+
+ elseif(GM.StorageMethod == "LZWCompressed") then
+
+ else
+ print("------------ERROR: database.lua----------")
+ print("\tGM.StorageMethod is not a valid value!")
+ print("Should be on of:\"Text\",\"Static Map\", or \"LZWCompressed\", but is:")
+ print(GM.StorageMethod)
+ end
+end
+
+local function convertTableStatic(tbl)
+ if(GM.StorageStaticMap == nil) then
+ print("---------ERROR: database.lua-----------")
+ print("\tGM.StorageMethod is set to \"Static Map\", but GM.StoreageStaticMap is not defined!")
+ return
+ end
+
+
+end