Backup code

master
BrunoMine 2019-08-26 13:40:20 -03:00
parent 05ec4afaa6
commit 773bf65dc9
3 changed files with 78 additions and 1 deletions

View File

@ -1 +1,37 @@
vignette
# Vignette
Dark gradient hud overlay for a immersive experience. By default it will add
a single overlay to a players screen at the beginning of the game.
Vignette also has an api for other mods to leverage.
## Api
> Exposes an api on the vignette namespace with functions `add` and `edit`.
> These function can be used by other mods in the following manner.
```lua
vignette.set({
-- player is a required field
player = player,
-- a number between 0 or 5, you can do more but that might result in
-- a frame-rate drop
darkness = 4
});
vignette.add({
-- same as the first example
player = player,
-- instead of setting it adds the darkness to the current player's screen it
-- is allows to pass negative values also. If the darkness results in a
-- negative value it is defaulted to 0
darkness = 1
})
```

41
init.lua Normal file
View File

@ -0,0 +1,41 @@
vignette = {
huds = {}
}
vignette.set = function (defs)
for i=1, math.max(defs.darkness, #vignette.huds) do
--
-- adding huds
if (i >= #vignette.huds) then
local hud_id=defs.player:hud_add({
hud_elem_type = "image",
position = {x = 0.5, y = 0.5},
scale = {
x = -100,
y = -100
},
text = "vignette.png"
})
vignette.huds[defs.player][i] = hud_id;
end
-- removing huds
if (i > defs.darkness) then
defs.player:hud_remove(vignette.huds[defs.player][i])
end
end
end
vignette.add = function (defs)
defs.darkness = math.max(defs.darkness + #vignette.huds[defs.player], 0)
vignette.set(defs)
end
minetest.register_on_joinplayer(function (player)
vignette.huds[player] = {}
vignette.set({
darkness = 1,
player = player
})
end)

BIN
textures/vignette.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB