Added chat command to toggle.
This commit is contained in:
parent
d87e87d4fa
commit
ded1b68605
14
LICENSE.txt
14
LICENSE.txt
@ -1,5 +1,17 @@
|
||||
Licence of vignette textures
|
||||
License of source code
|
||||
----------------------
|
||||
|
||||
The MIT License (MIT)
|
||||
Copyright 2018 kestral246
|
||||
|
||||
https://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
Licence of media (textures)
|
||||
---------------------------
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||
Copyright 2018 kestral246
|
||||
|
||||
http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
|
50
init.lua
50
init.lua
@ -1,10 +1,44 @@
|
||||
-- vignette
|
||||
-- Adds a vignette filter to player's screen
|
||||
-- Based on concept by TriBlade9
|
||||
-- By David_G (kestral246@gmail.com)
|
||||
-- Includes chat command "/vignette", which toggles effect off or on
|
||||
|
||||
local vignette = {}
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
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}
|
||||
})
|
||||
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 }
|
||||
end)
|
||||
|
||||
minetest.register_chatcommand("vignette", {
|
||||
params = "",
|
||||
description = "Toggle display of vignette mask.",
|
||||
privs = {},
|
||||
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")
|
||||
vignette[name].enable = false
|
||||
else
|
||||
player:hud_change(vignette[name].id, "text", "vignette.png")
|
||||
vignette[name].enable = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local pname = player:get_player_name()
|
||||
if vignette[pname] then
|
||||
vignette[pname] = nil
|
||||
end
|
||||
end)
|
||||
|
BIN
textures/blank.png
Normal file
BIN
textures/blank.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.0 KiB |
Loading…
x
Reference in New Issue
Block a user