New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Give subgames the ability to disallow specific mapgens #6792
Changes from all commits
7445cc6
692c978
b182872
60eff52
e571411
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,39 @@ | |
--with this program; if not, write to the Free Software Foundation, Inc., | ||
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
local worldname = "" | ||
|
||
local function create_world_formspec(dialogdata) | ||
local mapgens = core.get_mapgen_names() | ||
|
||
local current_seed = core.settings:get("fixed_map_seed") or "" | ||
local current_mg = core.settings:get("mg_name") | ||
local gameid = core.settings:get("menu_last_game") | ||
|
||
local game, gameidx = nil , 0 | ||
if gameid ~= nil then | ||
game, gameidx = gamemgr.find_by_gameid(gameid) | ||
|
||
if gameidx == nil then | ||
gameidx = 0 | ||
end | ||
end | ||
|
||
local gamepath = core.get_game(gameidx).path | ||
local gameconfig = Settings(gamepath.."/game.conf") | ||
|
||
local disallowed_mapgens = (gameconfig:get("disallowed_mapgens") or ""):split() | ||
for key, value in pairs(disallowed_mapgens) do | ||
disallowed_mapgens[key] = value:trim() | ||
end | ||
|
||
if disallowed_mapgens then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Superfluous check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rubenwardy requested it be this way. I know his commented version is a little different, but he asked me to adjust to this, so will see what he says. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't notice this aha, krock is right unfortunately. But doesn't matter too much |
||
for i = #mapgens, 1, -1 do | ||
if table.indexof(disallowed_mapgens, mapgens[i]) > 0 then | ||
table.remove(mapgens, i) | ||
end | ||
end | ||
end | ||
|
||
local mglist = "" | ||
local selindex = 1 | ||
|
@@ -32,23 +60,12 @@ local function create_world_formspec(dialogdata) | |
mglist = mglist .. v .. "," | ||
end | ||
mglist = mglist:sub(1, -2) | ||
|
||
local gameid = core.settings:get("menu_last_game") | ||
|
||
local game, gameidx = nil , 0 | ||
if gameid ~= nil then | ||
game, gameidx = gamemgr.find_by_gameid(gameid) | ||
|
||
if gameidx == nil then | ||
gameidx = 0 | ||
end | ||
end | ||
|
||
current_seed = core.formspec_escape(current_seed) | ||
local retval = | ||
"size[11.5,6.5,true]" .. | ||
"label[2,0;" .. fgettext("World name") .. "]".. | ||
"field[4.5,0.4;6,0.5;te_world_name;;]" .. | ||
"field[4.5,0.4;6,0.5;te_world_name;;" .. minetest.formspec_escape(worldname) .. "]" .. | ||
|
||
"label[2,1;" .. fgettext("Seed") .. "]".. | ||
"field[4.5,1.4;6,0.5;te_seed;;".. current_seed .. "]" .. | ||
|
@@ -121,10 +138,14 @@ local function create_world_buttonhandler(this, fields) | |
return true | ||
end | ||
|
||
worldname = fields.te_world_name | ||
|
||
if fields["games"] then | ||
local gameindex = core.get_textlist_index("games") | ||
core.settings:set("menu_last_game", gamemgr.games[gameindex].id) | ||
return true | ||
end | ||
|
||
if fields["world_create_cancel"] then | ||
this:delete() | ||
return true | ||
|
@@ -135,6 +156,7 @@ end | |
|
||
|
||
function create_create_world_dlg(update_worldlistfilter) | ||
worldname = "" | ||
local retval = dialog_create("sp_create_world", | ||
create_world_formspec, | ||
create_world_buttonhandler, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, was this a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup.