diff --git a/static_spawn/init.lua b/static_spawn/init.lua index f649d34..c6b6318 100644 --- a/static_spawn/init.lua +++ b/static_spawn/init.lua @@ -1,71 +1,91 @@ -- twi_mods/static_spawn/init.lua --[[ Copyright (C) 2014-2021 AndrejIT, spfar, mightyjoe781 Copyright (C) 2024 1F616EMO This library 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 library 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 library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ]] S = core.get_translator("spawn") core.register_chatcommand("spawn", { description = S("Teleport to spawnpoint"), privs = { home = true }, func = function(name) local player = core.get_player_by_name(name) if not player then return false, S("Player object not found.") end local spawn_pos = core.setting_get_pos("static_spawnpoint") if not spawn_pos then return false, S("Spawn point not set. Consult moderators to set a proper static spawnpoint.") end player:set_pos(spawn_pos) background_music.set_start_play_gap(name, 2) background_music.decide_and_play(player, true) return true, S("Teleported to Spawn!") end }) core.register_chatcommand("setspawn", { description = S("Override the static spawnpoint"), privs = { server = true }, param = "[]", func = function(name, param) if param == "" then local player = core.get_player_by_name(name) if not player then return false, S("Player object not found.") end param = core.pos_to_string(player:get_pos(), 0) else local pos = core.string_to_pos(param) if not pos then return false, S("Invalid position given.") end param = core.pos_to_string(pos) end core.settings:set("static_spawnpoint", param) return true, S("Static spawnpoint set to @1.", param) end }) + + + +core.register_chatcommand("spawn", { + description = S("Teleport to origin"), + privs = { + home = true + }, + func = function(name) + local player = core.get_player_by_name(name) + if not player then + return false, S("Player object not found.") + end + + player:set_pos({ x = 37, y = 18, z = -42 }) + background_music.set_start_play_gap(name, 2) + background_music.decide_and_play(player, true) + return true, S("Teleported to Origin!") + end +}) diff --git a/twi_bgm/init.lua b/twi_bgm/init.lua index 584c5a6..fa29bea 100644 --- a/twi_bgm/init.lua +++ b/twi_bgm/init.lua @@ -1,137 +1,261 @@ -- twi_mods/twi_bgm/init.lua -- Make background musics by area -- Copyright (C) 2024 1F616EMO -- SPDX-License-Identifier: LGPL-3.0-or-later local MP = core.get_modpath("twi_bgm") +-- Songs played around Grape Hills Spawnpoint in daytime +background_music.register_music("twi_bgm:gh_spawn_day", { + -- Sun Cave Village + -- Soundworlds Histories: Chasing the Leviathan (John Oestmann) + -- License: CC0 + { + file = MP .. "/bgms/john_leviathan_03.ogg", + gain = 0.4, + resend_time = 198.4, + }, + + -- Inca Pan Flute hip hop + -- Tom Peter + -- https://opengameart.org/content/inca-pan-flute-hip-hop + -- License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ + { + file = MP .. "/bgms/tom_inca_pan_flute.ogg", + gain = 0.4, + resend_time = 146.4, + }, + + -- Fluffy style + -- Totraf + -- https://opengameart.org/content/fluffy-style + -- License: CC BY 3.0 https://creativecommons.org/licenses/by/3.0/ + { + file = MP .. "/bgms/tom_fluffy_style.ogg", + gain = 0.4, + resend_time = 161.9, + }, + + -- Town Themne + -- Pixelsphere OST? (cynicmusic) + -- https://opengameart.org/content/town-theme-rpg + -- License: CC0 + { + file = MP .. "/bgms/cynicmusic_town_theme.ogg", + gain = 0.4, + resend_time = 97.5, + }, + + -- Yuri, the Travelling Shoppe + -- Soundworlds Histories: Duskfire (John Oestmann) + -- License: CC0 + { + file = MP .. "/bgms/john_duskfire_07.ogg", + gain = 0.4, + resend_time = 100.2, + }, + + -- Stepping Pebbles (No Drums) + -- Matthew Pablo + -- https://opengameart.org/content/stepping-stones + -- License: CC BY 3.0 https://creativecommons.org/licenses/by/3.0/ + { + file = MP .. "/bgms/pablo_stepping_pebbles_nodrums.ogg", + gain = 0.4, + resend_time = 64.4, + }, + + -- Little Town [TODO] + -- bart (remix: 1F616EMO) + -- https://opengameart.org/content/little-town + -- License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ + -- { + -- file = MP .. "/bgms/1f616emo_little_town", + -- }, +}) + +-- Songs played around Grape Hills Spawnpoint at night +background_music.register_music("twi_bgm:gh_spawn_night", { + -- Del Erad + -- Radakan OST (Janne Hanhisuanto for Radakan) + -- https://opengameart.org/content/radakan-del-erad + -- License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ + { + file = MP .. "/bgms/radakan_del_erad.ogg", + gain = 0.4, + resend_time = 300.8, + }, + + -- Never Grow Up + -- Diminixed + -- License:CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/ + { + file = MP .. "/bgms/diminixed_nevergrowup.ogg", + gain = 0.4, + resend_time = 71.4, + }, + + -- A New Town (RPG Theme) + -- Pixelsphere OST (cynicmusic) + -- https://pixelsphere.org/ + -- License: CC0 + { + file = MP .. "/bgms/pixelsphere_25_new_town.ogg", + gain = 0.4, + resend_time = 62.3, + }, + + -- Deadlands Forest Shrine + -- Soundworlds Datapedia: Ardune Ambient (John Oestmann) + -- License: CC0 + { + file = MP .. "/bgms/john_ardune_07.ogg", + gain = 0.4, + resend_time = 193.5, + }, + + -- Path to Lake Land + -- Alexandr Zhelanov + -- License: CC-BY 3.0 https://creativecommons.org/licenses/by/3.0/ + { + file = MP .. "/bgms/zhelanov_path_lake_land.ogg", + gain = 0.4, + resend_time = 254.8, + }, +}) + -- Songs played around Spawnpoint in daytime background_music.register_music("twi_bgm:spawn_day", { -- Sun Cave Village -- Soundworlds Histories: Chasing the Leviathan (John Oestmann) -- License: CC0 { file = MP .. "/bgms/john_leviathan_03.ogg", gain = 0.4, resend_time = 198.4, }, -- Inca Pan Flute hip hop -- Tom Peter -- https://opengameart.org/content/inca-pan-flute-hip-hop -- License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ { file = MP .. "/bgms/tom_inca_pan_flute.ogg", gain = 0.4, resend_time = 146.4, }, -- Fluffy style -- Totraf -- https://opengameart.org/content/fluffy-style -- License: CC BY 3.0 https://creativecommons.org/licenses/by/3.0/ { file = MP .. "/bgms/tom_fluffy_style.ogg", gain = 0.4, resend_time = 161.9, }, -- Town Themne -- Pixelsphere OST? (cynicmusic) -- https://opengameart.org/content/town-theme-rpg -- License: CC0 { file = MP .. "/bgms/cynicmusic_town_theme.ogg", gain = 0.4, resend_time = 97.5, }, -- Yuri, the Travelling Shoppe -- Soundworlds Histories: Duskfire (John Oestmann) -- License: CC0 { file = MP .. "/bgms/john_duskfire_07.ogg", gain = 0.4, resend_time = 100.2, }, -- Stepping Pebbles (No Drums) -- Matthew Pablo -- https://opengameart.org/content/stepping-stones -- License: CC BY 3.0 https://creativecommons.org/licenses/by/3.0/ { file = MP .. "/bgms/pablo_stepping_pebbles_nodrums.ogg", gain = 0.4, resend_time = 64.4, }, -- Little Town [TODO] -- bart (remix: 1F616EMO) -- https://opengameart.org/content/little-town -- License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ -- { -- file = MP .. "/bgms/1f616emo_little_town", -- }, }) -- Songs played around Spawnpoint at night background_music.register_music("twi_bgm:spawn_night", { -- Del Erad -- Radakan OST (Janne Hanhisuanto for Radakan) -- https://opengameart.org/content/radakan-del-erad -- License: CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0/ { file = MP .. "/bgms/radakan_del_erad.ogg", gain = 0.4, resend_time = 300.8, }, -- Never Grow Up -- Diminixed -- License:CC BY-SA 4.0 https://creativecommons.org/licenses/by-sa/4.0/ { file = MP .. "/bgms/diminixed_nevergrowup.ogg", gain = 0.4, resend_time = 71.4, }, -- A New Town (RPG Theme) -- Pixelsphere OST (cynicmusic) -- https://pixelsphere.org/ -- License: CC0 { file = MP .. "/bgms/pixelsphere_25_new_town.ogg", gain = 0.4, resend_time = 62.3, }, -- Deadlands Forest Shrine -- Soundworlds Datapedia: Ardune Ambient (John Oestmann) -- License: CC0 { file = MP .. "/bgms/john_ardune_07.ogg", gain = 0.4, resend_time = 193.5, }, -- Path to Lake Land -- Alexandr Zhelanov -- License: CC-BY 3.0 https://creativecommons.org/licenses/by/3.0/ { file = MP .. "/bgms/zhelanov_path_lake_land.ogg", gain = 0.4, resend_time = 254.8, }, }) background_music.register_on_decide_music(function(player) local ppos = player:get_pos() local timeofday = core.get_timeofday() -- 0.23 < day < 0.78 local now_day = timeofday > 0.23 and timeofday < 0.78 + if func_areas.is_in_func_area(ppos, 2207) then + -- Grape Hills Spawn + return now_day and "twi_bgm:gh_spawn_day" or "twi_bgm:gh_spawn_night" + end + if func_areas.is_in_func_area(ppos, 497) then -- Spawn Island return now_day and "twi_bgm:spawn_day" or "twi_bgm:spawn_night" end end)