Hi, i need to make a tree in my datafile with lua language ?
ex :
thanksCode:{ "00000000000000000": { "1": { "count": 0 }, "detected": true }, "00000000000000001": { "1": { "count": 0 }, "detected": true }
Solved Creating a nested datafile in Lua?
Discussion in 'Rust Development' started by CrazyDoo, Sep 22, 2016.
-
Thanks but i got a code with a single line data ...
How to make a tree ? -
The example code builds a nested JSON object, not a flat one.
-
The api exemple :
Json :Code:PLUGIN.Title = "aa" PLUGIN.Description = "aa" PLUGIN.Author = "CrazyDoo" PLUGIN.Version = V(0, 0, 1)local Table = "aa" --Nom du fichier data local dataTable = {} function PLUGIN:Init() self:LoadDataFiles() endfunction PLUGIN:LoadDataFiles() dataTable = datafile.GetDataTable(Table) or {} endfunction PLUGIN:OnExplosiveThrown(player, entity) local name = player.displayName dataTable[name] = true datafile.SaveDataTable(Table) end
Its not tree :sCode:{ "[God] CrazyDoo": true } -
You can simply serialize a nested table. Instead of adding true to the table, try adding a table.
-
@sqroot , I find :
Its a tree !Code:local targetSteamID = rust.UserIDFromPlayer(player) if Data[targetSteamID] then return false end if Data[targetSteamID] == nil then Data[targetSteamID] = {} Data[targetSteamID].az = 0 Data[targetSteamID].aa = false table.insert(Data, Data[targetSteamID]) datafile.SaveDataTable(List)
Its resolved.
