end
local function configure_selected_world_params(idx)
- local worldconfig = modmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
+ local worldconfig = pkgmgr.get_worldconfig(menudata.worldlist:get_list()[idx].path)
if worldconfig.creative_mode then
core.settings:set("creative_mode", worldconfig.creative_mode)
end
"5=" .. core.formspec_escape(defaulttexturedir .. "server_ping_1.png")
end
---------------------------------------------------------------------------------
-function order_favorite_list(list)
- local res = {}
- --orders the favorite list after support
- for i = 1, #list do
- local fav = list[i]
- if is_server_protocol_compat(fav.proto_min, fav.proto_max) then
- res[#res + 1] = fav
- end
- end
- for i = 1, #list do
- local fav = list[i]
- if not is_server_protocol_compat(fav.proto_min, fav.proto_max) then
- res[#res + 1] = fav
- end
- end
- return res
-end
--------------------------------------------------------------------------------
function render_serverlist_row(spec, is_favorite)
if spec.name then
text = text .. core.formspec_escape(spec.name:trim())
elseif spec.address then
- text = text .. spec.address:trim()
+ text = text .. core.formspec_escape(spec.address:trim())
if spec.port then
text = text .. ":" .. spec.port
end
end
- local details = ""
local grey_out = not is_server_protocol_compat(spec.proto_min, spec.proto_max)
+ local details
if is_favorite then
details = "1,"
else
end
if spec.clients and spec.clients_max then
- local clients_color = ''
local clients_percent = 100 * spec.clients / spec.clients_max
-- Choose a color depending on how many clients are connected
-- (relatively to clients_max)
+ local clients_color
if grey_out then clients_color = '#aaaaaa'
elseif spec.clients == 0 then clients_color = '' -- 0 players: default/white
elseif clients_percent <= 60 then clients_color = '#a1e587' -- 0-60%: green
--------------------------------------------------------------------------------
os.tempfolder = function()
- if core.settings:get("TMPFolder") then
- return core.settings:get("TMPFolder") .. DIR_DELIM .. "MT_" .. math.random(0,10000)
- end
-
- local filetocheck = os.tmpname()
- os.remove(filetocheck)
-
- local randname = "MTTempModFolder_" .. math.random(0,10000)
- if DIR_DELIM == "\\" then
- local tempfolder = os.getenv("TEMP")
- return tempfolder .. filetocheck
- else
- local backstring = filetocheck:reverse()
- return filetocheck:sub(0,filetocheck:len()-backstring:find(DIR_DELIM)+1) ..randname
- end
+ local temp = core.get_temp_path()
+ return temp .. DIR_DELIM .. "MT_" .. math.random(0, 10000)
+end
+--------------------------------------------------------------------------------
+os.tmpname = function()
+ local path = os.tempfolder()
+ io.open(path, "w"):close()
+ return path
end
--------------------------------------------------------------------------------
return false
end
---------------------------------------------------------------------------------
-function asyncOnlineFavourites()
- if not menudata.public_known then
- menudata.public_known = {{
- name = fgettext("Loading..."),
- description = fgettext_ne("Try reenabling public serverlist and check your internet connection.")
- }}
- end
- menudata.favorites = menudata.public_known
- menudata.favorites_is_public = true
-
- if not menudata.public_downloading then
- menudata.public_downloading = true
- else
- return
- end
-
- core.handle_async(
- function(param)
- return core.get_favorites("online")
- end,
- nil,
- function(result)
- menudata.public_downloading = nil
- local favs = order_favorite_list(result)
- if favs[1] then
- menudata.public_known = favs
- menudata.favorites = menudata.public_known
- menudata.favorites_is_public = true
- end
- core.event_handler("Refresh")
- end
- )
-end
-
--------------------------------------------------------------------------------
function text2textlist(xpos, ypos, width, height, tl_name, textlen, text, transparency)
local textlines = core.wrap_text(text, textlen, true)