cIniFile help?
#1
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?
Reply
Thanks given by:
#2
Maybe this helps: https://code.google.com/p/mc-server/sour...354&r=1354 it shows a list of groups.
Reply
Thanks given by:
#3
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).
Reply
Thanks given by:
#4
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.
Reply
Thanks given by:
#5
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.
Reply
Thanks given by: NiLSPACE
#6
An XML parser is planned in the API:
http://www.mc-server.org/support/index.p...ask_id=336
Later on...
Reply
Thanks given by:
#7
Seems sensible Smile
Reply
Thanks given by:
#8
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.
Reply
Thanks given by:
#9
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.
Reply
Thanks given by:
#10
and how can i then add something to Broken, Date, BlockID and BlockMeta with that function? i'm not realy good with tables :S
Reply
Thanks given by:




Users browsing this thread: 8 Guest(s)