Managing mod files
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Managing mod files
(I know nooby question, but...)
Someone know how to manage files in minetest mods? Means - create file, remove file, edit content of file (both binary and text), create folder, remove folder and best would be permissions (like chmod, yep im a linux fan)
Someone know how to manage files in minetest mods? Means - create file, remove file, edit content of file (both binary and text), create folder, remove folder and best would be permissions (like chmod, yep im a linux fan)
-
- Member
- Posts: 177
- Joined: Mon Dec 07, 2020 01:04
- GitHub: ronoaldo
- IRC: ronoaldo
- In-game: RonoaldoKakashi
- Location: São Paulo, Brasil
- Contact:
Re: Managing mod files
Hi! welcome to the forums and Minetest :D
If I understood your question right, you want to make changes to the mod files, correct?
The mods are basically scripts written in the Lua programming language, so if you want to change the code any text file editor will be OK! If you already know how to code and use an IDE, just open the files there. If you prefer to use the terminal on Linux, Vi/Vim or even Nano are some good options too. I personally use VS Code, but the default text editor on most linux desktop environments will come with syntax highlight for Lua (Kwrite, Gedit, Leafpad, ...). For directories, no special things needed: just mkdir from terminal or use the file manager (Dolphin, Nautlius, Thunar, ...) for that.
For textures and models, you need specific programs for that. Gimp is good for editing the PNG files but if you want to change, say, a model 3d object, you usually will go for something like blender. For blender, you also need something to convert it to b3d and there is an extension to do the conversion that keeps all animations so you can use them on Minetest.
If you are into modding, this is a great starting point: https://rubenwardy.com/minetest_modding ... index.html
Also, there is a Youtube video series that walks over the process step by step, which is also great: https://www.youtube.com/watch?v=GgG9MHUGnew
Feel free to share error messages you may be receiving if you are trying to make changes so we may help with that... Depending on the issue you may need to debug it yourself :(
Yep, I'm also a Linux for for... like, 20 years O.O - I use Debian KDE by the way :-P
If I understood your question right, you want to make changes to the mod files, correct?
The mods are basically scripts written in the Lua programming language, so if you want to change the code any text file editor will be OK! If you already know how to code and use an IDE, just open the files there. If you prefer to use the terminal on Linux, Vi/Vim or even Nano are some good options too. I personally use VS Code, but the default text editor on most linux desktop environments will come with syntax highlight for Lua (Kwrite, Gedit, Leafpad, ...). For directories, no special things needed: just mkdir from terminal or use the file manager (Dolphin, Nautlius, Thunar, ...) for that.
For textures and models, you need specific programs for that. Gimp is good for editing the PNG files but if you want to change, say, a model 3d object, you usually will go for something like blender. For blender, you also need something to convert it to b3d and there is an extension to do the conversion that keeps all animations so you can use them on Minetest.
If you are into modding, this is a great starting point: https://rubenwardy.com/minetest_modding ... index.html
Also, there is a Youtube video series that walks over the process step by step, which is also great: https://www.youtube.com/watch?v=GgG9MHUGnew
Feel free to share error messages you may be receiving if you are trying to make changes so we may help with that... Depending on the issue you may need to debug it yourself :(
Yep, I'm also a Linux for for... like, 20 years O.O - I use Debian KDE by the way :-P
- Blockhead
- Member
- Posts: 1622
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: Managing mod files
The Lua standard library includes an I/O Library. These functions are accessible in Minetest. I don't think they can be used to set file permission though, since Lua is cross-platform to Windows where the UNIX permissions system isn't used (therefore introducing a platform-specific operation wouldn't make sense necessarily).
For security, you can only modify files within the current running world directory. Otherwise you could write a virus in Minetest Lua code. So you should start all filename strings with a call to minetest.get_worldpath() then concatenate file and directory names. Also, you should usually use modstorage (another link) unless you need to save binary data or access the same files as another mod*.
An example:
*Someone with more info should answer: Is this line in the documentation still relevant now that modstorage has moved to a database backend instead of flat files?
For security, you can only modify files within the current running world directory. Otherwise you could write a virus in Minetest Lua code. So you should start all filename strings with a call to minetest.get_worldpath() then concatenate file and directory names. Also, you should usually use modstorage (another link) unless you need to save binary data or access the same files as another mod*.
An example:
Code: Select all
f = io.open(minetest.get_worldpath().."/mymodname/filename", "w")
f:write("Hello, world!")
f:close()
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
Thx. Thought it was from minetest to modify files tho :’D
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
-
- Member
- Posts: 177
- Joined: Mon Dec 07, 2020 01:04
- GitHub: ronoaldo
- IRC: ronoaldo
- In-game: RonoaldoKakashi
- Location: São Paulo, Brasil
- Contact:
Re: Managing mod files
Sorry, I misinterpreted your question. You can in theory use any lua libraries, but I guess you need to embed them in your mod and use the `dofile` instruction for that.
What do you mean by binary files? Binary files are random bytes / blobs, any specific format you have in mind?
Keep in mind that Minetest sandboxes your mod code, so it don't have arbitrary access to any file in the client/server it is running on. If you need to change arbitrary files, like other mod code or files outside the world directory, you need to request what is defined as a "insecure environment". See this chapter for more about security https://rubenwardy.com/minetest_modding ... vironments
Honestly, I would not allow such access to a mod though, so if the users don't add the mod and enable the insecure environment, your cod will not work as expected.
What do you mean by binary files? Binary files are random bytes / blobs, any specific format you have in mind?
Keep in mind that Minetest sandboxes your mod code, so it don't have arbitrary access to any file in the client/server it is running on. If you need to change arbitrary files, like other mod code or files outside the world directory, you need to request what is defined as a "insecure environment". See this chapter for more about security https://rubenwardy.com/minetest_modding ... vironments
Honestly, I would not allow such access to a mod though, so if the users don't add the mod and enable the insecure environment, your cod will not work as expected.
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
also next question - what about running other programming languages in lua? like C or bash
Spoiler
(or assembly...)
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
and also - someone knows if its possible to embed other folders to init.lua ? like /games /root or /misc ?
- joe7575
- Member
- Posts: 851
- Joined: Mon Apr 24, 2017 20:38
- GitHub: joe7575
- In-game: JoSto wuffi
- Location: Germany, in the deep south
Re: Managing mod files
This is possible by accepting that this mod becomes insecure and has to be added to the list of 'secure.trusted_mods'.hacknorris wrote: ↑Thu Mar 31, 2022 18:08and also - someone knows if its possible to embed other folders to init.lua ? like /games /root or /misc ?
E. g. PDP-13 is a mod, with provides a file system for each computer.
Sent from my Commodore 64. Some of my Mods: Tech Age, TechPack, Hyperloop, Tower Crane, Lumberjack, vm16, Minecart, Signs Bot.
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
thanks for saying that. now i dont have project :/joe7575 wrote: ↑Fri Apr 01, 2022 11:27This is possible by accepting that this mod becomes insecure and has to be added to the list of 'secure.trusted_mods'.hacknorris wrote: ↑Thu Mar 31, 2022 18:08and also - someone knows if its possible to embed other folders to init.lua ? like /games /root or /misc ?
E. g. PDP-13 is a mod, with provides a file system for each computer.
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
last question - is it possible if such mod with insecure env gets approved to contentdb or i can only github?
- rubenwardy
- Moderator
- Posts: 6972
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Managing mod files
Yes, ContentDB allows that.hacknorris wrote: ↑Sun Apr 03, 2022 11:31last question - is it possible if such mod with insecure env gets approved to contentdb or i can only github?
It only disallows mods that ask for the sandbox to be fully disabled, rather than using insecure env
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
so if i create something that writes to mod subdirs and reads from it can be?
- rubenwardy
- Moderator
- Posts: 6972
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: Bristol, United Kingdom
- Contact:
Re: Managing mod files
Yeah, but be aware that mod files are overwritten when the mod updates. So any new files or changes in mod directories will be lost
Oh, and if this is a hack and there's a better way to do it then you'll be asked to do that
Oh, and if this is a hack and there's a better way to do it then you'll be asked to do that
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
well... then i'd rather put it in github as i did with mtMod.... (yes, this is my acc again )
- Blockhead
- Member
- Posts: 1622
- Joined: Wed Jul 17, 2019 10:14
- GitHub: Montandalar
- IRC: Blockhead256
- In-game: Blockhead Blockhead256
- Location: Land Down Under
- Contact:
Re: Managing mod files
Thread recap:
Hacknorris wants to write a mod that will use unnecessary self-modifying code techniques or other obscure methods without giving a justification.
Response from Rubenwardy: Well you know you probably don't need to and shouldn't do it that way
Response from Hacknorris: Uhh well then I'm not going to publish it on ContentDB.
Ok but seriously though are you trying to write something super special that we haven't seen before, for which you need this technique, or are you just going to create a big mess that would never pass code review?
Hacknorris wants to write a mod that will use unnecessary self-modifying code techniques or other obscure methods without giving a justification.
Response from Rubenwardy: Well you know you probably don't need to and shouldn't do it that way
Response from Hacknorris: Uhh well then I'm not going to publish it on ContentDB.
Ok but seriously though are you trying to write something super special that we haven't seen before, for which you need this technique, or are you just going to create a big mess that would never pass code review?
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
well... its not even special and im slowly moving out of it cause i saw that someone already did it... (vm16 and pdp-13)
- Miniontoby
- Member
- Posts: 616
- Joined: Fri Mar 01, 2019 19:25
- GitHub: Miniontoby
- IRC: Miniontoby
- In-game: Miniontoby
- Location: The Netherlands
Re: Managing mod files
Possible but difficult... and only at server side mods...hacknorris wrote: ↑Tue Mar 29, 2022 15:33also next question - what about running other programming languages in lua? like C or bashSpoiler
(or assembly...)
- Linuxdirk
- Member
- Posts: 3217
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Managing mod files
You should not write to mod sub directories. Better write to the world directory. This also allows the mod to be used in multiple worlds with own individual settings/data.hacknorris wrote: ↑Sun Apr 03, 2022 14:29so if i create something that writes to mod subdirs and reads from it can be?
-
- Member
- Posts: 68
- Joined: Mon Mar 28, 2022 21:34
- GitHub: hacknorris-aka-penguin
- IRC: hacknorris
- In-game: hacknorris
Re: Managing mod files
anyways - why i still get reply to this? someone can close thread as done? pls...
i already gave up and doing very other things...
i already gave up and doing very other things...
- Linuxdirk
- Member
- Posts: 3217
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: Managing mod files
Report your initial post and ask for the thread being closed.
Who is online
Users browsing this forum: Google [Bot] and 7 guests