master
4aiman 2015-05-25 23:44:45 +03:00
parent c7b69b0483
commit bf42107a0f
25 changed files with 604 additions and 3454 deletions

View File

@ -309,7 +309,7 @@ core.register_chatcommand("teleport", {
teleportee:setpos(p)
return true, "Teleporting to "..core.pos_to_string(p)
end
local teleportee = nil
local p = nil
local target_name = nil
@ -346,7 +346,7 @@ core.register_chatcommand("teleport", {
return true, "Teleporting " .. teleportee_name
.. " to " .. core.pos_to_string(p)
end
local teleportee = nil
local p = nil
local teleportee_name = nil
@ -368,7 +368,7 @@ core.register_chatcommand("teleport", {
.. " to " .. target_name
.. " at " .. core.pos_to_string(p)
end
return false, 'Invalid parameters ("' .. param
.. '") or player not found (see /help teleport)'
end,
@ -509,7 +509,6 @@ core.register_chatcommand("giveme", {
if not itemstring then
return false, "ItemString required"
end
core.stat_add("giveme", name)
return handle_give_command("/giveme", name, name, itemstring)
end,
})
@ -783,7 +782,6 @@ core.register_chatcommand("die", {
return
end
player:set_hp(0)
core.stat_add("suicide", name)
end,
})

View File

@ -36,7 +36,7 @@ elseif INIT == "mainmenu" then
if mainmenuscript ~= nil and mainmenuscript ~= "" then
dofile(mainmenuscript)
else
dofile(core.get_mainmenu_path()..DIR_DELIM.."fm_init.lua")
dofile(core.get_mainmenu_path()..DIR_DELIM.."init.lua")
end
elseif INIT == "async" then
dofile(asyncpath.."init.lua")

View File

@ -35,8 +35,8 @@ local function add_server_formspec(dialogdata)
"field[6.5,6.4;6,0.5;desc;;Added on ".. os.date() .."]" ..
"image_button[8,9.54;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;server_add_confirm;".. fgettext("Add") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;server_add_cancel;".. fgettext("Cancel") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[8,9.54;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;server_add_confirm;".. fgettext("Add") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;server_add_cancel;".. fgettext("Cancel") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
return retval
end
@ -64,7 +64,7 @@ local function add_server_buttonhandler(this, fields)
--gamedata.errormessage = fgettext("Can't find serverlist_file! ("..path..')')
end
if favourites then
favourites = minetest.parse_json(favourites)
favourites = core.parse_json(favourites)
else
favourites = {["list"]={},}
end
@ -79,7 +79,7 @@ local function add_server_buttonhandler(this, fields)
}
)
favourites = minetest.write_json(favourites)
favourites = core.write_json(favourites)
--print(path)
local output = io.open(path, "w")

View File

@ -52,8 +52,8 @@ local function get_formspec(data)
"label[8,3;" .. fgettext("Depends:") .. "]" ..
"textlist[8,3.5;7,4.0;world_config_depends;" ..
modmgr.get_dependencies(mod.path) .. ";0]" ..
"image_button[8,9.55;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_config_world_save;" .. fgettext("Save") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_config_world_cancel;".. fgettext("Cancel") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[8,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_config_world_save;" .. fgettext("Save") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_config_world_cancel;".. fgettext("Cancel") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
if mod ~= nil and mod.name ~= "" and mod.typ ~= "game_mod" then
if mod.is_modpack then
@ -69,9 +69,9 @@ local function get_formspec(data)
end
if all_enabled == false then
retval = retval .. "image_button[8,7.55;3.5,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_enable;" .. fgettext("Enable MP") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[8,7.55;3.5,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_enable;" .. fgettext("Enable MP") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
else
retval = retval .. "image_button[8,7.85;3.5,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_disable;" .. fgettext("Disable MP") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[8,7.85;3.5,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_disable;" .. fgettext("Disable MP") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
end
else
if mod.enabled then
@ -83,7 +83,7 @@ local function get_formspec(data)
end
retval = retval ..
"image_button[11.75,7.55;3.5,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_all_mods;" .. fgettext("Enable all") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[11.75,7.55;3.5,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_all_mods;" .. fgettext("Enable all") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"textlist[1,3.5;6,4.0;world_config_modlist;"
--"textlist[5.5,0.5;5.5,5.75;world_config_modlist;"

View File

@ -51,22 +51,22 @@ local function create_world_formspec(dialogdata)
"box[-100,8.5;200,10;#999999]" ..
"box[-100,-10;200,12;#999999]" ..
"label[4,3;" .. fgettext("World name") .. "]"..
"field[6.5,3.4;6,0.5;te_world_name;;]" ..
"label[4,4;" .. fgettext("World name") .. "]"..
"field[6.5,4.4;6,0.5;te_world_name;;]" ..
"label[4,4;" .. fgettext("Seed") .. "]"..
"field[6.5,4.4;6,0.5;te_seed;;".. current_seed .. "]" ..
"label[4,5;" .. fgettext("Seed") .. "]"..
"field[6.5,5.4;6,0.5;te_seed;;".. current_seed .. "]" ..
"label[4,5;" .. fgettext("Mapgen") .. "]"..
"dropdown[6.2,5;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
-- "label[4,5;" .. fgettext("Mapgen") .. "]"..
-- "dropdown[6.2,5;6.3;dd_mapgen;" .. mglist .. ";" .. selindex .. "]" ..
"label[4,6;" .. fgettext("Game") .. "]"..
"dropdown[6.2,6;6.3;games;" .. gamemgr.gamelist() ..
";" .. gameidx .. "]" ..
-- "label[4,6;" .. fgettext("Game") .. "]"..
"dropdown[6000.2,6;6.3;games;" .. gamemgr.gamelist() ..
";1]" ..
"image_button[8,9.55;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create_confirm;".. fgettext("Create") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create_cancel;".. fgettext("Cancel") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[8,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create_confirm;".. fgettext("Create") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create_cancel;".. fgettext("Cancel") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
if #gamemgr.games == 0 then
retval = retval .. "box[4,7;8,1;#ff8800]label[4.25,7;" ..
@ -105,7 +105,7 @@ local function create_world_buttonhandler(this, fields)
local message = nil
if not menudata.worldlist:uid_exists_raw(worldname) then
core.setting_set("mg_name",fields["dd_mapgen"])
core.setting_set("mg_name","v6")
message = core.create_world(worldname,gameindex)
else
message = fgettext("A world named \"$1\" already exists", worldname)

View File

@ -28,8 +28,8 @@ local function delete_mod_formspec(dialogdata)
"box[-100,-10;200,12;#999999]" ..
"label[6.5,4.5;" ..
fgettext("Are you sure you want to delete \"$1\"?", dialogdata.mod.name) .. ";]"..
"image_button[4,5.7;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_delete_mod_confirm;" .. fgettext("Yes").. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[8,5.7;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_delete_mod_cancel;" .. fgettext("No") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[4,5.7;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_delete_mod_confirm;" .. fgettext("Yes").. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[8,5.7;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_delete_mod_cancel;" .. fgettext("No") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
return retval
end

View File

@ -25,8 +25,8 @@ local function delete_world_formspec(dialogdata)
"box[-100,-10;200,12;#999999]" ..
"label[6.5,4.5;" ..
fgettext("Delete World \"$1\"?", dialogdata.delete_name) .. "]"..
"image_button[4,5.7;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete_confirm;" .. fgettext("Yes").. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[8,5.7;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete_cancel;" .. fgettext("No") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[4,5.7;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete_confirm;" .. fgettext("Yes").. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[8,5.7;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete_cancel;" .. fgettext("No") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
return retval
end

View File

@ -27,10 +27,10 @@ local function rename_modpack_formspec(dialogdata)
"field[4.5,1.4;6,0.5;te_modpack_name;;" ..
dialogdata.mod.name ..
"]" ..
"image_button[5,4.2;2.6,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_rename_modpack_confirm;"..
fgettext("Accept") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.5,4.2;2.8,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_rename_modpack_cancel;"..
fgettext("Cancel") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[5,4.2;2.6,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_rename_modpack_confirm;"..
fgettext("Accept") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.5,4.2;2.8,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_rename_modpack_cancel;"..
fgettext("Cancel") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
return retval
end

View File

@ -1,321 +0,0 @@
--Minetest
--Copyright (C) 2013 sapier
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
gamemgr = {}
--------------------------------------------------------------------------------
function gamemgr.dialog_new_game()
local retval =
"label[2,2;" .. fgettext("Game Name") .. "]"..
"field[4.5,2.4;6,0.5;te_game_name;;]" ..
"button[5,4.2;2.6,0.5;new_game_confirm;" .. fgettext("Create") .. "]" ..
"button[7.5,4.2;2.8,0.5;new_game_cancel;" .. fgettext("Cancel") .. "]"
return retval
end
--------------------------------------------------------------------------------
function gamemgr.handle_games_buttons(fields)
if fields["gamelist"] ~= nil then
local event = core.explode_textlist_event(fields["gamelist"])
gamemgr.selected_game = event.index
end
if fields["btn_game_mgr_edit_game"] ~= nil then
return {
is_dialog = true,
show_buttons = false,
current_tab = "dialog_edit_game"
}
end
if fields["btn_game_mgr_new_game"] ~= nil then
return {
is_dialog = true,
show_buttons = false,
current_tab = "dialog_new_game"
}
end
return nil
end
--------------------------------------------------------------------------------
function gamemgr.handle_new_game_buttons(fields)
if fields["new_game_confirm"] and
fields["te_game_name"] ~= nil and
fields["te_game_name"] ~= "" then
local gamepath = core.get_gamepath()
if gamepath ~= nil and
gamepath ~= "" then
local gamefolder = cleanup_path(fields["te_game_name"])
--TODO check for already existing first
core.create_dir(gamepath .. DIR_DELIM .. gamefolder)
core.create_dir(gamepath .. DIR_DELIM .. gamefolder .. DIR_DELIM .. "mods")
core.create_dir(gamepath .. DIR_DELIM .. gamefolder .. DIR_DELIM .. "menu")
local gameconf =
io.open(gamepath .. DIR_DELIM .. gamefolder .. DIR_DELIM .. "game.conf","w")
if gameconf then
gameconf:write("name = " .. fields["te_game_name"])
gameconf:close()
end
end
end
return {
is_dialog = false,
show_buttons = true,
current_tab = core.setting_get("main_menu_tab")
}
end
--------------------------------------------------------------------------------
function gamemgr.handle_edit_game_buttons(fields)
local current_game = gamemgr.get_game(gamemgr.selected_game)
if fields["btn_close_edit_game"] ~= nil or
current_game == nil then
return {
is_dialog = false,
show_buttons = true,
current_tab = core.setting_get("main_menu_tab")
}
end
if fields["btn_remove_mod_from_game"] ~= nil then
gamemgr.delete_mod(current_game,core.get_textlist_index("mods_current"))
end
if fields["btn_add_mod_to_game"] ~= nil then
local modindex = core.get_textlist_index("mods_available")
local mod = modmgr.get_global_mod(modindex)
if mod ~= nil then
local sourcepath = mod.path
if not gamemgr.add_mod(current_game,sourcepath) then
gamedata.errormessage =
fgettext("Gamemgr: Unable to copy mod \"$1\" to game \"$2\"", mod.name, current_game.id)
end
end
end
return nil
end
--------------------------------------------------------------------------------
function gamemgr.add_mod(gamespec,sourcepath)
if gamespec.gamemods_path ~= nil and
gamespec.gamemods_path ~= "" then
local modname = get_last_folder(sourcepath)
return core.copy_dir(sourcepath,gamespec.gamemods_path .. DIR_DELIM .. modname);
end
return false
end
--------------------------------------------------------------------------------
function gamemgr.delete_mod(gamespec,modindex)
if gamespec.gamemods_path ~= nil and
gamespec.gamemods_path ~= "" then
local game_mods = {}
get_mods(gamespec.gamemods_path,game_mods)
if modindex > 0 and
#game_mods >= modindex then
if game_mods[modindex].path:sub(0,gamespec.gamemods_path:len())
== gamespec.gamemods_path then
core.delete_dir(game_mods[modindex].path)
end
end
end
end
--------------------------------------------------------------------------------
function gamemgr.find_by_gameid(gameid)
for i=1,#gamemgr.games,1 do
if gamemgr.games[i].id == gameid then
return gamemgr.games[i], i
end
end
return nil, nil
end
--------------------------------------------------------------------------------
function gamemgr.get_game_mods(gamespec, retval)
if gamespec ~= nil and
gamespec.gamemods_path ~= nil and
gamespec.gamemods_path ~= "" then
get_mods(gamespec.gamemods_path, retval)
end
end
--------------------------------------------------------------------------------
function gamemgr.get_game_modlist(gamespec)
local retval = ""
local game_mods = {}
gamemgr.get_game_mods(gamespec, game_mods)
for i=1,#game_mods,1 do
if retval ~= "" then
retval = retval..","
end
retval = retval .. game_mods[i].name
end
return retval
end
--------------------------------------------------------------------------------
function gamemgr.gettab(name)
local retval = ""
if name == "dialog_edit_game" then
retval = retval .. gamemgr.dialog_edit_game()
end
if name == "dialog_new_game" then
retval = retval .. gamemgr.dialog_new_game()
end
if name == "game_mgr" then
retval = retval .. gamemgr.tab()
end
return retval
end
--------------------------------------------------------------------------------
function gamemgr.tab()
if gamemgr.selected_game == nil then
gamemgr.selected_game = 1
end
local retval =
"label[6.5,-0.25;" .. fgettext("Games") .. ":]" ..
"textlist[6.5,0.25;8,4.4;gamelist;" ..
gamemgr.gamelist() ..
";" .. gamemgr.selected_game .. "]"
local current_game = gamemgr.get_game(gamemgr.selected_game)
if current_game ~= nil then
if current_game.menuicon_path ~= nil and
current_game.menuicon_path ~= "" then
retval = retval ..
"image[6.5,5.5;2,2;" ..
core.formspec_escape(current_game.menuicon_path) .. "]"
end
retval = retval ..
"field[9,5.5;6,2;;" .. current_game.name .. ";]"..
"label[6.5,7.2;" .. fgettext("Mods:") .."]" ..
"button[6.5,11.4;3.2,0.2;btn_game_mgr_edit_game;" .. fgettext("edit game") .. "]" ..
"textlist[6.5,7.7;8,3.3;game_mgr_modlist;"
.. gamemgr.get_game_modlist(current_game) ..";0]" ..
"button[6.5,4.9;3.2,0.5;btn_game_mgr_new_game;" .. fgettext("new game") .. "]"
end
return retval
end
--------------------------------------------------------------------------------
function gamemgr.dialog_edit_game()
local current_game = gamemgr.get_game(gamemgr.selected_game)
if current_game ~= nil then
local retval =
"vertlabel[0,-0.25;" .. fgettext("EDIT GAME") .."]" ..
"label[0,-0.25;" .. current_game.name .. "]" ..
"button[11.55,-0.2;0.75,0.5;btn_close_edit_game;x]"
if current_game.menuicon_path ~= nil and
current_game.menuicon_path ~= "" then
retval = retval ..
"image[5.25,0;2,2;" ..
core.formspec_escape(current_game.menuicon_path) .. "]"
end
retval = retval ..
"textlist[0.5,0.5;4.5,4.3;mods_current;"
.. gamemgr.get_game_modlist(current_game) ..";0]"
retval = retval ..
"textlist[7,0.5;4.5,4.3;mods_available;"
.. modmgr.render_modlist() .. ";0]"
retval = retval ..
"button[0.55,4.95;4.7,0.5;btn_remove_mod_from_game;" .. fgettext("Remove selected mod") .."]"
retval = retval ..
"button[7.05,4.95;4.7,0.5;btn_add_mod_to_game;" .. fgettext("<<-- Add mod") .."]"
return retval
end
end
--------------------------------------------------------------------------------
function gamemgr.handle_buttons(tab,fields)
local retval = nil
if tab == "dialog_edit_game" then
retval = gamemgr.handle_edit_game_buttons(fields)
end
if tab == "dialog_new_game" then
retval = gamemgr.handle_new_game_buttons(fields)
end
if tab == "game_mgr" then
retval = gamemgr.handle_games_buttons(fields)
end
return retval
end
--------------------------------------------------------------------------------
function gamemgr.get_game(index)
if index > 0 and index <= #gamemgr.games then
return gamemgr.games[index]
end
return nil
end
--------------------------------------------------------------------------------
function gamemgr.update_gamelist()
gamemgr.games = core.get_games()
end
--------------------------------------------------------------------------------
function gamemgr.gamelist()
local retval = ""
if #gamemgr.games > 0 then
retval = retval .. gamemgr.games[1].name
for i=2,#gamemgr.games,1 do
retval = retval .. "," .. gamemgr.games[i].name
end
end
return retval
end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -66,11 +66,11 @@ end
local function get_formspec2(tabview, name, tabdata)
local retval = ""
retval = retval .. "bgcolor[#00000000;false]"
retval = retval .. "image_button[2.5,3.4;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir) .. "menu_button.png;btn_show_multiplayer;" .. fgettext("Multiplayer") .. ";true;true;" .. minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,4.8;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_options;".. fgettext("Options") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
--retval = retval .. "image_button[8.5,4.8;1,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_help;?;true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,6.2;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_exit;".. fgettext("Exit") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,2.0;7,1;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_singleplayer;".. fgettext("Singleplayer") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,3.4;7,1;"..core.formspec_escape(mm_texture.basetexturedir) .. "menu_button.png;btn_show_multiplayer;" .. fgettext("Multiplayer") .. ";true;true;" .. core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,4.8;7,1;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_options;".. fgettext("Options") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
--retval = retval .. "image_button[8.5,4.8;1,1;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_help;?;true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,6.2;7,1;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_exit;".. fgettext("Exit") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,2.0;7,1;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_singleplayer;".. fgettext("Singleplayer") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
local si = core.get_screen_info()
@ -80,16 +80,16 @@ local function get_formspec2(tabview, name, tabdata)
--print(xdiv..' x '..ydiv..' = '..ratio)
math.randomseed(os.time())
local rnd = 'image['.. 12*ratio ..','.. 1 .. ';6,0.5;'..minetest.formspec_escape(mm_texture.basetexturedir)..'ad_label'..tostring(math.random(1,14))..'.png]'
-- local rnd = 'image['.. 12*ratio ..','.. 1 .. ';6,0.5;'..core.formspec_escape(mm_texture.basetexturedir)..'ad_label'..tostring(math.random(1,14))..'.png]'
return retval .. rnd
return retval --.. rnd
end
--------------------------------------------------------------------------------
local function main_button_handler2(tabview, fields, name, tabdata)
local index = ''
if fields["btn_show_singleplayer"] then index = "server" end
if fields["btn_show_singleplayer"] then index = "singleplayer" end
if fields["btn_show_multiplayer"] then index = "multiplayer" end
if fields["btn_show_options"] then index = "settings" end
--if fields["btn_show_help"] then index = "help" end
@ -126,8 +126,8 @@ local function on_activate2(type,old_tab,new_tab)
mm_texture.clear("header")
mm_texture.clear("footer")
core.set_clouds(false)
core.set_background("background",minetest.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",minetest.formspec_escape(mm_texture.basetexturedir)..'header.png')
core.set_background("background",core.formspec_escape(mm_texture.basetexturedir)..'background.png')
core.set_background("header",core.formspec_escape(mm_texture.basetexturedir)..'header.png')
end

View File

@ -17,34 +17,34 @@
--------------------------------------------------------------------------------
function get_mods(path,retval,modpack)
local mods = core.get_dirlist(path, true)
for i=1, #mods, 1 do
if mods[i]:sub(1,1) ~= "." then
local toadd = {}
local modpackfile = nil
local mods = core.get_dirlist(path, true)
toadd.name = mods[i]
toadd.path = path .. DIR_DELIM .. mods[i] .. DIR_DELIM
if modpack ~= nil and
modpack ~= "" then
toadd.modpack = modpack
else
local filename = path .. DIR_DELIM .. mods[i] .. DIR_DELIM .. "modpack.txt"
local error = nil
modpackfile,error = io.open(filename,"r")
end
for i=1, #mods, 1 do
if mods[i]:sub(1,1) ~= "." then
local toadd = {}
local modpackfile = nil
if modpackfile ~= nil then
modpackfile:close()
toadd.is_modpack = true
table.insert(retval,toadd)
get_mods(path .. DIR_DELIM .. mods[i],retval,mods[i])
else
table.insert(retval,toadd)
end
end
end
toadd.name = mods[i]
toadd.path = path .. DIR_DELIM .. mods[i] .. DIR_DELIM
if modpack ~= nil and
modpack ~= "" then
toadd.modpack = modpack
else
local filename = path .. DIR_DELIM .. mods[i] .. DIR_DELIM .. "modpack.txt"
local error = nil
modpackfile,error = io.open(filename,"r")
end
if modpackfile ~= nil then
modpackfile:close()
toadd.is_modpack = true
table.insert(retval,toadd)
get_mods(path .. DIR_DELIM .. mods[i],retval,mods[i])
else
table.insert(retval,toadd)
end
end
end
end
--modmanager implementation
@ -52,513 +52,513 @@ modmgr = {}
--------------------------------------------------------------------------------
function modmgr.extract(modfile)
if modfile.type == "zip" then
local tempfolder = os.tempfolder()
if modfile.type == "zip" then
local tempfolder = os.tempfolder()
if tempfolder ~= nil and
tempfolder ~= "" then
core.create_dir(tempfolder)
if core.extract_zip(modfile.name,tempfolder) then
return tempfolder
end
end
end
return nil
if tempfolder ~= nil and
tempfolder ~= "" then
core.create_dir(tempfolder)
if core.extract_zip(modfile.name,tempfolder) then
return tempfolder
end
end
end
return nil
end
-------------------------------------------------------------------------------
function modmgr.getbasefolder(temppath)
if temppath == nil then
return {
type = "invalid",
path = ""
}
end
if temppath == nil then
return {
type = "invalid",
path = ""
}
end
local testfile = io.open(temppath .. DIR_DELIM .. "init.lua","r")
if testfile ~= nil then
testfile:close()
return {
type="mod",
path=temppath
}
end
local testfile = io.open(temppath .. DIR_DELIM .. "init.lua","r")
if testfile ~= nil then
testfile:close()
return {
type="mod",
path=temppath
}
end
testfile = io.open(temppath .. DIR_DELIM .. "modpack.txt","r")
if testfile ~= nil then
testfile:close()
return {
type="modpack",
path=temppath
}
end
testfile = io.open(temppath .. DIR_DELIM .. "modpack.txt","r")
if testfile ~= nil then
testfile:close()
return {
type="modpack",
path=temppath
}
end
local subdirs = core.get_dirlist(temppath,true)
local subdirs = core.get_dirlist(temppath,true)
--only single mod or modpack allowed
if #subdirs ~= 1 then
return {
type = "invalid",
path = ""
}
end
--only single mod or modpack allowed
if #subdirs ~= 1 then
return {
type = "invalid",
path = ""
}
end
testfile =
io.open(temppath .. DIR_DELIM .. subdirs[1] ..DIR_DELIM .."init.lua","r")
if testfile ~= nil then
testfile:close()
return {
type="mod",
path= temppath .. DIR_DELIM .. subdirs[1]
}
end
testfile =
io.open(temppath .. DIR_DELIM .. subdirs[1] ..DIR_DELIM .."init.lua","r")
if testfile ~= nil then
testfile:close()
return {
type="mod",
path= temppath .. DIR_DELIM .. subdirs[1]
}
end
testfile =
io.open(temppath .. DIR_DELIM .. subdirs[1] ..DIR_DELIM .."modpack.txt","r")
if testfile ~= nil then
testfile:close()
return {
type="modpack",
path=temppath .. DIR_DELIM .. subdirs[1]
}
end
testfile =
io.open(temppath .. DIR_DELIM .. subdirs[1] ..DIR_DELIM .."modpack.txt","r")
if testfile ~= nil then
testfile:close()
return {
type="modpack",
path=temppath .. DIR_DELIM .. subdirs[1]
}
end
return {
type = "invalid",
path = ""
}
return {
type = "invalid",
path = ""
}
end
--------------------------------------------------------------------------------
function modmgr.isValidModname(modpath)
if modpath:find("-") ~= nil then
return false
end
if modpath:find("-") ~= nil then
return false
end
return true
return true
end
--------------------------------------------------------------------------------
function modmgr.parse_register_line(line)
local pos1 = line:find("\"")
local pos2 = nil
if pos1 ~= nil then
pos2 = line:find("\"",pos1+1)
end
local pos1 = line:find("\"")
local pos2 = nil
if pos1 ~= nil then
pos2 = line:find("\"",pos1+1)
end
if pos1 ~= nil and pos2 ~= nil then
local item = line:sub(pos1+1,pos2-1)
if pos1 ~= nil and pos2 ~= nil then
local item = line:sub(pos1+1,pos2-1)
if item ~= nil and
item ~= "" then
local pos3 = item:find(":")
if item ~= nil and
item ~= "" then
local pos3 = item:find(":")
if pos3 ~= nil then
local retval = item:sub(1,pos3-1)
if retval ~= nil and
retval ~= "" then
return retval
end
end
end
end
return nil
if pos3 ~= nil then
local retval = item:sub(1,pos3-1)
if retval ~= nil and
retval ~= "" then
return retval
end
end
end
end
return nil
end
--------------------------------------------------------------------------------
function modmgr.parse_dofile_line(modpath,line)
local pos1 = line:find("\"")
local pos2 = nil
if pos1 ~= nil then
pos2 = line:find("\"",pos1+1)
end
local pos1 = line:find("\"")
local pos2 = nil
if pos1 ~= nil then
pos2 = line:find("\"",pos1+1)
end
if pos1 ~= nil and pos2 ~= nil then
local filename = line:sub(pos1+1,pos2-1)
if pos1 ~= nil and pos2 ~= nil then
local filename = line:sub(pos1+1,pos2-1)
if filename ~= nil and
filename ~= "" and
filename:find(".lua") then
return modmgr.identify_modname(modpath,filename)
end
end
return nil
if filename ~= nil and
filename ~= "" and
filename:find(".lua") then
return modmgr.identify_modname(modpath,filename)
end
end
return nil
end
--------------------------------------------------------------------------------
function modmgr.identify_modname(modpath,filename)
local testfile = io.open(modpath .. DIR_DELIM .. filename,"r")
if testfile ~= nil then
local line = testfile:read()
local testfile = io.open(modpath .. DIR_DELIM .. filename,"r")
if testfile ~= nil then
local line = testfile:read()
while line~= nil do
local modname = nil
while line~= nil do
local modname = nil
if line:find("minetest.register_tool") then
modname = modmgr.parse_register_line(line)
end
if line:find("core.register_tool") then
modname = modmgr.parse_register_line(line)
end
if line:find("minetest.register_craftitem") then
modname = modmgr.parse_register_line(line)
end
if line:find("core.register_craftitem") then
modname = modmgr.parse_register_line(line)
end
if line:find("minetest.register_node") then
modname = modmgr.parse_register_line(line)
end
if line:find("core.register_node") then
modname = modmgr.parse_register_line(line)
end
if line:find("dofile") then
modname = modmgr.parse_dofile_line(modpath,line)
end
if line:find("dofile") then
modname = modmgr.parse_dofile_line(modpath,line)
end
if modname ~= nil then
testfile:close()
return modname
end
if modname ~= nil then
testfile:close()
return modname
end
line = testfile:read()
end
testfile:close()
end
line = testfile:read()
end
testfile:close()
end
return nil
return nil
end
--------------------------------------------------------------------------------
function modmgr.render_modlist(render_list)
local retval = ""
local retval = ""
if render_list == nil then
if modmgr.global_mods == nil then
modmgr.refresh_globals()
end
render_list = modmgr.global_mods
end
if render_list == nil then
if modmgr.global_mods == nil then
modmgr.refresh_globals()
end
render_list = modmgr.global_mods
end
local list = render_list:get_list()
local last_modpack = nil
local list = render_list:get_list()
local last_modpack = nil
for i,v in ipairs(list) do
if retval ~= "" then
retval = retval ..","
end
for i,v in ipairs(list) do
if retval ~= "" then
retval = retval ..","
end
local color = ""
local color = ""
if v.is_modpack then
local rawlist = render_list:get_raw_list()
if v.is_modpack then
local rawlist = render_list:get_raw_list()
local all_enabled = true
for j=1,#rawlist,1 do
if rawlist[j].modpack == list[i].name and
rawlist[j].enabled ~= true then
all_enabled = false
break
end
end
local all_enabled = true
for j=1,#rawlist,1 do
if rawlist[j].modpack == list[i].name and
rawlist[j].enabled ~= true then
all_enabled = false
break
end
end
if all_enabled == false then
color = mt_color_grey
else
color = mt_color_dark_green
end
end
if all_enabled == false then
color = mt_color_grey
else
color = mt_color_dark_green
end
end
if v.typ == "game_mod" then
color = mt_color_blue
else
if v.enabled then
color = mt_color_green
end
end
if v.typ == "game_mod" then
color = mt_color_blue
else
if v.enabled then
color = mt_color_green
end
end
retval = retval .. color
if v.modpack ~= nil then
retval = retval .. " "
end
retval = retval .. v.name
end
retval = retval .. color
if v.modpack ~= nil then
retval = retval .. " "
end
retval = retval .. v.name
end
return retval
return retval
end
--------------------------------------------------------------------------------
function modmgr.get_dependencies(modfolder)
local toadd = ""
if modfolder ~= nil then
local filename = modfolder ..
DIR_DELIM .. "depends.txt"
local toadd = ""
if modfolder ~= nil then
local filename = modfolder ..
DIR_DELIM .. "depends.txt"
local dependencyfile = io.open(filename,"r")
local dependencyfile = io.open(filename,"r")
if dependencyfile then
local dependency = dependencyfile:read("*l")
while dependency do
if toadd ~= "" then
toadd = toadd .. ","
end
toadd = toadd .. dependency
dependency = dependencyfile:read()
end
dependencyfile:close()
end
end
if dependencyfile then
local dependency = dependencyfile:read("*l")
while dependency do
if toadd ~= "" then
toadd = toadd .. ","
end
toadd = toadd .. dependency
dependency = dependencyfile:read()
end
dependencyfile:close()
end
end
return toadd
return toadd
end
--------------------------------------------------------------------------------
function modmgr.get_worldconfig(worldpath)
local filename = worldpath ..
DIR_DELIM .. "world.mt"
local filename = worldpath ..
DIR_DELIM .. "world.mt"
local worldfile = Settings(filename)
local worldfile = Settings(filename)
local worldconfig = {}
worldconfig.global_mods = {}
worldconfig.game_mods = {}
local worldconfig = {}
worldconfig.global_mods = {}
worldconfig.game_mods = {}
for key,value in pairs(worldfile:to_table()) do
if key == "gameid" then
worldconfig.id = value
else
worldconfig.global_mods[key] = core.is_yes(value)
end
end
for key,value in pairs(worldfile:to_table()) do
if key == "gameid" then
worldconfig.id = value
else
worldconfig.global_mods[key] = core.is_yes(value)
end
end
--read gamemods
local gamespec = gamemgr.find_by_gameid(worldconfig.id)
gamemgr.get_game_mods(gamespec, worldconfig.game_mods)
--read gamemods
local gamespec = gamemgr.find_by_gameid(worldconfig.id)
gamemgr.get_game_mods(gamespec, worldconfig.game_mods)
return worldconfig
return worldconfig
end
--------------------------------------------------------------------------------
function modmgr.installmod(modfilename,basename)
local modfile = modmgr.identify_filetype(modfilename)
local modpath = modmgr.extract(modfile)
local modfile = modmgr.identify_filetype(modfilename)
local modpath = modmgr.extract(modfile)
if modpath == nil then
gamedata.errormessage = fgettext("Install Mod: file: \"$1\"", modfile.name) ..
fgettext("\nInstall Mod: unsupported filetype \"$1\" or broken archive", modfile.type)
return
end
if modpath == nil then
gamedata.errormessage = fgettext("Install Mod: file: \"$1\"", modfile.name) ..
fgettext("\nInstall Mod: unsupported filetype \"$1\" or broken archive", modfile.type)
return
end
local basefolder = modmgr.getbasefolder(modpath)
local basefolder = modmgr.getbasefolder(modpath)
if basefolder.type == "modpack" then
local clean_path = nil
if basefolder.type == "modpack" then
local clean_path = nil
if basename ~= nil then
clean_path = "mp_" .. basename
end
if basename ~= nil then
clean_path = "mp_" .. basename
end
if clean_path == nil then
clean_path = get_last_folder(cleanup_path(basefolder.path))
end
if clean_path == nil then
clean_path = get_last_folder(cleanup_path(basefolder.path))
end
if clean_path ~= nil then
local targetpath = core.get_modpath() .. DIR_DELIM .. clean_path
if not core.copy_dir(basefolder.path,targetpath) then
gamedata.errormessage = fgettext("Failed to install $1 to $2", basename, targetpath)
end
else
gamedata.errormessage = fgettext("Install Mod: unable to find suitable foldername for modpack $1", modfilename)
end
end
if clean_path ~= nil then
local targetpath = core.get_modpath() .. DIR_DELIM .. clean_path
if not core.copy_dir(basefolder.path,targetpath) then
gamedata.errormessage = fgettext("Failed to install $1 to $2", basename, targetpath)
end
else
gamedata.errormessage = fgettext("Install Mod: unable to find suitable foldername for modpack $1", modfilename)
end
end
if basefolder.type == "mod" then
local targetfolder = basename
if basefolder.type == "mod" then
local targetfolder = basename
if targetfolder == nil then
targetfolder = modmgr.identify_modname(basefolder.path,"init.lua")
end
if targetfolder == nil then
targetfolder = modmgr.identify_modname(basefolder.path,"init.lua")
end
--if heuristic failed try to use current foldername
if targetfolder == nil then
targetfolder = get_last_folder(basefolder.path)
end
--if heuristic failed try to use current foldername
if targetfolder == nil then
targetfolder = get_last_folder(basefolder.path)
end
if targetfolder ~= nil and modmgr.isValidModname(targetfolder) then
local targetpath = core.get_modpath() .. DIR_DELIM .. targetfolder
core.copy_dir(basefolder.path,targetpath)
else
gamedata.errormessage = fgettext("Install Mod: unable to find real modname for: $1", modfilename)
end
end
if targetfolder ~= nil and modmgr.isValidModname(targetfolder) then
local targetpath = core.get_modpath() .. DIR_DELIM .. targetfolder
core.copy_dir(basefolder.path,targetpath)
else
gamedata.errormessage = fgettext("Install Mod: unable to find real modname for: $1", modfilename)
end
end
core.delete_dir(modpath)
core.delete_dir(modpath)
modmgr.refresh_globals()
modmgr.refresh_globals()
end
--------------------------------------------------------------------------------
function modmgr.preparemodlist(data)
local retval = {}
local retval = {}
local global_mods = {}
local game_mods = {}
local global_mods = {}
local game_mods = {}
--read global mods
local modpath = core.get_modpath()
--read global mods
local modpath = core.get_modpath()
if modpath ~= nil and
modpath ~= "" then
get_mods(modpath,global_mods)
end
if modpath ~= nil and
modpath ~= "" then
get_mods(modpath,global_mods)
end
for i=1,#global_mods,1 do
global_mods[i].typ = "global_mod"
table.insert(retval,global_mods[i])
end
for i=1,#global_mods,1 do
global_mods[i].typ = "global_mod"
table.insert(retval,global_mods[i])
end
--read game mods
local gamespec = gamemgr.find_by_gameid(data.gameid)
gamemgr.get_game_mods(gamespec, game_mods)
--read game mods
local gamespec = gamemgr.find_by_gameid(data.gameid)
gamemgr.get_game_mods(gamespec, game_mods)
for i=1,#game_mods,1 do
game_mods[i].typ = "game_mod"
table.insert(retval,game_mods[i])
end
for i=1,#game_mods,1 do
game_mods[i].typ = "game_mod"
table.insert(retval,game_mods[i])
end
if data.worldpath == nil then
return retval
end
if data.worldpath == nil then
return retval
end
--read world mod configuration
local filename = data.worldpath ..
DIR_DELIM .. "world.mt"
--read world mod configuration
local filename = data.worldpath ..
DIR_DELIM .. "world.mt"
local worldfile = Settings(filename)
local worldfile = Settings(filename)
for key,value in pairs(worldfile:to_table()) do
if key:sub(1, 9) == "load_mod_" then
key = key:sub(10)
local element = nil
for i=1,#retval,1 do
if retval[i].name == key and
not retval[i].is_modpack then
element = retval[i]
break
end
end
if element ~= nil then
element.enabled = core.is_yes(value)
else
core.log("info", "Mod: " .. key .. " " .. dump(value) .. " but not found")
end
end
end
for key,value in pairs(worldfile:to_table()) do
if key:sub(1, 9) == "load_mod_" then
key = key:sub(10)
local element = nil
for i=1,#retval,1 do
if retval[i].name == key and
not retval[i].is_modpack then
element = retval[i]
break
end
end
if element ~= nil then
element.enabled = core.is_yes(value)
else
core.log("info", "Mod: " .. key .. " " .. dump(value) .. " but not found")
end
end
end
return retval
return retval
end
--------------------------------------------------------------------------------
function modmgr.comparemod(elem1,elem2)
if elem1 == nil or elem2 == nil then
return false
end
if elem1.name ~= elem2.name then
return false
end
if elem1.is_modpack ~= elem2.is_modpack then
return false
end
if elem1.typ ~= elem2.typ then
return false
end
if elem1.modpack ~= elem2.modpack then
return false
end
if elem1 == nil or elem2 == nil then
return false
end
if elem1.name ~= elem2.name then
return false
end
if elem1.is_modpack ~= elem2.is_modpack then
return false
end
if elem1.typ ~= elem2.typ then
return false
end
if elem1.modpack ~= elem2.modpack then
return false
end
if elem1.path ~= elem2.path then
return false
end
if elem1.path ~= elem2.path then
return false
end
return true
return true
end
--------------------------------------------------------------------------------
function modmgr.mod_exists(basename)
if modmgr.global_mods == nil then
modmgr.refresh_globals()
end
if modmgr.global_mods == nil then
modmgr.refresh_globals()
end
if modmgr.global_mods:raw_index_by_uid(basename) > 0 then
return true
end
if modmgr.global_mods:raw_index_by_uid(basename) > 0 then
return true
end
return false
return false
end
--------------------------------------------------------------------------------
function modmgr.get_global_mod(idx)
if modmgr.global_mods == nil then
return nil
end
if modmgr.global_mods == nil then
return nil
end
if idx == nil or idx < 1 or
idx > modmgr.global_mods:size() then
return nil
end
if idx == nil or idx < 1 or
idx > modmgr.global_mods:size() then
return nil
end
return modmgr.global_mods:get_list()[idx]
return modmgr.global_mods:get_list()[idx]
end
--------------------------------------------------------------------------------
function modmgr.refresh_globals()
modmgr.global_mods = filterlist.create(
modmgr.preparemodlist, --refresh
modmgr.comparemod, --compare
function(element,uid) --uid match
if element.name == uid then
return true
end
end,
nil, --filter
{}
)
modmgr.global_mods:add_sort_mechanism("alphabetic", sort_mod_list)
modmgr.global_mods:set_sortmode("alphabetic")
modmgr.global_mods = filterlist.create(
modmgr.preparemodlist, --refresh
modmgr.comparemod, --compare
function(element,uid) --uid match
if element.name == uid then
return true
end
end,
nil, --filter
{}
)
modmgr.global_mods:add_sort_mechanism("alphabetic", sort_mod_list)
modmgr.global_mods:set_sortmode("alphabetic")
end
--------------------------------------------------------------------------------
function modmgr.identify_filetype(name)
if name:sub(-3):lower() == "zip" then
return {
name = name,
type = "zip"
}
end
if name:sub(-3):lower() == "zip" then
return {
name = name,
type = "zip"
}
end
if name:sub(-6):lower() == "tar.gz" or
name:sub(-3):lower() == "tgz"then
return {
name = name,
type = "tgz"
}
end
if name:sub(-6):lower() == "tar.gz" or
name:sub(-3):lower() == "tgz"then
return {
name = name,
type = "tgz"
}
end
if name:sub(-6):lower() == "tar.bz2" then
return {
name = name,
type = "tbz"
}
end
if name:sub(-6):lower() == "tar.bz2" then
return {
name = name,
type = "tbz"
}
end
if name:sub(-2):lower() == "7z" then
return {
name = name,
type = "7z"
}
end
if name:sub(-2):lower() == "7z" then
return {
name = name,
type = "7z"
}
end
return {
name = name,
type = "ukn"
}
return {
name = name,
type = "ukn"
}
end

View File

@ -164,7 +164,7 @@ function modstore.successfulldialog()
retval = retval .. "label[3,0.75;" .. core.formspec_escape(modstore.lastmodentry.moddetails.basename) .. "]"
end
retval = retval .. "image_button[2.5,1.5;1,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_confirm_mod_successfull;" .. fgettext("ok") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[2.5,1.5;1,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_confirm_mod_successfull;" .. fgettext("ok") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
end,
function(this,fields)
if fields["btn_confirm_mod_successfull"] ~= nil then
@ -495,12 +495,12 @@ function modstore.getshortmodinfo(ypos,listentry,details)
if details.basename then
--install button
local buttony = ypos + 1.2
retval = retval .."image_button[9.1," .. buttony .. ";2.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_install_mod_" .. details.id .. ";"
retval = retval .."image_button[9.1," .. buttony .. ";2.5,0.5;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_install_mod_" .. details.id .. ";"
if modmgr.mod_exists(details.basename) then
retval = retval .. fgettext("re-Install") ..";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. fgettext("re-Install") ..";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
else
retval = retval .. fgettext("Install") ..";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. fgettext("Install") ..";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
end
end
@ -519,7 +519,7 @@ function modstore.getmodlist(list,yoffset)
local sb_y_start = 0.2 + yoffset
local sb_y_end = (modstore.modsperpage * 1.75) + ((modstore.modsperpage-1) * 0.15)
local close_button = "image_button[4," .. (sb_y_end + 0.3 + yoffset) ..
";4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_close;" .. fgettext("Close store") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
";4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_close;" .. fgettext("Close store") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
if #list.data == 0 then
return close_button
@ -533,9 +533,9 @@ function modstore.getmodlist(list,yoffset)
((sb_y_end -1.6)/(list.pagecount-1)) * list.page
scrollbar = scrollbar .. "box[11.6," ..scrollbarpos .. ";0.28,0.5;#32CD32]"
scrollbar = scrollbar .. "image_button[11.6," .. (sb_y_start)
.. ";0.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_page_up;^;true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
.. ";0.5,0.5;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_page_up;^;true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
scrollbar = scrollbar .. "image_button[11.6," .. (sb_y_start + sb_y_end - 0.5)
.. ";0.5,0.5;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_page_down;v;true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
.. ";0.5,0.5;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_page_down;v;true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
local retval = ""
@ -581,7 +581,7 @@ function modstore.getsearchpage(tabview, name, tabdata)
end
retval = retval ..
"image_button[9.5,0.2;2.5,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_search;".. fgettext("Search") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[9.5,0.2;2.5,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore_search;".. fgettext("Search") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"field[0.5,0.5;9,0.5;te_modstore_search;;" .. search .. "]"
retval = retval ..

View File

@ -27,7 +27,7 @@ tab_credits = {
"box[-100,8.5;200,10;#999999]" ..
"box[-100,-10;200,12;#999999]" ..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"label[3.5,9.75;Magichet 1.0 (based on FM " .. core.get_version() .. ")]" ..
"image[0.25,9;2,2;"..core.formspec_escape(logofile).."]"..
"textlist[0,2.0;15.8,6.25;list_credits;" ..

View File

@ -1,59 +0,0 @@
--Minetest
--Copyright (C) 2013 sapier
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------------
tab_help = {
name = "help",
caption = fgettext("Help"),
cbf_formspec = function (tabview, name, tabdata)
local logofile = defaulttexturedir .. "logo.png"
return "size[16,11]"..
"bgcolor[#00000070;true]"..
"box[-100,8.5;200,10;#999999]" ..
"box[-100,-10;200,12;#999999]" ..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"label[3.5,9.75;Magichet 1.0 (based on FM " .. core.get_version() .. ")]" ..
"image[0.25,9;2,2;"..core.formspec_escape(logofile).."]"..
"textlist[0,2;15.8,6.25;list_help;" ..
"#FFFF00How to begin to play (ENG)," ..
" - Press and hold to dig a block,"..
" - Doubletap to place a block,"..
" - To split a stack 'long pess' on it and,"..
" w/o releasing it tap a separate inventory cell,"..
","..
","..
"#FFFF00Как начать играть (RUS)," ..
" - Долгое нажатие = сломать блок,"..
" - Двойное нажатие = поставить блок,"..
" - Для разделения стака на части,"..
" нажмите на стак и удерживая его,"..
" нажмите вторым пальцем на свободной,"..
" ячейке интвентаря"..
";0;true]"
end,
cbf_button_handler = function(tabview, fields, name, tabdata)
if fields["btn_cancel"] ~= nil then
tabview:hide()
tabview.parent:show()
return true
end
return false
end
}

View File

@ -36,7 +36,7 @@ local function get_formspec(tabview, name, tabdata)
-- "label[0.8,4.2;" .. fgettext("Add mod:") .. "]" ..
-- TODO Disabled due to upcoming release 0.4.8 and irrlicht messing up localization
-- "button[0.75,4.85;1.8,0.5;btn_mod_mgr_install_local;".. fgettext("Local install") .. "]" ..
"image_button[0,4.85;5.25,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore;".. fgettext("Online mod repository") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[0,4.85;5.25,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_modstore;".. fgettext("Online mod repository") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
local selected_mod = nil
@ -89,10 +89,10 @@ local function get_formspec(tabview, name, tabdata)
if selected_mod.is_modpack then
retval = retval .. ";0]" ..
"image_button[10,4.85;2,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_rename_modpack;" ..
fgettext("Rename") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[5.5,4.85;4.5,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_delete_mod;"
.. fgettext("Uninstall selected modpack") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[10,4.85;2,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_rename_modpack;" ..
fgettext("Rename") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[5.5,4.85;4.5,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_delete_mod;"
.. fgettext("Uninstall selected modpack") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
else
--show dependencies
@ -102,8 +102,8 @@ local function get_formspec(tabview, name, tabdata)
retval = retval .. toadd .. ";0]"
retval = retval .. "image_button[5.5,4.85;4.5,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_delete_mod;"
.. fgettext("Uninstall selected mod") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
retval = retval .. "image_button[5.5,4.85;4.5,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mod_mgr_delete_mod;"
.. fgettext("Uninstall selected mod") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
end
end
return retval

View File

@ -23,7 +23,7 @@ local function get_formspec(tabview, name, tabdata)
"box[-100,-10;200,12;#999999]" ..
"bgcolor[#00000070;true]"..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;cancel;".. fgettext("Cancel") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;cancel;".. fgettext("Cancel") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
--"label[0,1.25;" .. fgettext("Address/Port") .. "]" ..
"field[1000.25,5.25;5.5,0.5;te_address;;" ..
core.formspec_escape(core.setting_get("address")) .. "]" ..
@ -40,15 +40,15 @@ local function get_formspec(tabview, name, tabdata)
--if not core.setting_getbool("public_serverlist") then
if (core.get_table_index("favourites") or 10000) <= #core.get_favorites("local") then
retval = retval ..
"image_button[4,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_delete_favorite;" .. fgettext("Delete") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[4,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_delete_favorite;" .. fgettext("Delete") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
else
retval = retval ..
"image_button[4,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;add_server;" .. fgettext("Add") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[4,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;add_server;" .. fgettext("Add") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
end
retval = retval ..
"image_button[8,9.55;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_connect;" .. fgettext("Connect") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[3.2,9.55;0.8,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."server_flags_favourite.png;btn_mp_favour;;true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[8,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_mp_connect;" .. fgettext("Connect") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[3.2,9.55;0.8,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."server_flags_favourite.png;btn_mp_favour;;true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"label[8,8;" .. fgettext("Name") .. ":]" ..
"field[8.3,9;3.95,0.8;te_name;;" ..
@ -231,7 +231,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
--gamedata.errormessage = err..' ('..errcode..')'
end
if favourites then
favourites = minetest.parse_json(favourites)
favourites = core.parse_json(favourites)
else
favourites = {["list"]={},}
end
@ -245,7 +245,7 @@ local function main_button_handler(tabview, fields, name, tabdata)
}
)
favourites = minetest.write_json(favourites)
favourites = core.write_json(favourites)
local output,err,errcode = io.open(path, "w")
if output then

View File

@ -27,27 +27,31 @@ local function get_formspec(tabview, name, tabdata)
"box[-100,8.5;200,10;#999999]" ..
"box[-100,-10;200,12;#999999]" ..
"bgcolor[#00000070;true]"..
"image_button[4,8.7;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;start_server;".. fgettext("Play") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.8,8.7;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create;".. fgettext("New") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[4,8.7;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;start_server;".. fgettext("Play") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.8,8.7;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create;".. fgettext("New") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[4,9.55;2.68,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete;".. fgettext("Delete") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[6.53,9.55;2.68,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_configure;".. fgettext("Configure") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[9.07,9.55;2.68,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;cancel;".. fgettext("Cancel") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[4,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete;".. fgettext("Delete") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
--"image_button[6.53,9.55;2.68,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_configure;".. fgettext("Configure") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.8,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;cancel;".. fgettext("Cancel") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"label[7,1.5;" .. fgettext("Select World:") .. "]" ..
"checkbox[12,8.70;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" .. dump(core.setting_getbool("creative_mode")) .. "]" ..
--"checkbox[1000,9.20;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" .. dump(core.setting_getbool("enable_damage")) .. "]" ..
"checkbox[12,9.50;cb_server_announce;" .. fgettext("Public") .. ";" .. dump(core.setting_getbool("server_announce")) .. "]" ..
"label[0.2,8.55;" .. fgettext("Name/Password") .. "]" ..
"field[0.5,9.45;3.5,0.5;te_playername;;"
"checkbox[0.2,8.35;btn_single;Local Server;true]"..
"label[-0.25,9.15;Name]" ..
"field[1,9.45;3,0.5;te_playername;;"
local nm = core.formspec_escape(core.setting_get("name"))
if nm=='' then
nm='Wanderer'
nm='Player'
end
retval = retval ..
nm .. "]" ..
"pwdfield[0.5,10.15;3.5,0.5;te_passwd;]"
"label[-0.25,9.8;Pass]" ..
"pwdfield[1,10.15;3,0.5;te_passwd;]"
local bind_addr = core.setting_get("bind_address")
@ -76,6 +80,14 @@ local function main_button_handler(this, fields, name, tabdata)
local world_doubleclick = false
if fields["btn_single"]~=nil then
local single = create_tab_single(true)
single:set_parent(this.parent)
single:show()
this:hide()
return true
end
if fields["srv_worlds"] ~= nil then
local event = core.explode_textlist_event(fields["srv_worlds"])
@ -102,7 +114,7 @@ local function main_button_handler(this, fields, name, tabdata)
bool = 'true'
end
core.setting_set("enable_damage", bool)
print(bool)
-- print(bool)
return true
end
@ -202,3 +214,12 @@ tab_server = {
cbf_button_handler = main_button_handler,
on_change = nil
}
function create_tab_server()
local retval = dialog_create("server",
get_formspec,
main_button_handler,
nil)
return retval
end

View File

@ -73,10 +73,10 @@ local function dlg_confirm_reset_formspec(data)
local retval =
"size[8,3]" ..
"label[1,1;".. fgettext("Are you sure to reset your singleplayer world?") .. "]"..
"image_button[1,2;2.6,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_reset_singleplayer_confirm;"..
fgettext("Yes") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[4,2;2.8,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_reset_singleplayer_cancel;"..
fgettext("No!!!") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[1,2;2.6,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_reset_singleplayer_confirm;"..
fgettext("Yes") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[4,2;2.8,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;dlg_reset_singleplayer_cancel;"..
fgettext("No!!!") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
return retval
end
@ -213,7 +213,7 @@ local function formspec(tabview, name, tabdata)
"dropdown[5.85,5.1;3.85;dd_video_driver;"
.. driver_formspec_string .. ";" .. driver_current_idx .. "]" ..
"tooltip[dd_video_driver;" ..
fgettext("Restart minetest for driver change to take effect") .. "]"
fgettext("Restart multicraft for driver change to take effect") .. "]"
@ -223,29 +223,29 @@ local function formspec(tabview, name, tabdata)
"box[9.75,2.5;5.25,4;#999999]"..
"checkbox[10,2.5;cb_shaders;".. fgettext("Shaders") .. ";"
.. dump(core.setting_getbool("enable_shaders")) .. "]"..
"image_button[0,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_change_keys;".. fgettext("Change keys") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"--..
-- "image_button[3.75,5;3.88,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[0,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_change_keys;".. fgettext("Change keys") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"--..
-- "image_button[3.75,5;3.88,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
else
--tab_string = tab_string ..
-- "image_button[3.75,5;3.88,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
-- "image_button[3.75,5;3.88,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_reset_singleplayer;".. fgettext("Reset singleplayer world") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
end
tab_string = tab_string ..
"image_button[4,9.55;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_textures;".. fgettext("Texturepacks") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir)..
"image_button[4,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_textures;".. fgettext("Texturepacks") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir)..
"menu_button_b.png]"..
"image_button[8,9.55;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_credits;".. fgettext("Credits") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
"image_button[8,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_show_credits;".. fgettext("Credits") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"
if PLATFORM == "Android" then
tab_string = tab_string ..
"box[9.75,2.5;5.25,2.5;#999999]" ..
"checkbox[10,2.75;cb_touchscreen_target;".. fgettext("Touch free target") .. ";" .. dump(core.setting_getbool("touchtarget")) .. "]"..
"box[0.75,6.8;14.25,1.35;#999999]" ..
"label[1.5,6.8;" .. fgettext("GUI scale factor") .. "]"..
"scrollbar[1.0,7.2;13.75,0.7;sb_gui_scaling;horizontal;" .. gui_scale_to_scrollbar() .. "]" ..
"tooltip[sb_gui_scaling;" .. fgettext("Scaling factor applied to menu elements: ") .. dump(core.setting_get("gui_scaling")) .. "]"
""
-- "box[0.75,6.8;14.25,1.35;#999999]" ..
-- "label[1.5,6.8;" .. fgettext("GUI scale factor") .. "]"..
--"scrollbar[1.0,7.2;13.75,0.7;sb_gui_scaling;horizontal;" .. gui_scale_to_scrollbar() .. "]" ..
-- "tooltip[sb_gui_scaling;" .. fgettext("Scaling factor applied to menu elements: ") .. dump(core.setting_get("gui_scaling")) .. "]"
-- if core.setting_get("touchscreen_threshold") ~= nil then
tab_string = tab_string ..
@ -253,12 +253,12 @@ local function formspec(tabview, name, tabdata)
"dropdown[10,4.0;5.18;dd_touchthreshold;0,10,20,30,40,50;" .. ((tonumber(core.setting_get("touchscreen_threshold") or 20)/10)+1) .. "]"
-- end
else
tab_string = tab_string ..
"box[0.75,6.8;14.25,1.35;#999999]" ..
"label[1.5,6.8;" .. fgettext("GUI scale factor") .. "]"..
"scrollbar[1.0,7.5;13.75,0.4;sb_gui_scaling;horizontal;" .. gui_scale_to_scrollbar() .. "]" ..
"tooltip[sb_gui_scaling;" .. fgettext("Scaling factor applied to menu elements: ") .. dump(core.setting_get("gui_scaling")) .. "]"
--else
-- tab_string = tab_string ..
-- "box[0.75,6.8;14.25,1.35;#999999]" ..
-- "label[1.5,6.8;" .. fgettext("GUI scale factor") .. "]"..
-- "scrollbar[1.0,7.5;13.75,0.4;sb_gui_scaling;horizontal;" .. gui_scale_to_scrollbar() .. "]" ..
-- "tooltip[sb_gui_scaling;" .. fgettext("Scaling factor applied to menu elements: ") .. dump(core.setting_get("gui_scaling")) .. "]"
end
if PLATFORM ~= "Android" then

View File

@ -1,69 +0,0 @@
--Minetest
--Copyright (C) 2013 sapier
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------------
--favourites
local function image_column(tooltip, flagname)
return "image," ..
"tooltip=" .. core.formspec_escape(tooltip) .. "," ..
"0=" .. core.formspec_escape(defaulttexturedir .. "blank.png") .. "," ..
"1=" .. core.formspec_escape(defaulttexturedir .. "server_flags_" .. flagname .. ".png")
end
local function get_formspec(tabview, name, tabdata)
local retval = ""
retval = retval .. "bgcolor[#00000000;false]"
retval = retval .. "image_button[2.5,1.0;7,1;multicraftbutton.png;btn_show_singleplayer;".. fgettext("Singleplayer") .. ";true;true;multicraftbutton.png]"
retval = retval .. "image_button[2.5,2.4;7,1;multicraftbutton.png;btn_show_multiplayer;" .. fgettext("Multiplayer") .. ";true;true;multicraftbutton.png]"
retval = retval .. "image_button[2.5,3.8;7,1;multicraftbutton.png;btn_show_options;".. fgettext("Options") .. ";true;true;multicraftbutton.png]"
retval = retval .. "image_button[2.5,5.2;7,1;multicraftbutton.png;btn_exit;".. fgettext("Exit") .. ";true;true;multicraftbutton.png]"
return retval
end
--------------------------------------------------------------------------------
local function main_button_handler(tabview, fields, name, tabdata)
local index = 0
if fields["btn_show_singleplayer"] then index = 1 end
if fields["btn_show_multiplayer"] then index = 2 end
if fields["btn_show_options"] then index = 3 end
if fields["btn_exit"] then core.close() end
--switch_to_tab(self, index)
end
--------------------------------------------------------------------------------
local function on_activate(type,old_tab,new_tab)
if type == "LEAVE" then
return
end
core.set_topleft_text('Multicraft II')
if core.setting_getbool("public_serverlist") then
asyncOnlineFavourites()
else
menudata.favorites = core.get_favorites("local")
end
end
--------------------------------------------------------------------------------
tab_simple_main = {
name = "main",
caption = fgettext("Main"),
cbf_formspec = get_formspec,
cbf_button_handler = main_button_handler,
on_change = on_activate
}

View File

@ -75,35 +75,66 @@ local function singleplayer_refresh_gamebar()
end
local function get_formspec(tabview, name, tabdata)
local retval = ""
local index = filterlist.get_current_index(menudata.worldlist,
tonumber(core.setting_get("mainmenu_last_selected_world"))
)
local index = menudata.worldlist:get_current_index(
tonumber(core.setting_get("mainmenu_last_selected_world"))
)
retval = retval ..
"image_button[4,4.05;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;play;".. fgettext("Play") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.8,4.05;3.95,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create;".. fgettext("New") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
local retval =
"size[16,11]"..
"box[-100,8.5;200,10;#999999]" ..
"box[-100,-10;200,12;#999999]" ..
"bgcolor[#00000070;true]"..
"image_button[4,8.7;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;play;".. fgettext("Play") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.8,8.7;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_create;".. fgettext("New") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[4,4.8;2.68,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete;".. fgettext("Delete") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[6.53,4.8;2.68,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_configure;".. fgettext("Configure") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[9.07,4.8;2.68,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;cancel;".. fgettext("Cancel") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[4,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_delete;".. fgettext("Delete") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
--"image_button[6.53,9.55;2.68,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;world_configure;".. fgettext("Configure") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[7.8,9.55;3.95,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;cancel;".. fgettext("Cancel") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"label[7,1.5;" .. fgettext("Select World:") .. "]" ..
"label[4,-0.25;".. fgettext("Select World:") .. "]"..
"checkbox[0.25,0.25;cb_creative_mode;".. fgettext("Creative Mode") .. ";" ..
dump(core.setting_getbool("creative_mode")) .. "]"..
"checkbox[0.25,0.7;cb_enable_damage;".. fgettext("Enable Damage") .. ";" ..
dump(core.setting_getbool("enable_damage")) .. "]"..
"textlist[4,0.25;7.5,3.7;sp_worlds;" ..
menu_render_worldlist() ..
";" .. index .. "]"
return retval
"checkbox[12,8.70;cb_creative_mode;" .. fgettext("Creative Mode") .. ";" .. dump(core.setting_getbool("creative_mode")) .. "]" ..
--"checkbox[1000,9.20;cb_enable_damage;" .. fgettext("Enable Damage") .. ";" .. dump(core.setting_getbool("enable_damage")) .. "]" ..
-- "checkbox[12,9.50;cb_server_announce;" .. fgettext("Public") .. ";" .. dump(core.setting_getbool("server_announce")) .. "]" ..
"checkbox[0.2,8.35;btn_server;Local Server;false]"
local bind_addr = core.setting_get("bind_address")
if not PLATFORM=="android" and bind_addr ~= nil and bind_addr ~= "" then
retval = retval ..
"field[300,0;2.25,0.5;te_serveraddr;" .. fgettext("Bind Address") .. ";" ..
core.formspec_escape(core.setting_get("bind_address")) .. "]"..
"field[300,1;1.25,0.5;te_serverport;" .. fgettext("Port") .. ";" ..
core.formspec_escape(core.setting_get("port")) .. "]"
else
retval = retval ..
"field[300,1;3.5,0.5;te_serverport;" .. fgettext("Server Port") .. ";" ..
core.formspec_escape(core.setting_get("port")) .. "]"
end
retval = retval ..
"textlist[0,2.2;16,6.5;sp_worlds;" ..
menu_render_worldlist() ..
";" .. (index or 1) .. ";true]"
return retval
end
local function main_button_handler(this, fields, name, tabdata)
--assert(name == "singleplayer")
if fields["btn_server"]~=nil then
local single = create_tab_server(true)
single:set_parent(this.parent)
single:show()
this:hide()
return true
end
local world_doubleclick = false
if fields["sp_worlds"] ~= nil then
@ -138,7 +169,7 @@ local function main_button_handler(this, fields, name, tabdata)
world_doubleclick or
fields["key_enter"] then
local selected = core.get_textlist_index("sp_worlds")
print(selected)
if selected ~= nil then
gamedata.selected_world = menudata.worldlist:get_raw_index(selected)
gamedata.singleplayer = true
@ -237,3 +268,12 @@ tab_singleplayer = {
cbf_button_handler = main_button_handler,
on_change = on_change
}
function create_tab_single()
local retval = dialog_create("singleplayer",
get_formspec,
main_button_handler,
nil)
return retval
end

View File

@ -51,7 +51,7 @@ local function get_formspec(tabview, name, tabdata)
"box[-100,8.5;200,10;#999999]" ..
"box[-100,-10;200,12;#999999]" ..
"label[4,-0.25;".. fgettext("Select texture pack:") .. "]"..
"image_button[12,9.55;4,0.8;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..minetest.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"image_button[12,9.55;4,0.8;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button.png;btn_cancel;".. fgettext("OK") .. ";true;true;"..core.formspec_escape(mm_texture.basetexturedir).."menu_button_b.png]"..
"textlist[0,2.0;15.8,6.25;TPs;"
local current_texture_path = core.setting_get("texture_path")

View File

@ -1,4 +1,5 @@
if not multicraft.get_modpath("check") then os.exit() end
if not multicraft.get_modpath("check") then os.exit() end
if not default.multicraft_is_variable_is_a_part_of_multicraft_subgame_and_copying_it_means_you_use_our_code_so_we_become_contributors_of_your_project then exit() end
-------------------------
-- adbs mod by 4aiman --
@ -1532,7 +1533,24 @@ function adbs.register_spawn(name,
action = function(pos, node, aoc, aocw)
if aocw > aocnt then return end
if not adbs.spawning_mobs[nm] then return end
local test = minetest.get_node(pos).name
if test:find('water')
then
return
else
--print(test)
end
pos.y = pos.y+1
local test = minetest.get_node(pos).name
if test:find('water')
then
return
else
-- print(test)
end
pos.y = pos.y+1
local l = multicraft.get_node_light(pos)
local daytime = multicraft.get_timeofday()
local high_time
@ -1549,6 +1567,7 @@ function adbs.register_spawn(name,
high_time = true
end
end
if not high_time then return end
if not l then return end
if l > light then return end
@ -2150,21 +2169,21 @@ end
local _
adbs.register_spawn("adbs:sheep", {"group:crumbly"}, _,
5, 15, 5, 40, 2, 50, 10, 100, _, 100, _, 2, _,0,1)
5, 15, 5, 48, 2, 50, 10, 100, _, 100, _, 2, _,0,1)
adbs.register_spawn("adbs:pig", {"group:crumbly"}, "default:water_source",
4, 15, 5, 50, 3, 100, _, 100, _, 100, _, 1, _,0,1)
adbs.register_spawn("adbs:pig", {"group:crumbly"}, _,
3, 15, 5, 40, 3, 100, _, 100, _, 100, _, 1, _,0,1)
adbs.register_spawn("adbs:chicken", {"group:crumbly"}, _,
3, 15, 5, 60, 2, 100, _, 100, _, 100, _, 1, _,0,1)
adbs.register_spawn("adbs:cow", {"group:crumbly"}, "default:water_source",
6, 15, 5, 50, 3, 100, _, 100, _, 100, _, 1, _,0,1)
adbs.register_spawn("adbs:cow", {"group:crumbly"}, _,
5, 15, 5, 50, 3, 100, _, 100, _, 100, _, 1, _,0,1)
adbs.register_spawn("adbs:skeleton", {"group:cracky", "group:crumbly"}, _,
7, 8, _, 40, 2, 100, -5000, 100, _, 100, _, 1, _,0.7,0.3)
adbs.register_spawn("adbs:zombie", {"group:crumbly"}, _,
adbs.register_spawn("adbs:zombie", {"group:crumbly", }, _,
7, 9, _, 40, 2, 100, -5000, 100, _, 100, _, 1, _,0.7,0.3)
adbs.register_spawn("adbs:skeleton", {"group:cracky", "group:crumbly"}, _,

View File

@ -12,6 +12,7 @@ multicraft.register_alias("mapgen_jungletree", "default:jungletree")
multicraft.register_alias("mapgen_jungleleaves", "default:jungleleaves")
multicraft.register_alias("mapgen_apple", "default:leaves")
multicraft.register_alias("mapgen_water_source", "default:water_source")
multicraft.register_alias("mapgen_river_water_source", "default:water_source")
multicraft.register_alias("mapgen_dirt", "default:dirt")
multicraft.register_alias("mapgen_sand", "default:sand")
multicraft.register_alias("mapgen_gravel", "default:gravel")
@ -26,6 +27,7 @@ multicraft.register_alias("mapgen_stone_with_iron", "default:stone_with_iron")
multicraft.register_alias("mapgen_desert_sand", "default:sand")
multicraft.register_alias("mapgen_desert_stone", "default:sandstone")
--
-- Ore generation
--