I'm creating a mod for online shopping. It adds to the currency mod that has shops. I know how I'm gonna do it but I need a place to store data. For example, I have a list of strings that I will set as a single string that is set by a single player then I want to get it in another function on another formspec accessed by all players. I also want the data or object to be saved when the client closes and when it opens it's still there. I cannot use mod storage becuase mod storage can only be accessed durring load time. I do not want to use player meta because then I have to search through every player to do what I want, and if you don't know why I do not want to use node meta then you probably also wont be able to answer this question.
I need a easy global place to store metadata just like player metadata that can be accessed anywhere, in any function, and can be saved like player metadata. The fact that this does not already exist is pretty infuriating.
How to store and get data
-
- Member
- Posts: 150
- Joined: Mon Feb 18, 2019 02:53
Re: How to store and get data
Mod storage can NOT only be accessed during load time. You can only call minetest.get_mod_storage() during load time but the storage object it returns can be used whenever. So do something like this:
Code: Select all
local storage = minetest.get_mod_storage()
[rest of the program]
-
- Member
- Posts: 150
- Joined: Mon Feb 18, 2019 02:53
Re: How to store and get data
Wherever I useEran wrote:Mod storage can NOT only be accessed during load time. You can only call minetest.get_mod_storage() during load time but the storage object it returns can be used whenever. So do something like this:Code: Select all
local storage = minetest.get_mod_storage() [rest of the program]
Code: Select all
mod_storage:set_string("mykey", "myvalue")
Last edited by LC Creations on Tue Mar 31, 2020 08:53, edited 2 times in total.
- rubenwardy
- Moderator
- Posts: 6364
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: United Kingdom
- Contact:
Re: How to store and get data
Modding book chapter: https://rubenwardy.com/minetest_modding ... orage.html
Core Developer | Donate | My Twitter | Mods | Mods 4 Android | Node Box Editor | Minetest Modding Book
Hello profile reader
Hello profile reader
-
- Member
- Posts: 150
- Joined: Mon Feb 18, 2019 02:53
Re: How to store and get data
Rubenwardy I just did everything that you just showed me but when I dorubenwardy wrote:Modding book chapter: https://rubenwardy.com/minetest_modding ... orage.html
Code: Select all
set_foo("desiredkey", "desiredstring")
Who is online
Users browsing this forum: No registered users and 5 guests