commit c2563cff2c055c510b1acfb8584f1601695cda63 Author: ROllerozxa Date: Tue Jan 7 00:48:01 2025 +0100 Initial Commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..38996de --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 ROllerozxa + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..f03d752 --- /dev/null +++ b/init.lua @@ -0,0 +1,36 @@ + +local function has_cloud_control(player) + return player:get_meta():contains("clouds_enabled") +end + +local function get_clouds_enabled(player) + return player:get_meta():get_int("clouds_enabled") == 1 +end + +local function set_clouds_enabled(player, enabled) + return player:get_meta():set_int("clouds_enabled", enabled and 1 or 0) +end + +core.register_chatcommand("toggle_clouds", { + params = "", + description = "Toggle clouds on or off for yourself", + func = function(name) + local player = core.get_player_by_name(name) + + local clouds_enabled = get_clouds_enabled(player) + + local new_state = not clouds_enabled + + set_clouds_enabled(player, new_state) + player:set_sky{clouds = new_state} + + return true, + "Clouds have been " .. (new_state and "enabled" or "disabled") .. "." + end, +}) + +core.register_on_joinplayer(function(player) + if has_cloud_control(player) then + player:set_sky{ clouds = get_clouds_enabled(player) } + end +end) diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..284ae77 --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +title = Cloud Control +name = cloud_control +description = Control whether clouds are enabled on per-player basis \ No newline at end of file