INI Arrays
#8
Hey,

Does this fit to you?
With GetNumValues() from cIniFile you can get the amount of values from a key, then you can foor loop over it. I use this nice idea in my skyblock plugin for the challenenges.

Messages.ini
Code:
[motd]
1=First motd
2=Second motd


[First motd]
1=Line 1
2=Line 2


[Second motd]
1=Line 1
2=Line 2
3=Line 3

TestPlugin.lua
PLUGIN = nil

function Initialize(Plugin)
    Plugin:SetName("TestPlugin")
    Plugin:SetVersion(1)

    PLUGIN = Plugin
   
    local MessagesIni = cIniFile()
    MessagesIni:ReadFile(PLUGIN:GetLocalDirectory() .. "/Messages.ini")
    
    local amountMOTD = MessagesIni:GetNumValues("motd")
    for i = 1, amountMOTD do
        LOG(MessagesIni:GetValue("motd", i))
        local motd = MessagesIni:GetValue("motd", i)
        local amountLines = MessagesIni:GetNumValues(motd)
        for line = 1, amountLines do
            LOG(MessagesIni:GetValue(motd, line))
        end
        LOG("")
    end
end

regards,
Seadragon91

Edit: Renamed l to line
Reply
Thanks given by:


Messages In This Thread
INI Arrays - by tryy3 - 09-12-2014, 09:34 PM
RE: INI Arrays - by LO1ZB - 09-12-2014, 10:10 PM
RE: INI Arrays - by tryy3 - 09-12-2014, 10:32 PM
RE: INI Arrays - by xoft - 09-12-2014, 10:36 PM
RE: INI Arrays - by tryy3 - 09-12-2014, 11:29 PM
RE: INI Arrays - by tigerw - 09-13-2014, 03:54 AM
RE: INI Arrays - by tryy3 - 09-13-2014, 05:26 AM
RE: INI Arrays - by Seadragon91 - 09-13-2014, 06:12 AM
RE: INI Arrays - by tryy3 - 09-13-2014, 08:22 AM
RE: INI Arrays - by xoft - 09-13-2014, 09:10 PM



Users browsing this thread: 1 Guest(s)