Cuberite Forum

Full Version: cIniFile help?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Does anyone know if you can list the keys inside a section of an ini file using cIniFile? If so, how could you do it?
Maybe this helps: https://code.google.com/p/mc-server/sour...354&r=1354 it shows a list of groups.
Ok, thanks. It relies on that key numbers are just counting up from 0, instead of random numbersTongue

(the dics didn't say what the key number was).
Yeah, I really hate that cIniFile interface. But what can I do, if I rewrite everything I hate, there'd be nothing leftTongue

Anyway, feel free to enhance the docs, it's a wiki, after all. I'm trying, from time to time - at least the hook handlers are more or less documented now, but there's just too many classes with too many changes in them.
Maybe we should build a new IniFile class? Or maybe we could even get a nice YAML parser (you can have more nesting) and deprecate the INI files, but keep IniFile in there for the old plugins.
An XML parser is planned in the API:
http://www.mc-server.org/support/index.p...ask_id=336
Later on...
Seems sensible Smile
how to insert multiple things in a value? i did this:
Block:SetValue( KeyName, "I", Player:GetName() .. "," .. "Placed" .. "," .. os.date() .. "," .. Player:GetWorld():GetBlock(X, Y, Z) .. "," .. Player:GetWorld():GetBlockMeta(X, Y, Z) )
to store the data and then this:
Player,Broken,Date,BlockID,BlockMeta = Block:GetValue(KeyName, "I")
to get the info but "Player" gets all the data "I" has stored in an ini file and "Broken" gets everything "KeyName" has.
IDK, simplest way is to do what I do, use my split function:

Code:
function split(string, pattern)

    -- Define variables.
    local t = {}  -- NOTE: use {n = 0} in Lua-5.0
    local fpat = "(.-)" .. pattern
    local last_end = 1
    local s, e, cap = string:find(fpat, 1)

    -- Split the string.
    while s do
        if s ~= 1 or cap ~= "" then
            table.insert(t,cap)
        end
        last_end = e+1
        s, e, cap = string:find(fpat, last_end)
    end

    if last_end <= #string then
        cap = string:sub(last_end)
        table.insert(t, cap)
    end

    -- Return the table.
    return t

end

Call it with:

Code:
Player = split(Block:GetValue(KeyName, "I"), ",")

The code is free to use for whatever you like.
and how can i then add something to Broken, Date, BlockID and BlockMeta with that function? i'm not realy good with tables :S
Pages: 1 2