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