]> git.lizzy.rs Git - elidragon.git/commitdiff
Tweaked birthday.lua and other things
authorElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 9 Sep 2020 14:25:50 +0000 (16:25 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 9 Sep 2020 14:25:50 +0000 (16:25 +0200)
birthday.lua
skyblock.lua

index 7c33fd2ce5f84519d88e70a24f30f601be85ebb4..a675f374d156bc1f3d1f138fb4f6316b81370e0d 100755 (executable)
@@ -1,9 +1,25 @@
 elidragon.savedata.birthday = elidragon.savedata.birthday or {}
+
+function elidragon.set_birthday(player, birthday)
+       player:get_meta():set_string("elidragon:birthday", birthday)
+end
+
+function elidragon.get_birthday(player)
+       local name = player:get_player_name()
+       local birthday = player:get_meta():get_string("elidragon:birthday")
+       if birthday == "" then
+               birthday = elidragon.savedata.birthday[name]
+               if birthday then
+                       elidragon.savedata.birthday[name] = nil
+                       elidragon.set_birthday(player, birthday)
+               end
+       end
+       return birthday
+end
+
 function elidragon.flower_rain(name)
        local player = minetest.get_player_by_name(name)
-       if not player then
-               return
-       end
+       if not player then return end
        local pos = player:get_pos()
        minetest.add_particlespawner({
                amount = 50,
@@ -25,8 +41,7 @@ function elidragon.flower_rain(name)
        minetest.after(0.5, function() elidragon.flower_rain(name) end)
 end
 minetest.register_on_joinplayer(function(player)
-       local name = player:get_player_name()
-       if elidragon.savedata.birthday[name] == os.date("%d/%m") then
+       if elidragon.get_birthday(player) == os.date("%d/%m") then
                minetest.chat_send_all(minetest.colorize("#FF20FF", name .. " has joined the game. Today is their birthday!"))
                elidragon.flower_rain(name)
                player:hud_add({
@@ -44,7 +59,9 @@ minetest.register_chatcommand("birthday", {
        description = "Set your birthday (e.g. 07/09 if your birthday is the seventh of september)",
        param = "DD/MM",
        func = function(name, param)
-               elidragon.savedata.birthday[name] = param
-               minetest.chat_send_player(name, "Birthday set to " .. param)
+               local player = minetest.get_player_by_name(name)
+               if not player then return false, "You need to be online to use this command." end
+               elidragon.set_birthday(player, param)
+               return true, "Birthday set to " .. param
        end
 })
index e190bda3e9c61f77bcf084a5be699e08487eef38..55d9b40a4b04e86ddb286d2986d940cc6c3fa3fd 100755 (executable)
@@ -144,26 +144,6 @@ end
 
 elidragon.savedata.spawns = elidragon.savedata.spawns or elidragon.skyblock.load_legacy_spawns() or {}
 
-
--- level
---[[
-minetest.register_chatcommand("level", {
-       description = "Get/set the current level of a player",
-       params = "<player> [<level>]",
-       func = function(name, param)
-               local target = param:split(" ")[1]
-               local level = tonumber(param:split(" ")[2])
-               if not level then
-                       minetest.chat_send_player(name, target .. " is on level " .. elidragon.skyblock.get_level(target))
-               elseif minetest.check_player_privs(name, {server = true}) and elidragon.skyblock.set_level(target, level) then
-                       minetest.chat_send_player(name, target .. " has been set to level " .. level)
-               else
-                       minetest.chat_send_player(name, "Cannot change " .. target .. " to level " .. level)
-               end
-       end,
-})
-]]--
-
 -- node
 
 minetest.register_node("elidragon:skyblock", {
@@ -219,33 +199,33 @@ minetest.after(0, function()
                local node
                if oldnode.name == "default:lava_source" then
                        node = "default:obsidian"
-               elseif math.random() < 0.001 then
+               elseif math.random() < 0.0001 then
                        node = "moreores:mineral_mithril"
-               elseif math.random() < 0.003 then
+               elseif math.random() < 0.0003 then
                        node = "default:stone_with_diamond"
-               elseif math.random() < 0.005 then
+               elseif math.random() < 0.0005 then
                        node = "default:stone_with_mese"
-               elseif math.random() < 0.01 then
+               elseif math.random() < 0.001 then
                        node = "default:stone_with_gold"
-               elseif math.random() < 0.01 then
+               elseif math.random() < 0.001 then
                        node = "technic:mineral_chromium"
-               elseif math.random() < 0.01 then
+               elseif math.random() < 0.001 then
                        node = "technic:mineral_zinc"
-               elseif math.random() < 0.012 then
+               elseif math.random() < 0.0012 then
                        node = "technic:mineral_uranium"
-               elseif math.random() < 0.015 then
+               elseif math.random() < 0.0015 then
                        node = "default:stone_with_tin"
-               elseif math.random() < 0.02 then
+               elseif math.random() < 0.002 then
                        node = "default:stone_with_copper"
-               elseif math.random() < 0.025 then
+               elseif math.random() < 0.0025 then
                        node = "technic:mineral_sulfur"
-               elseif math.random() < 0.033 then
+               elseif math.random() < 0.0033 then
                        node = "default:stone_with_iron"
-               elseif math.random() < 0.04 then
+               elseif math.random() < 0.004 then
                        node = "moreores:mineral_silver"
-               elseif math.random() < 0.045 then
+               elseif math.random() < 0.0045 then
                        node = "technic:mineral_lead"
-               elseif math.random() < 0.05 then
+               elseif math.random() < 0.005 then
                        node = "default:stone_with_coal"
                else
                        node = "default:stone"
@@ -271,7 +251,7 @@ minetest.after(0, function()
                        if stree ~= tree then
                                items[#items + 1] = {
                                        items = {stree .. "sapling"},
-                                       rarity = 1000,
+                                       rarity = 10000,
                                }
                        end
                end