From 119e47d22e9bea4ec1d37cc4b6440a8928a801a6 Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Tue, 13 Oct 2020 16:23:09 -0700 Subject: [PATCH] Buff medic class and allow item whitelisting --- mods/ctf/ctf_classes/api.lua | 14 ++++++++++---- mods/ctf/ctf_classes/classes.lua | 20 +++++++++++++++++--- mods/ctf/ctf_crafting/init.lua | 16 +++++++++++++--- 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/mods/ctf/ctf_classes/api.lua b/mods/ctf/ctf_classes/api.lua index 054de61..538ea22 100644 --- a/mods/ctf/ctf_classes/api.lua +++ b/mods/ctf/ctf_classes/api.lua @@ -16,9 +16,13 @@ function ctf_classes.register(cname, def) if not def.properties.item_blacklist then def.properties.item_blacklist = {} - for i=1, #def.properties.initial_stuff do - def.properties.item_blacklist[i] = - ItemStack(def.properties.initial_stuff[i]):get_name() + for i, item in ipairs(def.properties.initial_stuff) do + local iname = ItemStack(item):get_name() + + -- Only add to item blacklist if not in the whitelist + if table.indexof(def.properties.item_whitelist or {}, iname) == -1 then + def.properties.item_blacklist[i] = iname + end end end @@ -117,8 +121,10 @@ function ctf_classes.update(player) set_max_hp(player, class.properties.max_hp) ctf_classes.set_skin(player, color, class) - physics.set(player:get_player_name(), "ctf_classes:speed", { + physics.set(player:get_player_name(), "ctf_classes:physics", { speed = class.properties.speed, + jump = class.properties.jump, + gravity = class.properties.gravity, }) crafting.lock_all(player:get_player_name()) diff --git a/mods/ctf/ctf_classes/classes.lua b/mods/ctf/ctf_classes/classes.lua index d8ecbf6..8211fd7 100644 --- a/mods/ctf/ctf_classes/classes.lua +++ b/mods/ctf/ctf_classes/classes.lua @@ -67,7 +67,7 @@ ctf_classes.register("shooter", { ctf_classes.register("medic", { description = "Medic", - pros = { "x2 regen for nearby friendlies", "+10% speed" }, + pros = { "x2 regen for nearby friendlies", "Building supplies", "+10% speed" }, cons = {}, color = "#0af", properties = { @@ -76,13 +76,27 @@ ctf_classes.register("medic", { initial_stuff = { "ctf_bandages:bandage 50", + "default:pick_steel", + "default:shovel_steel", + "default:cobble 99" + }, + + item_whitelist = { + "default:cobble" }, allowed_guns = { "shooter_guns:pistol", - "shooter_guns:machine_gun", - "shooter_guns:shotgun", }, + + crafting = { + "default:axe_bronze", + "default:axe_mese", + "default:axe_diamond", + "default:shovel_bronze", + "default:shovel_mese", + "default:shovel_diamond", + } }, }) diff --git a/mods/ctf/ctf_crafting/init.lua b/mods/ctf/ctf_crafting/init.lua index 3fb04a0..29fae19 100644 --- a/mods/ctf/ctf_crafting/init.lua +++ b/mods/ctf/ctf_crafting/init.lua @@ -248,22 +248,32 @@ crafting.register_recipe({ -- Shovels for ore, ore_item in pairs(full_ores) do + local show = true + if ore == "diamond" or ore == "mese" or ore == "bronze" then + show = false + end + crafting.register_recipe({ type = "inv", output = "default:shovel_" .. ore, items = { "default:stick 2", ore_item }, - always_known = true, + always_known = show, level = 1, }) end -- Axes for ore, ore_item in pairs(full_ores) do + local show = true + if ore == "diamond" or ore == "mese" or ore == "bronze" then + show = false + end + crafting.register_recipe({ type = "inv", output = "default:axe_" .. ore, - items = { "default:stick 2", ore_item .. " 3" }, - always_known = true, + items = { "default:stick 2", ore_item}, + always_known = show, level = 1, }) end