Map editing no longer needs mod trust
This commit is contained in:
parent
5d10163f56
commit
28ac474cc2
@ -9,13 +9,12 @@ The tutorial castle is saved in the game itself in schematics and other binary m
|
||||
### Summary
|
||||
|
||||
1. If Luanti is running, shut it down
|
||||
2. Trust the code. In the settings menu or `minetest.conf`, add `tutorial_mapgen` to `secure.trusted_mods`
|
||||
3. In `minetest.conf`, add `tutorial_debug_map_editing = true`
|
||||
4. In `minetest.conf`, add `tutorial_debug_edit_item_spawners = true`
|
||||
5. Start Luanti and create a new world and enter the world in singleplayer (there should be a confirmation message in chat)
|
||||
6. Edit the map to your likings
|
||||
7. Grant yourselves the `tutorialmap` privilege
|
||||
8. Use `/tsave` command to save the map
|
||||
2. In `minetest.conf`, add `tutorial_debug_map_editing = true`
|
||||
3. In `minetest.conf`, add `tutorial_debug_edit_item_spawners = true`
|
||||
4. Start Luanti and create a new world and enter the world in singleplayer (there should be a confirmation message in chat)
|
||||
5. Edit the map to your likings
|
||||
6. Grant yourselves the `tutorialmap` privilege
|
||||
7. Use `/tsave` command to save the map
|
||||
|
||||
Note: `tutorial_debug_map_editing=true` will automatically enable Creative Mode.
|
||||
|
||||
@ -23,12 +22,6 @@ The changes will end up in `<world directory>/mapdata`. Copy this directory to `
|
||||
|
||||
If you want to edit item spawn positions, see the details below.
|
||||
|
||||
### Mod security
|
||||
First, you need to list `tutorial_mapgen` as a trusted mod because the `/tsave` command needs write access.
|
||||
You can review the relevant code in `mods/tutorial_mapgen/init.lua`.
|
||||
|
||||
Use the setting `secure.trusted_mods` to edit the list of trusted mods.
|
||||
|
||||
### Editing the map
|
||||
You want to only edit the map data files. Here's how:
|
||||
|
||||
@ -57,5 +50,3 @@ If you mess with item spawners, the setting `tutorial_debug_edit_item_spawners`
|
||||
|
||||
### Testing and finalizing
|
||||
To test your new map, remove the 2 `minetest.conf` settings and create a new world and check if everything works. If it does work, you can commit your changes now.
|
||||
|
||||
(Note: The `/tsave` command is not available if the `tutorial_mapgen` mod failed to request an "insecure" environment due to mod security issues.)
|
||||
|
@ -5,7 +5,6 @@
|
||||
-- the raw castle, no grass layer or other random decorations will be generated.
|
||||
-- Also, 2 commands to manage the schematic will be available:
|
||||
-- /treset and /tsave commands will be available.
|
||||
-- (/tsave only if tutorial is trusted mod)
|
||||
local map_editing = minetest.settings:get_bool("tutorial_debug_map_editing")
|
||||
|
||||
-- == END OF DEBUG SETTINGS ==
|
||||
@ -18,8 +17,6 @@ local c_grass = minetest.get_content_id("tutorial_default:grass_5")
|
||||
tutorial.map_directory = minetest.get_modpath("tutorial_mapgen").."/mapdata/"
|
||||
tutorial.map_save_directory = minetest.get_worldpath().."/mapdata/"
|
||||
|
||||
local insecure_environment = minetest.request_insecure_environment()
|
||||
|
||||
-- entity management functions
|
||||
|
||||
local function init_item_spawners(spawners)
|
||||
@ -146,7 +143,7 @@ local function save_region(minp, maxp, probability_list, filename, slice_prob_li
|
||||
-- Serialize entries
|
||||
result = minetest.serialize(result)
|
||||
|
||||
local file, err = insecure_environment.io.open(filename..".meta", "wb")
|
||||
local file, err = io.open(filename..".meta", "wb")
|
||||
if err ~= nil then
|
||||
error("Couldn't write to \"" .. filename .. "\"")
|
||||
end
|
||||
@ -305,24 +302,17 @@ if map_editing then
|
||||
end,
|
||||
})
|
||||
|
||||
-- Add commands for saving map and entities, but only if tutorial mod is trusted
|
||||
if insecure_environment then
|
||||
minetest.register_chatcommand("tsave", {
|
||||
params = "",
|
||||
description = "Saves the tutorial map",
|
||||
privs = {tutorialmap=true},
|
||||
func = function(name, param)
|
||||
if not save_schematic() then
|
||||
minetest.chat_send_player(name, "An error occurred while saving Tutorial World schematic")
|
||||
end
|
||||
end,
|
||||
})
|
||||
else
|
||||
minetest.log("warning", "Could not create insecure environment! /tsave command is disabled.")
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
minetest.chat_send_player(player:get_player_name(), "Could not create insecure environment! /tsave command is not available.")
|
||||
end)
|
||||
end
|
||||
-- Add commands for saving map and entities
|
||||
minetest.register_chatcommand("tsave", {
|
||||
params = "",
|
||||
description = "Saves the tutorial map",
|
||||
privs = {tutorialmap=true},
|
||||
func = function(name, param)
|
||||
if not save_schematic() then
|
||||
minetest.chat_send_player(name, "An error occurred while saving Tutorial World schematic")
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
------ Map Generation
|
||||
|
Loading…
x
Reference in New Issue
Block a user