commit 21bfe72ab3cb7bb1f2649842739d39f7cb940a36 Author: ROllerozxa Date: Sun May 1 20:59:09 2022 +0200 Initial Commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..416edce --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# enable_shadows +Since recent versions of Minetest 5.6.0-dev the dynamic shadow feature has been disabled by default, being required to enable by the game or modset you're using. This is a small mod that is compatible with any game and that can reenable shadows and control its intensity per-world. \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3a60376 --- /dev/null +++ b/init.lua @@ -0,0 +1,45 @@ + +local S = minetest.get_translator('enable_shadows') +local storage = minetest.get_mod_storage() + +local default_intensity = tonumber(minetest.settings:get("enable_shadows_default_intensity") or 0.33) +local intensity = tonumber(storage:get("intensity") or default_intensity) + +minetest.register_on_joinplayer(function(player) + player:set_lighting({ + shadows = { intensity = intensity } + }) +end) + +core.register_chatcommand("shadow_intensity", { + params = "", + description = S("Set shadow intensity for the current world."), + func = function(name, param) + local new_intensity + if param ~= "" then + new_intensity = tonumber(param) or nil + else + new_intensity = tonumber(default_intensity) or nil + end + + if new_intensity < 0 or new_intensity > 1 or new_intensity == nil then + minetest.chat_send_player(name, minetest.colorize("#ff0000", S("Invalid intensity."))) + return true + end + + if new_intensity ~= default_intensity then + minetest.chat_send_player(name, S("Set intensity to @1.", new_intensity)) + storage:set_float("intensity", new_intensity) + else + minetest.chat_send_player(name, S("Set intensity to default value (@1).", default_intensity)) + storage:set_string("intensity", "") + end + + intensity = new_intensity + for _,player in pairs(minetest.get_connected_players()) do + player:set_lighting({ + shadows = { intensity = new_intensity } + }) + end + end +}) diff --git a/locale/enable_shadows.sv.tr b/locale/enable_shadows.sv.tr new file mode 100644 index 0000000..773f46c --- /dev/null +++ b/locale/enable_shadows.sv.tr @@ -0,0 +1,6 @@ +# textdomain: enable_shadows + +Set shadow intensity for the current world.=Ställ in skuggintensitet för nuvarande värld. +Invalid intensity.=Ogiltig intensitet +Set intensity to @1.=Ställde intensiteten till @1. +Set intensity to default value (@1).=Ställde intensiteten till standardvärde (@1). \ No newline at end of file diff --git a/locale/template.txt b/locale/template.txt new file mode 100644 index 0000000..4e60c63 --- /dev/null +++ b/locale/template.txt @@ -0,0 +1,6 @@ +# textdomain: enable_shadows + +Set shadow intensity for the current world.= +Invalid intensity.= +Set intensity to @1.= +Set intensity to default value (@1).= \ No newline at end of file diff --git a/mod.conf b/mod.conf new file mode 100644 index 0000000..2b74a56 --- /dev/null +++ b/mod.conf @@ -0,0 +1,3 @@ +title = Enable Shadows +name = enable_shadows +description = Enable shadows for Minetest 5.6.0-dev. \ No newline at end of file diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..d865f9b Binary files /dev/null and b/screenshot.png differ diff --git a/settingtypes.txt b/settingtypes.txt new file mode 100644 index 0000000..ad37b4e --- /dev/null +++ b/settingtypes.txt @@ -0,0 +1,2 @@ +# Default shadow intensity when no other has been set. +enable_shadows_default_intensity (Default shadow intensity) float 0.33 0 1 \ No newline at end of file