Miscreated

Miscreated

评价数不足
[ModResource] MisDB
   
奖励
收藏
已收藏
取消收藏
标签: Scripts, modules
文件大小
发表于
更新日期
19.295 KB
2019 年 8 月 21 日 上午 8:47
2019 年 8 月 31 日 上午 10:04
3 项改动说明 ( 查看 )

订阅以下载
[ModResource] MisDB

描述
MisDB
This is a Modding Resource, This WONT do anything on its own

MisDB Provides Mods With a Method for "Data Persistance"
Via JSON File Backed "Pages" and "Collections".
Based on a Module to Providing a "Pure Lua" implementation
'Similar' to flatDB/NoDB

MisDB Takes a Lua Table Converts it to JSON, and we call that a "Page"
These "Pages" are Grouped into Named "Collections" and Stored as Seperate Files,
One for Each Different Collection in a Folder with this "MisDB Objects" Name
And Placed in the Specified Base Directory (Relative to Your Server Root)
eg:

For a MisDB Called "MyModsData" with a Collection Named "Settings"
and Stored in the BaseDir "MisDBdata" :
[ServerRoot]>{BaseDir}/{MisDB Name}/{Collection Name} ServerRoot>/MisDBdata/MyModsData/Settings


Methods:
To use this you need to Include the following line to load the script before using it Script.ReloadScript("scripts/MisDB/MisDB.lua") * MisDB:Create(BaseDir, Name) ~> TableObject(Your Main MisDB Object) Creates a New MisDB Object to Store Collections Backed by files in [ServerRoot]>{BaseDir}/{Name} With the Returned {Object} then: * {Object}:Collection(Name) ~> CollectionObject(Table/Object defining this Collection) Create/Fetch a New Collection in this MisDB (Non Existant Collections Are autoCreated) the Returned {Collection} then provides the following Methods: * {Collection}:GetPage(pageId) Fetch The Contents of a "Page" from this "Collection" By Specified PageID ! This Will return nil, with a message as the Second return var if the Page Does Not Exist * {Collection}:SetPage(pageId,data) Set The Contents of a "Page" from this "Collection" By Specified PageID ? Returns the "written to disk" Copy of the Page Content you Set ? Use this to save your page data and use the return to verify against your data * {Collection}:PurgePage(pageId) Remove a "Page" from this "Collection" By Specified PageID ? returns true/nil and a message with the result --! You "Should" be Using the GetPage/SetPage functions and Editing your --! Collection a Page at a Time using Local Copies, helps Performance(less I/O Calls) --! Provides some Protection from any invalid Writes if you allways check the pagedata
热门讨论 查看全部(1)
0
2019 年 9 月 21 日 上午 8:34
General
Theros