From 371a1cd66c55b5dfc0e8cc49fb204c5fb5e419ef Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 9 Sep 2020 16:25:50 +0200 Subject: [PATCH] Tweaked birthday.lua and other things --- birthday.lua | 31 ++++++++++++++++++++++++------- skyblock.lua | 50 +++++++++++++++----------------------------------- 2 files changed, 39 insertions(+), 42 deletions(-) diff --git a/birthday.lua b/birthday.lua index 7c33fd2..a675f37 100755 --- a/birthday.lua +++ b/birthday.lua @@ -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 }) diff --git a/skyblock.lua b/skyblock.lua index e190bda..55d9b40 100755 --- a/skyblock.lua +++ b/skyblock.lua @@ -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 = " []", - 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 -- 2.44.0