How to use files in lua
-
- Member
- Posts: 150
- Joined: Mon Feb 18, 2019 02:53
How to use files in lua
How do you load file in lua? I tried this and Minetest would not let the mod work. It was saying that it is forbidden to do that or something while loading the world with the mod. Thanks. I dont usually use lua so I forgot the code I used.
Re: How to use files in lua
Are you trying to write something in a directory other than the mod's own directory? I'm not sure what other circumstances give a similar error. Maybe post what it is you are doing, the directory you installed in, and the exact error message. That would be more helpful than just guessing.
- Linuxdirk
- Member
- Posts: 2712
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: How to use files in lua
dofile('path') for loading Lua files or io.open('path', 'mode') for opening files (mode r for reading, mode w for writing)LC Creations wrote:How do you load file in lua?
Provide your code and a proper error message. This would help people to understand your issue.LC Creations wrote:It was saying that it is forbidden to do that or something
Re: How to use files in lua
This sounds like mod security in action.
Minetest has security mechanisms which prevent io.open and some other functions from accessing files outside of your world folder and your mod folder (I think, didn't try it). Maybe there's also some other place you're allowed to access that I don't know of. minetest.get_worldpath and minetest.get_modpath are functions you can use to get these paths.
If you absolutely need to access files protected by mod security, look into insecure environments. If you just want to store data, there are ways in minetest without accessing files yourself. https://rubenwardy.com/minetest_modding ... orage.html
Minetest has security mechanisms which prevent io.open and some other functions from accessing files outside of your world folder and your mod folder (I think, didn't try it). Maybe there's also some other place you're allowed to access that I don't know of. minetest.get_worldpath and minetest.get_modpath are functions you can use to get these paths.
If you absolutely need to access files protected by mod security, look into insecure environments. If you just want to store data, there are ways in minetest without accessing files yourself. https://rubenwardy.com/minetest_modding ... orage.html
Who is online
Users browsing this forum: Google [Bot] and 1 guest