From 3606178b961c39d9acf07774d32cfeb25b4fe7ff Mon Sep 17 00:00:00 2001 From: LoneWolfHT Date: Fri, 23 Nov 2018 12:36:37 -0800 Subject: [PATCH] Add crafting recipes and afew other things --- grenades.lua | 28 +++++++++++++++++++++++++++- init.lua | 13 +++++++++++++ settingtypes.txt | 5 ++++- textures/grenades_gun_powder.png | Bin 0 -> 180 bytes 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 textures/grenades_gun_powder.png diff --git a/grenades.lua b/grenades.lua index 15bf5a6..dd1cdf8 100644 --- a/grenades.lua +++ b/grenades.lua @@ -4,6 +4,17 @@ local regular = settings:get_bool("enable_regular_grenade") local flash = settings:get_bool("enable_flashbang_grenade") local smoke = settings:get_bool("enable_smoke_grenade") +minetest.register_craftitem("grenades:gun_powder", { + description = "A dark powder used for crafting smoke grenades", + inventory_image = "grenades_gun_powder.png" +}) + +minetest.register_craft({ + type = "shapeless", + output = "grenades:gun_powder", + recipe = {"default:coal_lump", "default:coal_lump", "default:coal_lump", "default:coal_lump"}, +}) + if not regular or regular == true then grenades.register_grenade("regular", { description = "A regular grenade (Kills anyone near where it explodes)", @@ -36,6 +47,11 @@ if not regular or regular == true then end end end, + recipe = { + {"", "default:steel_ingot", ""}, + {"default:steel_ingot", "default:coal_lump", "default:steel_ingot"}, + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"} + }, timeout = 3 }) end @@ -68,12 +84,17 @@ if not flash or flash == true then end end end, + recipe = { + {"", "default:steel_ingot", ""}, + {"default:steel_ingot", "default:torch", "default:steel_ingot"}, + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"} + }, timeout = 3 }) end if not smoke or smoke == true then - grenades.register_grenade("smoke_greande", { + grenades.register_grenade("smoke", { description = "A smoke grenade (Generates a lot of smoke around the detonation area)", image = "grenades_smoke_grenade.png", on_explode = function(pos, player, self) @@ -98,6 +119,11 @@ if not smoke or smoke == true then }) end end, + recipe = { + {"", "default:steel_ingot", ""}, + {"default:steel_ingot", "grenades:gun_powder", "default:steel_ingot"}, + {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"} + }, timeout = 3 }) end diff --git a/init.lua b/init.lua index ae359bb..f2fedf3 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,5 @@ +local settings = minetest.settings + grenades = {} local function throw_grenade(name, player) @@ -14,6 +16,8 @@ local function throw_grenade(name, player) end function grenades.register_grenade(name, def) + if not def.type then def.type = "shaped" end + local grenade_entity = { physical = true, timer = 0, @@ -80,6 +84,15 @@ function grenades.register_grenade(name, def) return itemstack end }) + + if def.recipe and (not settings:get_bool("enable_grenade_recipes") or + settings:get_bool("enable_grenade_recipes") == true) then + minetest.register_craft({ + type = def.type, + output = "grenades:grenade_"..name, + recipe = def.recipe + }) + end end dofile(minetest.get_modpath("grenades").."/grenades.lua") diff --git a/settingtypes.txt b/settingtypes.txt index 152efa5..2da940f 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -5,4 +5,7 @@ enable_regular_grenade (Add a regular grenade to the world) bool true enable_flashbang_grenade (Add a flashbang grenade to the world) bool true #Add a smoke grenade -enable_smoke_grenade (Add a smoke grenade to the world) bool true \ No newline at end of file +enable_smoke_grenade (Add a smoke grenade to the world) bool true + +#Enable Recipes +enable_grenade_recipes (Gives enabled grenades cafting recipes) bool true \ No newline at end of file diff --git a/textures/grenades_gun_powder.png b/textures/grenades_gun_powder.png new file mode 100644 index 0000000000000000000000000000000000000000..1e6f436363460d01da0d03d08b6b1bde2fad3713 GIT binary patch literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf_({9+Z)B&*;42Td}ILnnwj?0RN(r@{3P%Y#Rc^jBofh^(2J>vKluj;vCX z&2fphDsem^ra^NO_8GsK6W7joMos1rn}3|&%0FRe)0)?uV|u1klykAX`kLFjzF#{t aKQZy&bgHWiD*O+$mci52&t;ucLK6U9Zb5ti literal 0 HcmV?d00001