Cuberite Forum
cIniFile help? - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Plugins (https://forum.cuberite.org/forum-1.html)
+--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html)
+--- Thread: cIniFile help? (/thread-845.html)

Pages: 1 2


RE: cIniFile help? - bearbin - 04-06-2013

Ah, sorry forgot. It returns a list, and you can do like Player[1], player[2] and so on.


RE: cIniFile help? - xoft - 04-07-2013

Actually MCServer already has a StringSplit() function that does more or less the same thing, but may be faster because it's native. It returns an AStringVector, which is exported to the Lua API so that you can use:
Code:
local Values = StringSplit(IniFile.Get(...), ",");  -- split by commas
local First = Values[0];
local Second = Values[1];
-- etc.
Not sure now if the arrar is zero-based or 1-based. But you already use that because it's how commands are handled Smile


RE: cIniFile help? - bearbin - 04-07-2013

Arrays are 1-based. Smile

I didn't know that existed, is it in the global function helpers section on the wiki?


RE: cIniFile help? - xoft - 04-07-2013

Lua arrays are, but are these native arrays as well? That's the question.

It's in the globals, but no wonder noone notices it - the wiki page is almost unreachable:
http://www.mc-server.org/wiki/doku.php?id=api:plugin:globals


RE: cIniFile help? - bearbin - 04-07-2013

I just added itTongue That's why its there.


RE: cIniFile help? - FakeTruth - 04-07-2013

(04-07-2013, 02:17 AM)xoft Wrote: Lua arrays are, but are these native arrays as well? That's the question.

It's in the globals, but no wonder noone notices it - the wiki page is almost unreachable:
http://www.mc-server.org/wiki/doku.php?id=api:plugin:globals

It's not a native array, it is pushed to Lua as a Lua array effectively copying the entire thing.