]> git.lizzy.rs Git - elidragon.git/blob - birthday.lua
Merge branch 'master' of https://github.com/EliasFleckenstein03/elidragon
[elidragon.git] / birthday.lua
1 elidragon.savedata.birthday = elidragon.savedata.birthday or {}
2 function elidragon.flower_rain(name)
3         local player = minetest.get_player_by_name(name)
4         if not player then
5                 return
6         end
7         local pos = player:get_pos()
8         minetest.add_particlespawner({
9                 amount = 50,
10                 time = 2,
11                 minpos = vector.add(pos, {x = -1, y = 2, z = -1}),
12                 maxpos = vector.add(pos, {x = 1, y = 3, z = 1}),
13                 minvel = {x=0, y=0, z=0},
14                 maxvel = {x=0, y=0, z=0},
15                 minacc = {x=0, y=-8, z=0},
16                 maxacc = {x=0, y=-8, z=0},
17                 minexptime = 0.7,
18                 maxexptime = 1,
19                 minsize = 5,
20                 maxsize = 10,
21                 collisiondetection = true,
22                 vertical = true,
23                 texture = "flowers_rose.png",
24         })
25         minetest.after(0.5, function() elidragon.flower_rain(name) end)
26 end
27 minetest.register_on_joinplayer(function(player)
28         local name = player:get_player_name()
29         if elidragon.savedata.birthday[name] == os.date("%d/%m") then
30                 minetest.chat_send_all(minetest.colorize("#FF20FF", name .. " has joined the game. Today is their birthday!"))
31                 elidragon.flower_rain(name)
32                 player:hud_add({
33                         hud_elem_type = "text",
34                         position      = {x = 1, y = 0},
35                         offset        = {x = -5, y = 5},
36                         text          = "Happy Birthday!",
37                         alignment     = {x = -1, y = 1},
38                         scale         = {x = 100, y = 100},
39                         number    = 0xFFF40A,
40                 })
41         end
42 end)
43 minetest.register_chatcommand("birthday", {
44         description = "Set your birthday (e.g. 07/09 if your birthday is the seventh of september)",
45         param = "DD/MM",
46         func = function(name, param)
47                 elidragon.savedata.birthday[name] = param
48                 minetest.chat_send_player(name, "Birthday set to " .. param)
49         end
50 })