Move mapgen 2 tutorial_mapgen 2 fix mapedit probs
This commit is contained in:
parent
bceef1d364
commit
bec4d5bca6
@ -3,12 +3,30 @@ Here is some useful info for developers.
|
|||||||
### How the map is saved
|
### How the map is saved
|
||||||
The map is not stored in a traditional way, like in real Minetest world. Instead, the tutorial generates the world on-the-fly when the player creates a new world.
|
The map is not stored in a traditional way, like in real Minetest world. Instead, the tutorial generates the world on-the-fly when the player creates a new world.
|
||||||
|
|
||||||
The tutorial castle is saved in the game itself in schematics and other binary metadata files in `mods/tutorial/mapdata`. When you start a new world, Tutorial force-sets the mapgen to `singlenode`, loads the schematics and places them. After that, it generates the grassland surroundings.
|
The tutorial castle is saved in the game itself in schematics and other binary metadata files in `mods/tutorial_mapgen/mapdata`. When you start a new world, Tutorial force-sets the mapgen to `singlenode`, loads the schematics and places them. After that, it generates the grassland surroundings.
|
||||||
|
|
||||||
## How to edit the map
|
## How to edit the map
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
1. Trust the code. In the settings menu or `minetest.conf`, add `tutorial_mapgen` to `secure.trusted_mods`
|
||||||
|
2. In `minetest.conf`, add `tutorial_debug_map_editing = true`
|
||||||
|
3. In `minetest.conf`, add `tutorial_debug_edit_item_spawners = true`
|
||||||
|
4. If Minetest is running, restart it
|
||||||
|
5. Create a new world, enable Creative Mode and enter it in singleplayer
|
||||||
|
6. Edit the map to your likings
|
||||||
|
7. Grant yourselves the `tutorialmap` privilege
|
||||||
|
8. Use `/tsave` command to save the map
|
||||||
|
9. Test your world: Disable the two settings from steps 2 and 3, create a new world and test it
|
||||||
|
|
||||||
|
The changes will end up in `mods/tutorial_mapgen/mapdata`. If everything worked, you can now commit the changes, use them in a patch or whatever.
|
||||||
|
|
||||||
|
If you want to edit item spawn positions, see the details below.
|
||||||
|
|
||||||
### Mod security
|
### Mod security
|
||||||
First, you need to list `tutorial` as a trusted mod because the `/tsave` command needs write access.
|
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.lua`.
|
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
|
### Editing the map
|
||||||
You want to only edit the map data files. Here's how:
|
You want to only edit the map data files. Here's how:
|
||||||
@ -23,7 +41,7 @@ tutorial_debug_edit_item_spawners = true
|
|||||||
This enables the `/treset` and `/tsave` commands to help editing the schematic. It also forces the Tutorial to only generate the raw castle, not the grasslands. Also, the item spawners become visible.
|
This enables the `/treset` and `/tsave` commands to help editing the schematic. It also forces the Tutorial to only generate the raw castle, not the grasslands. Also, the item spawners become visible.
|
||||||
|
|
||||||
Create a new world in Creative Mode. Now edit the map to your likings using your instant digging power and the creative inventory. You can of course WorldEdit to speed up the process.
|
Create a new world in Creative Mode. Now edit the map to your likings using your instant digging power and the creative inventory. You can of course WorldEdit to speed up the process.
|
||||||
If you're finished, use the `/tsave` command. This updates the map files in `mods/tutorial/mapdata`. Note that there are limits as for how big the tutorial castle can be.
|
If you're finished, grant yourself the `tutorialmap` privilege and use the `/tsave` command. This updates the map files in `mods/tutorial_mapgen/mapdata`. Note that there are limits as for how big the tutorial castle can be.
|
||||||
|
|
||||||
### About item spawners
|
### About item spawners
|
||||||
To place items in the map, you must use the item spawners, these are simple nodes that spawn items. They have 2 states: active and inactive.
|
To place items in the map, you must use the item spawners, these are simple nodes that spawn items. They have 2 states: active and inactive.
|
||||||
@ -37,4 +55,4 @@ If you mess with item spawners, the setting `tutorial_debug_edit_item_spawners`
|
|||||||
### Testing and finalizing
|
### 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.
|
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` mod failed to request an "insecure" environment due to mod security issues.)
|
(Note: The `/tsave` command is not available if the `tutorial_mapgen` mod failed to request an "insecure" environment due to mod security issues.)
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
default
|
default
|
||||||
areas
|
|
||||||
intllib?
|
intllib?
|
||||||
|
@ -4,6 +4,9 @@ tutorial = {}
|
|||||||
-- If true, item spawner nodes become visible and pointable.
|
-- If true, item spawner nodes become visible and pointable.
|
||||||
local edit_item_spawners = minetest.settings:get_bool("tutorial_debug_edit_item_spawners")
|
local edit_item_spawners = minetest.settings:get_bool("tutorial_debug_edit_item_spawners")
|
||||||
|
|
||||||
|
-- See tutorial_mapgen/init.lua
|
||||||
|
local map_editing = minetest.settings:get_bool("tutorial_debug_map_editing")
|
||||||
|
|
||||||
-- == END OF DEBUG SETTINGS ==
|
-- == END OF DEBUG SETTINGS ==
|
||||||
|
|
||||||
-- intllib support
|
-- intllib support
|
||||||
@ -1349,7 +1352,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
"]"..
|
"]"..
|
||||||
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
|
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
|
||||||
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
|
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
|
||||||
elseif(minetest.settings:get_bool("creative_mode")) then
|
elseif(not map_editing and minetest.settings:get_bool("creative_mode")) then
|
||||||
formspec = "size[12,6]"..
|
formspec = "size[12,6]"..
|
||||||
"label[-0.15,-0.4;"..(minetest.formspec_escape(S("Warning: Creative mode is active"))).."]"..
|
"label[-0.15,-0.4;"..(minetest.formspec_escape(S("Warning: Creative mode is active"))).."]"..
|
||||||
"tablecolumns[text]"..
|
"tablecolumns[text]"..
|
||||||
@ -1360,7 +1363,7 @@ minetest.register_on_joinplayer(function(player)
|
|||||||
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
|
"button_exit[2.5,5.5;3,1;close;"..minetest.formspec_escape(S("Continue anyways")).."]"..
|
||||||
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
|
"button_exit[6.5,5.5;3,1;leave;"..minetest.formspec_escape(S("Leave tutorial")).."]"
|
||||||
|
|
||||||
elseif(tutorial.state.intro_text == false) then
|
elseif(not map_editing and tutorial.state.intro_text == false) then
|
||||||
formspec = "size[12,6]"..
|
formspec = "size[12,6]"..
|
||||||
"label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]"..
|
"label[-0.15,-0.4;"..minetest.formspec_escape(S("Introduction")).."]"..
|
||||||
"tablecolumns[text]"..
|
"tablecolumns[text]"..
|
||||||
@ -1564,5 +1567,3 @@ function tutorial.extract_texts()
|
|||||||
io.close(file)
|
io.close(file)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load map generation and map data management functions
|
|
||||||
dofile(minetest.get_modpath("tutorial").."/mapgen.lua")
|
|
||||||
|
2
mods/tutorial_mapgen/depends.txt
Normal file
2
mods/tutorial_mapgen/depends.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
tutorial
|
||||||
|
areas
|
@ -15,9 +15,11 @@ local c_dirt_with_grass = minetest.get_content_id("default:dirt_with_grass")
|
|||||||
local c_grass = minetest.get_content_id("default:grass_5")
|
local c_grass = minetest.get_content_id("default:grass_5")
|
||||||
|
|
||||||
-- Directory where the map data will be stored
|
-- Directory where the map data will be stored
|
||||||
tutorial.map_directory = minetest.get_modpath("tutorial").."/mapdata/"
|
tutorial.map_directory = minetest.get_modpath("tutorial_mapgen").."/mapdata/"
|
||||||
|
|
||||||
local insecure_environment = minetest.request_insecure_environment()
|
local insecure_environment = minetest.request_insecure_environment()
|
||||||
|
minetest.log("error", tostring(insecure_environment ~= nil))
|
||||||
|
minetest.log("error", tostring(map_editing ~= nil))
|
||||||
|
|
||||||
-- entity management functions
|
-- entity management functions
|
||||||
|
|
||||||
@ -28,7 +30,7 @@ local function init_item_spawners(spawners)
|
|||||||
timer:start(3)
|
timer:start(3)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
minetest.log("action", "[tutorial] " .. count .. " item spawners initialized")
|
minetest.log("action", "[tutorial_mapgen] " .. count .. " item spawners initialized")
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -84,7 +86,7 @@ local function save_region(minp, maxp, probability_list, filename, slice_prob_li
|
|||||||
|
|
||||||
local success = minetest.create_schematic(minp, maxp, probability_list, filename .. ".mts", slice_prob_list)
|
local success = minetest.create_schematic(minp, maxp, probability_list, filename .. ".mts", slice_prob_list)
|
||||||
if not success then
|
if not success then
|
||||||
minetest.log("error", "[tutorial] problem creating schematic on ".. minetest.pos_to_string(minp) .. ": " .. filename)
|
minetest.log("error", "[tutorial_mapgen] problem creating schematic on ".. minetest.pos_to_string(minp) .. ": " .. filename)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -152,9 +154,9 @@ local function save_region(minp, maxp, probability_list, filename, slice_prob_li
|
|||||||
file:write(minetest.compress(result))
|
file:write(minetest.compress(result))
|
||||||
file:flush()
|
file:flush()
|
||||||
file:close()
|
file:close()
|
||||||
minetest.log("action", "[tutorial] schematic + metadata saved: " .. filename)
|
minetest.log("action", "[tutorial_mapgen] schematic + metadata saved: " .. filename)
|
||||||
else
|
else
|
||||||
minetest.log("action", "[tutorial] schematic (no metadata) saved: " .. filename)
|
minetest.log("action", "[tutorial_mapgen] schematic (no metadata) saved: " .. filename)
|
||||||
end
|
end
|
||||||
return success, count
|
return success, count
|
||||||
end
|
end
|
||||||
@ -184,9 +186,9 @@ local function load_region(minp, filename, vmanip, rotation, replacements, force
|
|||||||
end
|
end
|
||||||
|
|
||||||
if success == false then
|
if success == false then
|
||||||
minetest.log("action", "[tutorial] schematic partionally loaded on ".. minetest.pos_to_string(minp))
|
minetest.log("action", "[tutorial_mapgen] schematic partionally loaded on ".. minetest.pos_to_string(minp))
|
||||||
elseif not success then
|
elseif not success then
|
||||||
minetest.log("error", "[tutorial] problem placing schematic on ".. minetest.pos_to_string(minp) .. ": " .. filename)
|
minetest.log("error", "[tutorial_mapgen] problem placing schematic on ".. minetest.pos_to_string(minp) .. ": " .. filename)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -224,11 +226,11 @@ local function load_region(minp, filename, vmanip, rotation, replacements, force
|
|||||||
if entry.meta then get_meta(entry):from_table(entry.meta) end
|
if entry.meta then get_meta(entry):from_table(entry.meta) end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.log("error", "[tutorial] unsupported rotation angle: " .. (rotation or "nil"))
|
minetest.log("error", "[tutorial_mapgen] unsupported rotation angle: " .. (rotation or "nil"))
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.log("action", "[tutorial] schematic + metadata loaded on ".. minetest.pos_to_string(minp))
|
minetest.log("action", "[tutorial_mapgen] schematic + metadata loaded on ".. minetest.pos_to_string(minp))
|
||||||
return true, spawners
|
return true, spawners
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -243,7 +245,7 @@ local function save_schematic()
|
|||||||
z = sector.z + sector.l
|
z = sector.z + sector.l
|
||||||
}
|
}
|
||||||
if not save_region(minp, maxp, nil, filename) then
|
if not save_region(minp, maxp, nil, filename) then
|
||||||
minetest.log("error", "[tutorial] error loading Tutorial World sector " .. minetest.pos_to_string(sector))
|
minetest.log("error", "[tutorial_mapgen] error loading Tutorial World sector " .. minetest.pos_to_string(sector))
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -263,7 +265,7 @@ local function load_schematic()
|
|||||||
|
|
||||||
local vmanip = VoxelManip(sector, sector.maxp)
|
local vmanip = VoxelManip(sector, sector.maxp)
|
||||||
if not load_region(sector, filename, vmanip, nil, nil, true) then
|
if not load_region(sector, filename, vmanip, nil, nil, true) then
|
||||||
minetest.log("error", "[tutorial] error loading Tutorial World sector " .. minetest.pos_to_string(sector))
|
minetest.log("error", "[tutorial_mapgen] error loading Tutorial World sector " .. minetest.pos_to_string(sector))
|
||||||
success = false
|
success = false
|
||||||
end
|
end
|
||||||
vmanip:calc_lighting()
|
vmanip:calc_lighting()
|
||||||
@ -277,6 +279,11 @@ end
|
|||||||
------ Commands
|
------ Commands
|
||||||
|
|
||||||
if map_editing then
|
if map_editing then
|
||||||
|
minetest.log("action", "Map editing mode is enabled.")
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
minetest.chat_send_player(player:get_player_name(), "Map editing mode is enabled.")
|
||||||
|
end)
|
||||||
|
|
||||||
minetest.register_privilege("tutorialmap", "Can use commands to manage the tutorial map")
|
minetest.register_privilege("tutorialmap", "Can use commands to manage the tutorial map")
|
||||||
minetest.register_chatcommand("treset", {
|
minetest.register_chatcommand("treset", {
|
||||||
params = "",
|
params = "",
|
||||||
@ -307,6 +314,11 @@ if map_editing then
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user