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 0000000..1e6f436 Binary files /dev/null and b/textures/grenades_gun_powder.png differ