From e0c15bd0509f59141ab0cc434a74b13d500ad7a1 Mon Sep 17 00:00:00 2001 From: Alexsandro Percy Date: Sun, 2 Jan 2022 09:49:58 -0300 Subject: [PATCH] prizes fix --- init.lua | 3 ++- scoreboard.lua | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/init.lua b/init.lua index 8f1efe3..f741748 100644 --- a/init.lua +++ b/init.lua @@ -253,6 +253,7 @@ local function spawnstep(dtime) --minetest.add_entity(pos2, "zombiestrd:target") --debug target pos2.y=pos2.y-5 local height, liquidflag = mobkit.get_terrain_height(pos2,32) + if height == nil then height = 0 end local position_at_terrain_height = {x=pos2.x,y=height-0.01,z=pos2.z} --force the spawn area be inside the area @@ -387,7 +388,7 @@ minetest.register_entity("zombiestrd:zombie",{ --PONCTUATION if zombie_score[name] then zombie_score[name] = zombie_score[name] + 1 - check_prizes(puncher,zombie_score[name] + 1) + check_prizes(puncher) else zombie_score[name] = 1 end diff --git a/scoreboard.lua b/scoreboard.lua index 2dc877d..7a89b72 100644 --- a/scoreboard.lua +++ b/scoreboard.lua @@ -2,9 +2,14 @@ local storage = minetest.get_mod_storage() zombie_score = {} local prizes = { - {500, "default:mese", 1, "mese block"}, - {1000, "default:diamondblock", 1, "diamond block"}, - {1500, "default:diamondblock", 2, "diamond block"}, + {250, "binoculars:binoculars", 1, "binoculars"}, + {500, "default:mese_crystal", 5, "mese crystal"}, + {750, "default:mese", 1, "mese block"}, + {1000, "default:steel_ingot", 18, "steel ingot"}, + {1250, "default:diamond", 5, "diamond"}, + {1500, "default:diamondblock", 1, "diamond block"}, + {1750, "default:diamondblock", 2, "diamond block"}, + {2000, "default:obsidian", 99, "obsidian"}, } -- load scoreboard @@ -65,19 +70,19 @@ local function sortscore() return fname end -function check_prizes(user,number) +function check_prizes(user) local name = user:get_player_name() local inv = user:get_inventory() for i in ipairs(prizes) do local goal = prizes[i][1] - local nodename = prizes[i][2] - local howmuch = prizes[i][3] - local sayit = prizes[i][4] + local nodename = prizes[i][2] + local howmuch = prizes[i][3] + local sayit = prizes[i][4] - if zombie_score[name] + number == goal then - minetest.chat_send_player(name, core.colorize("#FF6700", "Congratulation: You killed your "..goal.."s zombies !! Keep up the good work. "..howmuch.." "..sayit.." have been added to your inv")) - inv:add_item("main", {name=nodename, count=howmuch}) - end + if zombie_score[name] == goal then + minetest.chat_send_player(name, core.colorize("#FF6700", "Congratulation: You killed your "..goal.."s zombies !! Keep up the good work. "..howmuch.." "..sayit.." have been added to your inv")) + inv:add_item("main", {name=nodename, count=howmuch}) + end end end