Let's have a look at the basics on how to accomplish this, assume this to be in the init.lua:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local base_path = minetest.get_modpath(minetest.get_current_modname())
minetest.register_chatcommand("reload", {
description = "Reloads all we need.",
params = "",
func = function(name, params)
dofile(base_path .. "/dynamic.lua")
return true, "Done"
end
})
And that's the basic framework, now you can run the command "reload" from within Minetest and "dynamic.lua" will be reloaded, you can make changes to "dynamic.lua" and simply reload it without having to exit Minetest.
You could also do that with a mapgen system, for example (note that the code assumes my utils mod to shorten it):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local base_path = minetest.get_modpath(minetest.get_current_modname())
dofile(base_path .. "/mapgen.lua")
-- MapGen object is defined in mapgen.lua.
local mapgen = MapGen.create()
minetest.register_chatcommand("reload", {
description = "Reloads all we need.",
params = "",
func = function(name, params)
-- Reload the file.
dofile(base_path .. "/mapgen.lua")
-- Now we have the "new" MapGen object that we can use.
mapgen = MapGen.create()
return true, "Done"
end
})
minetest.register_on_generated(function(minp, maxp, seed)
local manipulator = MapManipulator:new()
mapgen:run(minp, maxp, manipulator)
manipulator:set_data()
end)
Now you can make changes to the system, type "reload" in Minetest and the next piece of the world is generated the new, reloaded system will be used.