load BGM from the world folder + move SETTINGS in the world folder
This commit is contained in:
parent
cbf9733296
commit
735d55627e
2
DOCS.md
2
DOCS.md
@ -90,7 +90,7 @@ The second field, on the contrary, is a table of optional parameters: they defin
|
||||
* `team_properties`: ^ (it won't work if `teams` hasn't been declared)
|
||||
|
||||
### 1.1 Per server configuration
|
||||
There are also a couple of settings that can only be set in game via `/arenas settings`. This because different servers might need different parameters. They are:
|
||||
There are also a couple of settings that can only be set in game via `/arenas settings <minigame>`. This because different servers might need different parameters. They are:
|
||||
* `hub_spawn_point`: where players will be teleported when a match _in your mod_ ends. Default is `{ x = 0, y = 20, z = 0 }`. A bit of noise is applied on the x and z axis, ranging between `-1.5` and `1.5`.
|
||||
* `queue_waiting_time`: the time to wait before the loading phase starts. It gets triggered when the minimum amount of players has been reached to start the queue. Default is `10`
|
||||
|
||||
|
3
IGNOREME/README.md
Normal file
3
IGNOREME/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
**EDITING THIS FOLDER IS USELESS, EDIT THE ONE CALLED arena_lib IN THE WORLD FOLDER INSTEAD**
|
||||
|
||||
The first time the world is launched with `arena_lib` on, this folder is copy-pasted into the world folder (with the sole exception of this file). The purpose of this folder is to provide all the files and the structure to customise arena_lib.
|
2
SETTINGS.lua → IGNOREME/SETTINGS.lua
Executable file → Normal file
2
SETTINGS.lua → IGNOREME/SETTINGS.lua
Executable file → Normal file
@ -4,7 +4,7 @@ arena_lib.DEFAULT_ENTRANCE = "sign"
|
||||
-- The physics override to apply when a player leaves a match (whether by quitting,
|
||||
-- winning etc). This comes in handy for hybrid servers (i.e. survival/creative
|
||||
-- ones featuring some minigames). If you're aiming for a full minigame server,
|
||||
-- ignore this parameter and let the mod hub_manager supersede it =>
|
||||
-- ignore this parameter and let the mod Hub supersede it =>
|
||||
-- https://gitlab.com/zughy-friends-minetest/hub-manager
|
||||
arena_lib.SERVER_PHYSICS = {
|
||||
speed = 1,
|
3
IGNOREME/instructions.txt
Normal file
3
IGNOREME/instructions.txt
Normal file
@ -0,0 +1,3 @@
|
||||
DO NOT rename folders or the mod won't be able to read them.
|
||||
|
||||
/BGMs is where arenas BGMs shall be put (to then be assigned through the editor specific section).
|
@ -9,7 +9,7 @@ It comes with an arena manager and a signs system. The latter creates a bridge i
|
||||
|
||||
1) Install it as any other mod
|
||||
|
||||
2) Check [SETTINGS.lua](SETTINGS.lua)
|
||||
2) Launch the world at least once with arena_lib enabled and then check `worlds/nameofyourworld/arena_lib` to customise it
|
||||
|
||||
3) (modders only) Dive into the [full documentation](DOCS.md) to understand how to create minigames
|
||||
|
||||
@ -19,7 +19,7 @@ It comes with an arena manager and a signs system. The latter creates a bridge i
|
||||
* (optional) [Parties](https://gitlab.com/zughy-friends-minetest/parties) by me: use it to be sure to join the same arena/team with your friends
|
||||
|
||||
#### Add-ons
|
||||
[Hub](https://gitlab.com/zughy-friends-minetest/hub-manager) by me: use it if you're aiming for a full minigame server. It can't be set as an optional dependency, since arena_lib is a hard dependency of Hub in the first place (and MT doesn't like cross dependencies)
|
||||
* [Hub](https://gitlab.com/zughy-friends-minetest/hub) by me: use it if you're aiming for a full minigame server. It can't be set as an optional dependency, since arena_lib is a hard dependency of Hub in the first place (and MT doesn't like cross dependencies)
|
||||
|
||||
### Known conflicts
|
||||
* `Beds` or any other mod overriding the default respawn system
|
||||
|
4
init.lua
4
init.lua
@ -4,9 +4,11 @@ local srcpath = modpath .. "/src"
|
||||
|
||||
arena_lib = {}
|
||||
|
||||
dofile(modpath .. "/SETTINGS.lua")
|
||||
dofile(srcpath .. "/_load.lua")
|
||||
dofile(modpath .. "/libs/chatcmdbuilder.lua")
|
||||
|
||||
dofile(minetest.get_worldpath() .. "/arena_lib/SETTINGS.lua")
|
||||
|
||||
dofile(srcpath .. "/admin_tools/entrances.lua")
|
||||
dofile(srcpath .. "/admin_tools/minigame_settings.lua")
|
||||
dofile(srcpath .. "/api/core.lua")
|
||||
|
41
src/_load.lua
Normal file
41
src/_load.lua
Normal file
@ -0,0 +1,41 @@
|
||||
local function load_world_folder()
|
||||
local wrld_dir = minetest.get_worldpath() .. "/arena_lib"
|
||||
local bgm_dir = wrld_dir .. "/BGM"
|
||||
|
||||
local content = minetest.get_dir_list(wrld_dir)
|
||||
local modpath = minetest.get_modpath("arena_lib")
|
||||
|
||||
if not next(content) then
|
||||
local src_dir = modpath .. "/IGNOREME"
|
||||
minetest.cpdir(src_dir, wrld_dir)
|
||||
os.remove(wrld_dir .. "/README.md")
|
||||
|
||||
--v------------------ LEGACY UPDATE, to remove in 7.0 -------------------v
|
||||
local old_settings = io.open(modpath .. "/SETTINGS.lua", "r")
|
||||
|
||||
if old_settings then
|
||||
minetest.safe_file_write(wrld_dir .. "/SETTINGS.lua", old_settings:read("*a"))
|
||||
old_settings:close()
|
||||
os.remove(modpath .. "/SETTINGS.lua")
|
||||
end
|
||||
--^------------------ LEGACY UPDATE, to remove in 7.0 -------------------^
|
||||
|
||||
else
|
||||
-- aggiungi musiche come contenuti dinamici per non appesantire il server
|
||||
local function iterate_dirs(dir)
|
||||
for _, f_name in pairs(minetest.get_dir_list(dir, false)) do
|
||||
minetest.dynamic_add_media({filepath = dir .. "/" .. f_name}, function(name) end)
|
||||
end
|
||||
for _, subdir in pairs(minetest.get_dir_list(dir, true)) do
|
||||
iterate_dirs(dir .. "/" .. subdir)
|
||||
end
|
||||
end
|
||||
|
||||
-- non si possono aggiungere contenuti dinamici all'avvio del server
|
||||
minetest.after(0.1, function()
|
||||
iterate_dirs(bgm_dir)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
load_world_folder()
|
@ -1,6 +1,7 @@
|
||||
local S = minetest.get_translator("arena_lib")
|
||||
|
||||
local function get_bgm_formspec() end
|
||||
local function get_audio_file() end
|
||||
local function calc_gain() end
|
||||
local function calc_pitch() end
|
||||
|
||||
@ -95,6 +96,43 @@ end
|
||||
|
||||
|
||||
|
||||
function get_audio_file(bgm_dir, name, mod, p_name)
|
||||
local content = minetest.get_dir_list(bgm_dir, false)
|
||||
|
||||
local function iterate_dirs(dir)
|
||||
for _, f_name in pairs(minetest.get_dir_list(dir, false)) do
|
||||
local file = io.open(dir .. "/" .. name .. ".ogg", "r")
|
||||
if file then
|
||||
io.close(file)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
for _, subdir in pairs(minetest.get_dir_list(dir, true)) do
|
||||
if iterate_dirs(dir .. "/" .. subdir) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local exists = iterate_dirs(bgm_dir)
|
||||
|
||||
--v------------------ LEGACY UPDATE, to remove in 7.0 -------------------v (insieme a 'mod' e 'p_name' come parametro)
|
||||
if not exists then
|
||||
local deprecated_file = io.open(minetest.get_modpath(mod) .. "/sounds/" .. name .. ".ogg", "r")
|
||||
if deprecated_file then
|
||||
deprecated_file:close()
|
||||
minetest.chat_send_player(p_name, minetest.colorize("#e6482e", "[arena_lib] loading sounds from the minigame folder is deprecated and it'll be removed in future versions: put it into the world folder instead!"))
|
||||
exists = true
|
||||
end
|
||||
end
|
||||
--^------------------ LEGACY UPDATE, to remove in 7.0 -------------------^
|
||||
|
||||
return exists
|
||||
end
|
||||
|
||||
|
||||
|
||||
function calc_gain(field)
|
||||
return minetest.explode_scrollbar_event(field).value / 100
|
||||
end
|
||||
@ -115,13 +153,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "arena_lib:bgm" then return end
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
local bgm_dir = minetest.get_worldpath() .. "/arena_lib/BGM/"
|
||||
|
||||
-- se premo su icona "riproduci", riproduco audio
|
||||
if fields.play then
|
||||
|
||||
local mod = player:get_meta():get_string("arena_lib_editor.mod")
|
||||
|
||||
if not io.open(minetest.get_modpath(mod) .. "/sounds/" .. fields.bgm .. ".ogg", "r") then
|
||||
if not get_audio_file(bgm_dir, fields.bgm, mod, p_name) then
|
||||
minetest.chat_send_player(p_name, minetest.colorize("#e6482e", S("[!] This audio track doesn't exist!")))
|
||||
return end
|
||||
|
||||
@ -154,7 +192,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.bgm == "" then
|
||||
arena_lib.set_bgm(p_name, mod, arena_name, nil, nil, nil, nil, nil, true)
|
||||
-- se non esiste il file audio, annullo
|
||||
elseif not io.open(minetest.get_modpath(mod) .. "/sounds/" .. fields.bgm .. ".ogg", "r") then
|
||||
elseif not get_audio_file(bgm_dir, fields.bgm, mod, p_name) then
|
||||
minetest.chat_send_player(p_name, minetest.colorize("#e6482e", S("[!] This audio track doesn't exist!")))
|
||||
return
|
||||
-- sennò applico la traccia indicata
|
||||
|
Loading…
x
Reference in New Issue
Block a user