Page 1 of 1

File IO Help

PostPosted: Fri Feb 06, 2015 02:50
by false_chicken
Hello. I have begun creating a mod that would require that I create a directory in my mods folder that would store configuration files. Is there a Minetest specific way of doing this (For safety) or should I just use standard LUA IO? I noticed a PR on Github that mentioned adding mod security (https://github.com/minetest/minetest/pull/1606) that is why I am asking. I want to be future proof.

Also I noticed in the comments on the PR that ShadowNinja mentioned using "core.mkdir" as an alternative. Could someone explain what that is? I searched the wiki but couldn't find any documentation mentioning anything like that. Thanks!

Re: File IO Help

PostPosted: Fri Feb 06, 2015 09:46
by Krock
You can try the Lua IO functions, Minetest will throw warnings/errors when it's not happy about the them.
There was nothing about core.mkdir in the codes - I think it has not been added yet.

Re: File IO Help

PostPosted: Fri Feb 06, 2015 19:02
by false_chicken
Cool thanks. Ill give it a shot. Any other information anyone has would be appreciated.

Re: File IO Help

PostPosted: Wed Feb 11, 2015 00:36
by domtron vox
Hello! I messed around with file IO in my ranks and kits mod. I load information from a text file that lists one item (and optionally an amount) on each line. Here is the lua file (link goes to the relevant line) https://github.com/DomtronVox/minetest- ... it.lua#L96

I know it worked on ubuntu linux. However, I think there was an issue with it working on windows and I never got around to solving it. I hope it helps you solve your problem. If you find a working solution please post it as I'm still very interested in this subject.

Re: File IO Help

PostPosted: Wed Feb 11, 2015 01:18
by false_chicken
domtron vox wrote:Hello! I messed around with file IO in my ranks and kits mod. I load information from a text file that lists one item (and optionally an amount) on each line. Here is the lua file (link goes to the relevant line) https://github.com/DomtronVox/minetest- ... it.lua#L96

I know it worked on ubuntu linux. However, I think there was an issue with it working on windows and I never got around to solving it. I hope it helps you solve your problem. If you find a working solution please post it as I'm still very interested in this subject.


Thanks for the reply! My project involves saving inventory configurations that you could switch at will for creative purposes. Each player would have their own sub folder where configurations are stored. I was going to have each file name correspond to the configuration but found out that there is not a real platform independent way to list files in lua. At least none that I found. I decided to try and have each configuration listed in one file instead (one config per line). I was playing around with it but couldn't figure it out.

I will put it up on GitHub here soon and reply when I do if you are interested. If you happen to know a platform independent way to list directories/files that would be awesome lol. I also use Linux but would want maximum compatibility. Ill peek at your code and see if it helps me out. By your description it sounds like it will.