File IO Help

User avatar
false_chicken
Member
 
Posts: 51
Joined: Wed Feb 04, 2015 23:41
Location: Florida, USA
GitHub: falsechicken
In-game: false_chicken

File IO Help

by false_chicken » Fri Feb 06, 2015 02:50

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!
DISCLAIMER: I am probably wrong.
 

User avatar
Krock
Developer
 
Posts: 4341
Joined: Thu Oct 03, 2013 07:48
Location: Switzerland
GitHub: SmallJoker

Re: File IO Help

by Krock » Fri Feb 06, 2015 09:46

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.
>> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
 

User avatar
false_chicken
Member
 
Posts: 51
Joined: Wed Feb 04, 2015 23:41
Location: Florida, USA
GitHub: falsechicken
In-game: false_chicken

Re: File IO Help

by false_chicken » Fri Feb 06, 2015 19:02

Cool thanks. Ill give it a shot. Any other information anyone has would be appreciated.
DISCLAIMER: I am probably wrong.
 

User avatar
domtron vox
Member
 
Posts: 111
Joined: Thu Feb 20, 2014 21:07
GitHub: DomtronVox
IRC: Domtron
In-game: Domtron

Re: File IO Help

by domtron vox » Wed Feb 11, 2015 00:36

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.
 

User avatar
false_chicken
Member
 
Posts: 51
Joined: Wed Feb 04, 2015 23:41
Location: Florida, USA
GitHub: falsechicken
In-game: false_chicken

Re: File IO Help

by false_chicken » Wed Feb 11, 2015 01:18

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.
DISCLAIMER: I am probably wrong.
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 6 guests