Compare commits
5 Commits
ded1b68605
...
b33c18e82f
Author | SHA1 | Date |
---|---|---|
David G | b33c18e82f | |
David G | cf4211fc75 | |
David G | aa59bd2d36 | |
David G | 67ab33f15d | |
David G | efc09bca3b |
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
52
init.lua
52
init.lua
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
name = vignette_redo
|
||||
description = Optionally place a vignette filter over the screen.
|
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 |
Loading…
Reference in New Issue