Compare commits

...

5 Commits

Author SHA1 Message Date
David G b33c18e82f Add z_index to HUD definition (fixes issue 1). 2020-11-20 09:28:00 -07:00
David G cf4211fc75 Rename to vignette_redo. 2019-04-04 14:33:00 -07:00
David G aa59bd2d36 Add local storage to maintain state. 2019-03-19 13:25:27 -07:00
David G 67ab33f15d Remove blank.png. 2018-12-05 08:46:22 -07:00
David G efc09bca3b Add documentation and change default to off. 2018-11-10 16:24:00 -07:00
7 changed files with 78 additions and 14 deletions

38
README.md Normal file
View File

@ -0,0 +1,38 @@
Vignette Redo
-------------
A Minetest mod to optionally place a vignette filter over the screen.
![Vignette Screenshot](screenshot.png "Vignette")
By David G (kestral246), based on the concept by TriBlade9.
How to enable
-------------
This mod defaults to not applying filter. To enable, use the chat command:
> "/vignette"
Repeated use of this command will toggle the effect off and on.
Local mod storage is used to maintain state of vignette filter between sessions, per user.
Licenses
--------
Source code
> The MIT License (MIT)
Media (textures)
>Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)

View File

@ -1,23 +1,45 @@
-- vignette
-- Adds a vignette filter to player's screen
-- vignette_redo
-- Optionally place a vignette filter over the screen.
-- Based on concept by TriBlade9
-- By David_G (kestral246@gmail.com)
-- Includes chat command "/vignette", which toggles effect off or on
-- Vignette effect defaults to off at start.
-- Use chat command "/vignette" to enable, and then to toggle effect off or on.
-- Local storage maintains state of vignette filter per user.
-- 2020-11-20
-- Add z_index to HUD definition (issue 1)
local vignette = {}
local storage = minetest.get_mod_storage()
minetest.register_on_joinplayer(function(player)
local pname = player:get_player_name()
vignette[pname] = {
id = player:hud_add({
hud_elem_type = "image",
text = "vignette.png",
position = {x=0, y=0},
scale = {x=-100, y=-100},
alignment = {x=1, y=1},
offset = {x=0, y=0}
}),
enable = true }
if storage:get(pname) and storage:get(pname) == "1" then -- enabled
vignette[pname] = {
id = player:hud_add({
hud_elem_type = "image",
text = "vignette.png",
position = {x=0, y=0},
scale = {x=-100, y=-100},
alignment = {x=1, y=1},
offset = {x=0, y=0},
z_index = -400
}),
enable = true }
else -- not enabled
vignette[pname] = {
id = player:hud_add({
hud_elem_type = "image",
text = "",
position = {x=0, y=0},
scale = {x=-100, y=-100},
alignment = {x=1, y=1},
offset = {x=0, y=0},
z_index = -400
}),
enable = false }
end
end)
minetest.register_chatcommand("vignette", {
@ -27,11 +49,13 @@ minetest.register_chatcommand("vignette", {
func = function(name, param)
local player = minetest.get_player_by_name(name)
if vignette[name].enable == true then
player:hud_change(vignette[name].id, "text", "blank.png")
player:hud_change(vignette[name].id, "text", "")
vignette[name].enable = false
storage:set_string(name, "0")
else
player:hud_change(vignette[name].id, "text", "vignette.png")
vignette[name].enable = true
storage:set_string(name, "1")
end
end,
})

2
mod.conf Normal file
View File

@ -0,0 +1,2 @@
name = vignette_redo
description = Optionally place a vignette filter over the screen.

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 42 KiB