Separate weapons and API

Use less generic mod names to avoid conflicts
This commit is contained in:
BrunoMine 2017-07-13 09:33:00 -03:00 committed by stujones11
parent 0533d52142
commit edb19cf061
68 changed files with 134 additions and 102 deletions

View file

@ -1,26 +0,0 @@
local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/shooter.lua")
if SHOOTER_ENABLE_CROSSBOW == true then
dofile(modpath.."/crossbow.lua")
end
if SHOOTER_ENABLE_GUNS == true then
dofile(modpath.."/guns.lua")
end
if SHOOTER_ENABLE_FLARES == true then
dofile(modpath.."/flaregun.lua")
end
if SHOOTER_ENABLE_HOOK == true then
dofile(modpath.."/grapple.lua")
end
if SHOOTER_ENABLE_GRENADES == true then
dofile(modpath.."/grenade.lua")
end
if SHOOTER_ENABLE_ROCKETS == true then
dofile(modpath.."/rocket.lua")
end
if SHOOTER_ENABLE_TURRETS == true then
dofile(modpath.."/turret.lua")
end

1
modpack.txt Normal file
View file

@ -0,0 +1 @@
The presence of this file indicates that the current folder is a modpack.

7
shooter/init.lua Normal file
View file

@ -0,0 +1,7 @@
local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/api.lua")

View file

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 175 KiB

View file

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 268 B

View file

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View file

Before

Width:  |  Height:  |  Size: 157 B

After

Width:  |  Height:  |  Size: 157 B

View file

Before

Width:  |  Height:  |  Size: 659 B

After

Width:  |  Height:  |  Size: 659 B

View file

@ -0,0 +1,2 @@
wool
shooter

View file

@ -2,7 +2,7 @@ SHOOTER_CROSSBOW_USES = 50
SHOOTER_ARROW_TOOL_CAPS = {damage_groups={fleshy=2}} SHOOTER_ARROW_TOOL_CAPS = {damage_groups={fleshy=2}}
SHOOTER_ARROW_LIFETIME = 180 -- 3 minutes SHOOTER_ARROW_LIFETIME = 180 -- 3 minutes
minetest.register_alias("shooter:arrow", "shooter:arrow_white") minetest.register_alias("shooter_crossbow:arrow", "shooter_crossbow:arrow_white")
minetest.register_alias("shooter:crossbow_loaded", "shooter:crossbow_loaded_white") minetest.register_alias("shooter:crossbow_loaded", "shooter:crossbow_loaded_white")
local dye_basecolors = (dye and dye.basecolors) or local dye_basecolors = (dye and dye.basecolors) or
@ -30,7 +30,7 @@ local function get_texture(name, colour)
return "shooter_"..name..".png^wool_"..colour..".png^shooter_"..name..".png^[makealpha:255,126,126" return "shooter_"..name..".png^wool_"..colour..".png^shooter_"..name..".png^[makealpha:255,126,126"
end end
minetest.register_entity("shooter:arrow_entity", { minetest.register_entity("shooter_crossbow:arrow_entity", {
physical = false, physical = false,
visual = "mesh", visual = "mesh",
mesh = "shooter_arrow.b3d", mesh = "shooter_arrow.b3d",
@ -84,7 +84,7 @@ minetest.register_entity("shooter:arrow_entity", {
on_punch = function(self, puncher) on_punch = function(self, puncher)
if puncher then if puncher then
if puncher:is_player() then if puncher:is_player() then
local stack = "shooter:arrow_"..self.color local stack = "shooter_crossbow:arrow_"..self.color
local inv = puncher:get_inventory() local inv = puncher:get_inventory()
if inv:room_for_item("main", stack) then if inv:room_for_item("main", stack) then
inv:add_item("main", stack) inv:add_item("main", stack)
@ -169,11 +169,11 @@ minetest.register_entity("shooter:arrow_entity", {
}) })
for _, color in pairs(dye_basecolors) do for _, color in pairs(dye_basecolors) do
minetest.register_craftitem("shooter:arrow_"..color, { minetest.register_craftitem("shooter_crossbow:arrow_"..color, {
description = color:gsub("%a", string.upper, 1).." Arrow", description = color:gsub("%a", string.upper, 1).." Arrow",
inventory_image = get_texture("arrow_inv", color), inventory_image = get_texture("arrow_inv", color),
}) })
minetest.register_tool("shooter:crossbow_loaded_"..color, { minetest.register_tool("shooter_crossbow:crossbow_loaded_"..color, {
description = "Crossbow", description = "Crossbow",
inventory_image = get_texture("crossbow_loaded", color), inventory_image = get_texture("crossbow_loaded", color),
groups = {not_in_creative_inventory=1}, groups = {not_in_creative_inventory=1},
@ -182,13 +182,13 @@ for _, color in pairs(dye_basecolors) do
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/SHOOTER_CROSSBOW_USES) itemstack:add_wear(65535/SHOOTER_CROSSBOW_USES)
end end
itemstack = "shooter:crossbow 1 "..itemstack:get_wear() itemstack = "shooter_crossbow:crossbow 1 "..itemstack:get_wear()
local pos = user:getpos() local pos = user:getpos()
local dir = user:get_look_dir() local dir = user:get_look_dir()
local yaw = user:get_look_yaw() local yaw = user:get_look_yaw()
if pos and dir and yaw then if pos and dir and yaw then
pos.y = pos.y + 1.5 pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "shooter:arrow_entity") local obj = minetest.add_entity(pos, "shooter_crossbow:arrow_entity")
local ent = nil local ent = nil
if obj then if obj then
ent = obj:get_luaentity() ent = obj:get_luaentity()
@ -235,27 +235,27 @@ for _, color in pairs(dye_basecolors) do
}) })
end end
minetest.register_tool("shooter:crossbow", { minetest.register_tool("shooter_crossbow:crossbow", {
description = "Crossbow", description = "Crossbow",
inventory_image = "shooter_crossbow.png", inventory_image = "shooter_crossbow.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local inv = user:get_inventory() local inv = user:get_inventory()
local stack = inv:get_stack("main", user:get_wield_index() + 1) local stack = inv:get_stack("main", user:get_wield_index() + 1)
local color = string.match(stack:get_name(), "shooter:arrow_(%a+)") local color = string.match(stack:get_name(), "shooter_crossbow:arrow_(%a+)")
if color then if color then
minetest.sound_play("shooter_reload", {object=user}) minetest.sound_play("shooter_reload", {object=user})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "shooter:arrow_"..color.." 1") inv:remove_item("main", "shooter_crossbow:arrow_"..color.." 1")
end end
return "shooter:crossbow_loaded_"..color.." 1 "..itemstack:get_wear() return "shooter_crossbow:crossbow_loaded_"..color.." 1 "..itemstack:get_wear()
end end
for _, color in pairs(dye_basecolors) do for _, color in pairs(dye_basecolors) do
if inv:contains_item("main", "shooter:arrow_"..color) then if inv:contains_item("main", "shooter_crossbow:arrow_"..color) then
minetest.sound_play("shooter_reload", {object=user}) minetest.sound_play("shooter_reload", {object=user})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "shooter:arrow_"..color.." 1") inv:remove_item("main", "shooter_crossbow:arrow_"..color.." 1")
end end
return "shooter:crossbow_loaded_"..color.." 1 "..itemstack:get_wear() return "shooter_crossbow:crossbow_loaded_"..color.." 1 "..itemstack:get_wear()
end end
end end
minetest.sound_play("shooter_click", {object=user}) minetest.sound_play("shooter_click", {object=user})
@ -264,7 +264,7 @@ minetest.register_tool("shooter:crossbow", {
if SHOOTER_ENABLE_CRAFTING == true then if SHOOTER_ENABLE_CRAFTING == true then
minetest.register_craft({ minetest.register_craft({
output = "shooter:crossbow", output = "shooter_crossbow:crossbow",
recipe = { recipe = {
{"default:stick", "default:stick", "default:stick"}, {"default:stick", "default:stick", "default:stick"},
{"default:stick", "default:stick", ""}, {"default:stick", "default:stick", ""},
@ -272,7 +272,7 @@ if SHOOTER_ENABLE_CRAFTING == true then
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:arrow_white", output = "shooter_crossbow:arrow_white",
recipe = { recipe = {
{"default:steel_ingot", "", ""}, {"default:steel_ingot", "", ""},
{"", "default:stick", "default:paper"}, {"", "default:stick", "default:paper"},
@ -282,12 +282,19 @@ if SHOOTER_ENABLE_CRAFTING == true then
for _, color in pairs(dye_basecolors) do for _, color in pairs(dye_basecolors) do
if color ~= "white" then if color ~= "white" then
minetest.register_craft({ minetest.register_craft({
output = "shooter:arrow_"..color, output = "shooter_crossbow:arrow_"..color,
recipe = { recipe = {
{"", "dye:"..color, "shooter:arrow_white"}, {"", "dye:"..color, "shooter_crossbow:arrow_white"},
}, },
}) })
end end
end end
end end
--Backwards compatibility
minetest.register_alias("shooter:crossbow", "shooter_crossbow:crossbow")
for _, color in pairs(dye_basecolors) do
minetest.register_alias("shooter:arrow_"..color, "shooter_crossbow:arrow_"..color)
minetest.register_alias("shooter:crossbow_loaded_"..color, "shooter_crossbow:crossbow_loaded_"..color)
end

View file

Before

Width:  |  Height:  |  Size: 234 B

After

Width:  |  Height:  |  Size: 234 B

View file

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 290 B

View file

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 500 B

View file

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 389 B

View file

@ -0,0 +1,3 @@
tnt
wool
shooter

View file

@ -1,9 +1,9 @@
minetest.register_craftitem("shooter:flare", { minetest.register_craftitem("shooter_flaregun:flare", {
description = "Flare", description = "Flare",
inventory_image = "shooter_flare_inv.png", inventory_image = "shooter_flare_inv.png",
}) })
minetest.register_node("shooter:flare_light", { minetest.register_node("shooter_flaregun:flare_light", {
drawtype = "glasslike", drawtype = "glasslike",
tiles = {"shooter_flare_light.png"}, tiles = {"shooter_flare_light.png"},
paramtype = "light", paramtype = "light",
@ -17,7 +17,7 @@ minetest.register_node("shooter:flare_light", {
}) })
minetest.register_abm({ minetest.register_abm({
nodenames = "shooter:flare_light", nodenames = "shooter_flaregun:flare_light",
interval = 5, interval = 5,
chance = 1, chance = 1,
action = function(pos, node) action = function(pos, node)
@ -34,7 +34,7 @@ minetest.register_abm({
end, end,
}) })
minetest.register_entity("shooter:flare_entity", { minetest.register_entity("shooter_flaregun:flare_entity", {
physical = true, physical = true,
timer = 0, timer = 0,
visual = "cube", visual = "cube",
@ -66,7 +66,7 @@ minetest.register_entity("shooter:flare_entity", {
if minetest.get_node(pos).name == "air" and if minetest.get_node(pos).name == "air" and
node.name ~= "default:water_source" and node.name ~= "default:water_source" and
node.name ~= "default:water_flowing" then node.name ~= "default:water_flowing" then
minetest.place_node(pos, {name="shooter:flare_light"}) minetest.place_node(pos, {name="shooter_flaregun:flare_light"})
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
pos.y = pos.y - 0.1 pos.y = pos.y - 0.1
local id = minetest.add_particlespawner( local id = minetest.add_particlespawner(
@ -95,12 +95,12 @@ minetest.register_entity("shooter:flare_entity", {
end, end,
}) })
minetest.register_tool("shooter:flaregun", { minetest.register_tool("shooter_flaregun:flaregun", {
description = "Flare Gun", description = "Flare Gun",
inventory_image = "shooter_flaregun.png", inventory_image = "shooter_flaregun.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local inv = user:get_inventory() local inv = user:get_inventory()
if not inv:contains_item("main", "shooter:flare") then if not inv:contains_item("main", "shooter_flaregun:flare") then
minetest.sound_play("shooter_click", {object=user}) minetest.sound_play("shooter_click", {object=user})
return itemstack return itemstack
end end
@ -113,7 +113,7 @@ minetest.register_tool("shooter:flaregun", {
local yaw = user:get_look_yaw() local yaw = user:get_look_yaw()
if pos and dir and yaw then if pos and dir and yaw then
pos.y = pos.y + 1.5 pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "shooter:flare_entity") local obj = minetest.add_entity(pos, "shooter_flaregun:flare_entity")
if obj then if obj then
minetest.sound_play("shooter_flare_fire", {object=obj}) minetest.sound_play("shooter_flare_fire", {object=obj})
obj:setvelocity({x=dir.x * 16, y=dir.y * 16, z=dir.z * 16}) obj:setvelocity({x=dir.x * 16, y=dir.y * 16, z=dir.z * 16})
@ -131,13 +131,13 @@ minetest.register_tool("shooter:flaregun", {
if SHOOTER_ENABLE_CRAFTING == true then if SHOOTER_ENABLE_CRAFTING == true then
minetest.register_craft({ minetest.register_craft({
output = "shooter:flare", output = "shooter_flaregun:flare",
recipe = { recipe = {
{"tnt:gunpowder", "wool:red"}, {"tnt:gunpowder", "wool:red"},
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:flaregun", output = "shooter_flaregun:flaregun",
recipe = { recipe = {
{"wool:red", "wool:red", "wool:red"}, {"wool:red", "wool:red", "wool:red"},
{"", "", "default:steel_ingot"} {"", "", "default:steel_ingot"}
@ -145,3 +145,7 @@ if SHOOTER_ENABLE_CRAFTING == true then
}) })
end end
--Backwards compatibility
minetest.register_alias("shooter:flaregun", "shooter_flaregun:flaregun")
minetest.register_alias("shooter:flare", "shooter_flaregun:flare")

View file

Before

Width:  |  Height:  |  Size: 173 B

After

Width:  |  Height:  |  Size: 173 B

View file

Before

Width:  |  Height:  |  Size: 278 B

After

Width:  |  Height:  |  Size: 278 B

View file

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 291 B

View file

Before

Width:  |  Height:  |  Size: 310 B

After

Width:  |  Height:  |  Size: 310 B

View file

Before

Width:  |  Height:  |  Size: 498 B

After

Width:  |  Height:  |  Size: 498 B

View file

@ -0,0 +1,2 @@
tnt
shooter

View file

@ -1,4 +1,4 @@
minetest.register_entity("shooter:grenade_entity", { minetest.register_entity("shooter_grenade:grenade_entity", {
physical = false, physical = false,
timer = 0, timer = 0,
visual = "cube", visual = "cube",
@ -35,7 +35,7 @@ minetest.register_entity("shooter:grenade_entity", {
end, end,
}) })
minetest.register_tool("shooter:grenade", { minetest.register_tool("shooter_grenade:grenade", {
description = "Grenade", description = "Grenade",
inventory_image = "shooter_hand_grenade.png", inventory_image = "shooter_hand_grenade.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
@ -54,7 +54,7 @@ minetest.register_tool("shooter:grenade", {
local yaw = user:get_look_yaw() local yaw = user:get_look_yaw()
if pos and dir then if pos and dir then
pos.y = pos.y + 1.5 pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "shooter:grenade_entity") local obj = minetest.add_entity(pos, "shooter_grenade:grenade_entity")
if obj then if obj then
obj:setvelocity({x=dir.x * 15, y=dir.y * 15, z=dir.z * 15}) obj:setvelocity({x=dir.x * 15, y=dir.y * 15, z=dir.z * 15})
obj:setacceleration({x=dir.x * -3, y=-10, z=dir.z * -3}) obj:setacceleration({x=dir.x * -3, y=-10, z=dir.z * -3})
@ -71,10 +71,13 @@ minetest.register_tool("shooter:grenade", {
if SHOOTER_ENABLE_CRAFTING == true then if SHOOTER_ENABLE_CRAFTING == true then
minetest.register_craft({ minetest.register_craft({
output = "shooter:grenade", output = "shooter_grenade:grenade",
recipe = { recipe = {
{"tnt:gunpowder", "default:steel_ingot"}, {"tnt:gunpowder", "default:steel_ingot"},
}, },
}) })
end end
--Backwards compatibility
minetest.register_alias("shooter:grenade", "shooter_grenade:grenade")

View file

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View file

Before

Width:  |  Height:  |  Size: 381 B

After

Width:  |  Height:  |  Size: 381 B

2
shooter_guns/depends.txt Normal file
View file

@ -0,0 +1,2 @@
tnt
shooter

View file

@ -1,4 +1,4 @@
shooter:register_weapon("shooter:pistol", { shooter:register_weapon("shooter_guns:pistol", {
description = "Pistol", description = "Pistol",
inventory_image = "shooter_pistol.png", inventory_image = "shooter_pistol.png",
rounds = 200, rounds = 200,
@ -12,7 +12,7 @@ shooter:register_weapon("shooter:pistol", {
}, },
}) })
shooter:register_weapon("shooter:rifle", { shooter:register_weapon("shooter_guns:rifle", {
description = "Rifle", description = "Rifle",
inventory_image = "shooter_rifle.png", inventory_image = "shooter_rifle.png",
rounds = 100, rounds = 100,
@ -26,7 +26,7 @@ shooter:register_weapon("shooter:rifle", {
}, },
}) })
shooter:register_weapon("shooter:shotgun", { shooter:register_weapon("shooter_guns:shotgun", {
description = "Shotgun", description = "Shotgun",
inventory_image = "shooter_shotgun.png", inventory_image = "shooter_shotgun.png",
rounds = 50, rounds = 50,
@ -40,7 +40,7 @@ shooter:register_weapon("shooter:shotgun", {
}, },
}) })
shooter:register_weapon("shooter:machine_gun", { shooter:register_weapon("shooter_guns:machine_gun", {
description = "Sub Machine Gun", description = "Sub Machine Gun",
inventory_image = "shooter_smgun.png", inventory_image = "shooter_smgun.png",
rounds = 50, rounds = 50,
@ -55,21 +55,21 @@ shooter:register_weapon("shooter:machine_gun", {
}, },
}) })
minetest.register_craftitem("shooter:ammo", { minetest.register_craftitem("shooter_guns:ammo", {
description = "Ammo pack", description = "Ammo pack",
inventory_image = "shooter_ammo.png", inventory_image = "shooter_ammo.png",
}) })
if SHOOTER_ENABLE_CRAFTING == true then if SHOOTER_ENABLE_CRAFTING == true then
minetest.register_craft({ minetest.register_craft({
output = "shooter:pistol 1 65535", output = "shooter_guns:pistol 1 65535",
recipe = { recipe = {
{"default:steel_ingot", "default:steel_ingot"}, {"default:steel_ingot", "default:steel_ingot"},
{"", "default:mese_crystal"}, {"", "default:mese_crystal"},
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:rifle 1 65535", output = "shooter_guns:rifle 1 65535",
recipe = { recipe = {
{"default:steel_ingot", "", ""}, {"default:steel_ingot", "", ""},
{"", "default:bronze_ingot", ""}, {"", "default:bronze_ingot", ""},
@ -77,7 +77,7 @@ if SHOOTER_ENABLE_CRAFTING == true then
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:shotgun 1 65535", output = "shooter_guns:shotgun 1 65535",
recipe = { recipe = {
{"default:steel_ingot", "", ""}, {"default:steel_ingot", "", ""},
{"", "default:steel_ingot", ""}, {"", "default:steel_ingot", ""},
@ -85,15 +85,15 @@ if SHOOTER_ENABLE_CRAFTING == true then
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:machine_gun 1 65535", output = "shooter_guns:machine_gun 1 65535",
recipe = { recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, {"shooter_guns:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
{"", "default:bronze_ingot", "default:mese_crystal"}, {"", "default:bronze_ingot", "default:mese_crystal"},
{"", "default:bronze_ingot", ""}, {"", "default:bronze_ingot", ""},
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:ammo", output = "shooter_guns:ammo",
recipe = { recipe = {
{"tnt:gunpowder", "default:bronze_ingot"}, {"tnt:gunpowder", "default:bronze_ingot"},
}, },
@ -125,3 +125,10 @@ minetest.register_globalstep(function(dtime)
end end
end) end)
--Backwards compatibility
minetest.register_alias("shooter:shotgun", "shooter_guns:shotgun")
minetest.register_alias("shooter:pistol", "shooter_guns:pistol")
minetest.register_alias("shooter:machine_gun", "shooter_guns:machine_gun")
minetest.register_alias("shooter:rifle", "shooter_guns:rifle")
minetest.register_alias("shooter:ammo", "shooter_guns:ammo")

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 B

View file

Before

Width:  |  Height:  |  Size: 274 B

After

Width:  |  Height:  |  Size: 274 B

View file

Before

Width:  |  Height:  |  Size: 420 B

After

Width:  |  Height:  |  Size: 420 B

View file

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 402 B

View file

Before

Width:  |  Height:  |  Size: 289 B

After

Width:  |  Height:  |  Size: 289 B

2
shooter_hook/depends.txt Normal file
View file

@ -0,0 +1,2 @@
shooter
shooter_guns

View file

@ -8,7 +8,7 @@ local function throw_hook(itemstack, user, vel)
itemstack:add_wear(65535/100) itemstack:add_wear(65535/100)
end end
pos.y = pos.y + 1.5 pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "shooter:hook") local obj = minetest.add_entity(pos, "shooter_hook:hook")
if obj then if obj then
minetest.sound_play("shooter_throw", {object=obj}) minetest.sound_play("shooter_throw", {object=obj})
obj:setvelocity({x=dir.x * vel, y=dir.y * vel, z=dir.z * vel}) obj:setvelocity({x=dir.x * vel, y=dir.y * vel, z=dir.z * vel})
@ -23,12 +23,12 @@ local function throw_hook(itemstack, user, vel)
end end
end end
minetest.register_entity("shooter:hook", { minetest.register_entity("shooter_hook:hook", {
physical = true, physical = true,
timer = 0, timer = 0,
visual = "wielditem", visual = "wielditem",
visual_size = {x=1/2, y=1/2}, visual_size = {x=1/2, y=1/2},
textures = {"shooter:grapple_hook"}, textures = {"shooter_hook:grapple_hook"},
player = nil, player = nil,
itemstack = "", itemstack = "",
collisionbox = {-1/4,-1/4,-1/4, 1/4,1/4,1/4}, collisionbox = {-1/4,-1/4,-1/4, 1/4,1/4,1/4},
@ -67,7 +67,7 @@ minetest.register_entity("shooter:hook", {
end, end,
}) })
minetest.register_tool("shooter:grapple_hook", { minetest.register_tool("shooter_hook:grapple_hook", {
description = "Grappling Hook", description = "Grappling Hook",
inventory_image = "shooter_hook.png", inventory_image = "shooter_hook.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
@ -79,17 +79,17 @@ minetest.register_tool("shooter:grapple_hook", {
end, end,
}) })
minetest.register_tool("shooter:grapple_gun", { minetest.register_tool("shooter_hook:grapple_gun", {
description = "Grappling Gun", description = "Grappling Gun",
inventory_image = "shooter_hook_gun.png", inventory_image = "shooter_hook_gun.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local inv = user:get_inventory() local inv = user:get_inventory()
if inv:contains_item("main", "shooter:grapple_hook") and if inv:contains_item("main", "shooter_hook:grapple_hook") and
inv:contains_item("main", "tnt:gunpowder") then inv:contains_item("main", "tnt:gunpowder") then
inv:remove_item("main", "tnt:gunpowder") inv:remove_item("main", "tnt:gunpowder")
minetest.sound_play("shooter_reload", {object=user}) minetest.sound_play("shooter_reload", {object=user})
local stack = inv:remove_item("main", "shooter:grapple_hook") local stack = inv:remove_item("main", "shooter_hook:grapple_hook")
itemstack = "shooter:grapple_gun_loaded 1 "..stack:get_wear() itemstack = "shooter_hook:grapple_gun_loaded 1 "..stack:get_wear()
else else
minetest.sound_play("shooter_click", {object=user}) minetest.sound_play("shooter_click", {object=user})
end end
@ -97,7 +97,7 @@ minetest.register_tool("shooter:grapple_gun", {
end, end,
}) })
minetest.register_tool("shooter:grapple_gun_loaded", { minetest.register_tool("shooter_hook:grapple_gun_loaded", {
description = "Grappling Gun", description = "Grappling Gun",
inventory_image = "shooter_hook_gun_loaded.png", inventory_image = "shooter_hook_gun_loaded.png",
groups = {not_in_creative_inventory=1}, groups = {not_in_creative_inventory=1},
@ -106,15 +106,15 @@ minetest.register_tool("shooter:grapple_gun_loaded", {
return itemstack return itemstack
end end
minetest.sound_play("shooter_pistol", {object=user}) minetest.sound_play("shooter_pistol", {object=user})
itemstack = ItemStack("shooter:grapple_hook 1 "..itemstack:get_wear()) itemstack = ItemStack("shooter_hook:grapple_hook 1 "..itemstack:get_wear())
throw_hook(itemstack, user, 20) throw_hook(itemstack, user, 20)
return "shooter:grapple_gun" return "shooter_hook:grapple_gun"
end, end,
}) })
if SHOOTER_ENABLE_CRAFTING == true then if SHOOTER_ENABLE_CRAFTING == true then
minetest.register_craft({ minetest.register_craft({
output = "shooter:grapple_hook", output = "shooter_hook:grapple_hook",
recipe = { recipe = {
{"default:steel_ingot", "default:steel_ingot", "default:diamond"}, {"default:steel_ingot", "default:steel_ingot", "default:diamond"},
{"default:steel_ingot", "default:steel_ingot", ""}, {"default:steel_ingot", "default:steel_ingot", ""},
@ -122,7 +122,7 @@ if SHOOTER_ENABLE_CRAFTING == true then
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:grapple_gun", output = "shooter_hook:grapple_gun",
recipe = { recipe = {
{"", "default:steel_ingot", "default:steel_ingot"}, {"", "default:steel_ingot", "default:steel_ingot"},
{"", "", "default:diamond"}, {"", "", "default:diamond"},
@ -130,3 +130,7 @@ if SHOOTER_ENABLE_CRAFTING == true then
}) })
end end
--Backwards compatibility
minetest.register_alias("shooter:grapple_hook", "shooter_hook:grapple_hook")
minetest.register_alias("shooter:grapple_gun", "shooter_hook:grapple_gun")
minetest.register_alias("shooter:grapple_gun_loaded", "shooter_hook:grapple_gun_loaded")

View file

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 567 B

View file

Before

Width:  |  Height:  |  Size: 537 B

After

Width:  |  Height:  |  Size: 537 B

View file

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 569 B

View file

@ -0,0 +1,2 @@
tnt
shooter

View file

@ -1,10 +1,10 @@
minetest.register_craftitem("shooter:rocket", { minetest.register_craftitem("shooter_rocket:rocket", {
description = "Rocket", description = "Rocket",
stack_max = 1, stack_max = 1,
inventory_image = "shooter_rocket_inv.png", inventory_image = "shooter_rocket_inv.png",
}) })
minetest.register_entity("shooter:rocket_entity", { minetest.register_entity("shooter_rocket:rocket_entity", {
physical = false, physical = false,
timer = 0, timer = 0,
visual = "cube", visual = "cube",
@ -41,7 +41,7 @@ minetest.register_entity("shooter:rocket_entity", {
end, end,
}) })
minetest.register_tool("shooter:rocket_gun_loaded", { minetest.register_tool("shooter_rocket:rocket_gun_loaded", {
description = "Rocket Gun", description = "Rocket Gun",
inventory_image = "shooter_rocket_gun_loaded.png", inventory_image = "shooter_rocket_gun_loaded.png",
groups = {not_in_creative_inventory=1}, groups = {not_in_creative_inventory=1},
@ -49,7 +49,7 @@ minetest.register_tool("shooter:rocket_gun_loaded", {
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
itemstack:add_wear(65535/50) itemstack:add_wear(65535/50)
end end
itemstack = "shooter:rocket_gun 1 "..itemstack:get_wear() itemstack = "shooter_rocket:rocket_gun 1 "..itemstack:get_wear()
if pointed_thing.type ~= "nothing" then if pointed_thing.type ~= "nothing" then
local pointed = minetest.get_pointed_thing_position(pointed_thing) local pointed = minetest.get_pointed_thing_position(pointed_thing)
if vector.distance(user:getpos(), pointed) < 8 then if vector.distance(user:getpos(), pointed) < 8 then
@ -62,7 +62,7 @@ minetest.register_tool("shooter:rocket_gun_loaded", {
local yaw = user:get_look_yaw() local yaw = user:get_look_yaw()
if pos and dir and yaw then if pos and dir and yaw then
pos.y = pos.y + 1.5 pos.y = pos.y + 1.5
local obj = minetest.add_entity(pos, "shooter:rocket_entity") local obj = minetest.add_entity(pos, "shooter_rocket:rocket_entity")
if obj then if obj then
minetest.sound_play("shooter_rocket_fire", {object=obj}) minetest.sound_play("shooter_rocket_fire", {object=obj})
obj:setvelocity({x=dir.x * 20, y=dir.y * 20, z=dir.z * 20}) obj:setvelocity({x=dir.x * 20, y=dir.y * 20, z=dir.z * 20})
@ -78,17 +78,17 @@ minetest.register_tool("shooter:rocket_gun_loaded", {
end, end,
}) })
minetest.register_tool("shooter:rocket_gun", { minetest.register_tool("shooter_rocket:rocket_gun", {
description = "Rocket Gun", description = "Rocket Gun",
inventory_image = "shooter_rocket_gun.png", inventory_image = "shooter_rocket_gun.png",
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local inv = user:get_inventory() local inv = user:get_inventory()
if inv:contains_item("main", "shooter:rocket") then if inv:contains_item("main", "shooter_rocket:rocket") then
minetest.sound_play("shooter_reload", {object=user}) minetest.sound_play("shooter_reload", {object=user})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "shooter:rocket 1") inv:remove_item("main", "shooter_rocket:rocket 1")
end end
itemstack = "shooter:rocket_gun_loaded 1 "..itemstack:get_wear() itemstack = "shooter_rocket:rocket_gun_loaded 1 "..itemstack:get_wear()
else else
minetest.sound_play("shooter_click", {object=user}) minetest.sound_play("shooter_click", {object=user})
end end
@ -98,17 +98,23 @@ minetest.register_tool("shooter:rocket_gun", {
if SHOOTER_ENABLE_CRAFTING == true then if SHOOTER_ENABLE_CRAFTING == true then
minetest.register_craft({ minetest.register_craft({
output = "shooter:rocket_gun", output = "shooter_rocket:rocket_gun",
recipe = { recipe = {
{"default:bronze_ingot", "default:steel_ingot", "default:steel_ingot"}, {"default:bronze_ingot", "default:steel_ingot", "default:steel_ingot"},
{"", "", "default:diamond"}, {"", "", "default:diamond"},
}, },
}) })
minetest.register_craft({ minetest.register_craft({
output = "shooter:rocket", output = "shooter_rocket:rocket",
recipe = { recipe = {
{"default:bronze_ingot", "tnt:gunpowder", "default:bronze_ingot"}, {"default:bronze_ingot", "tnt:gunpowder", "default:bronze_ingot"},
}, },
}) })
end end
--Backwards compatibility
minetest.register_alias("shooter:rocket", "shooter_rocket:rocket")
minetest.register_alias("shooter:rocket_gun", "shooter_rocket:rocket_gun")
minetest.register_alias("shooter:rocket_gun_loaded", "shooter_rocket:rocket_gun_loaded")

View file

Before

Width:  |  Height:  |  Size: 690 B

After

Width:  |  Height:  |  Size: 690 B

View file

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 679 B

View file

Before

Width:  |  Height:  |  Size: 376 B

After

Width:  |  Height:  |  Size: 376 B

View file

@ -0,0 +1,2 @@
shooter
shooter_guns

View file

@ -4,7 +4,7 @@ local function get_turret_entity(pos)
for _, obj in ipairs(objects) do for _, obj in ipairs(objects) do
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
if ent then if ent then
if ent.name == "shooter:turret_entity" then if ent.name == "shooter_turret:turret_entity" then
-- Remove duplicates -- Remove duplicates
if entity then if entity then
obj:remove() obj:remove()
@ -17,7 +17,7 @@ local function get_turret_entity(pos)
return entity return entity
end end
minetest.register_entity("shooter:tnt_entity", { minetest.register_entity("shooter_turret:tnt_entity", {
physical = false, physical = false,
timer = 0, timer = 0,
visual = "cube", visual = "cube",
@ -53,7 +53,7 @@ minetest.register_entity("shooter:tnt_entity", {
end, end,
}) })
minetest.register_entity("shooter:turret_entity", { minetest.register_entity("shooter_turret:turret_entity", {
physical = true, physical = true,
visual = "mesh", visual = "mesh",
mesh = "shooter_turret.b3d", mesh = "shooter_turret.b3d",
@ -70,7 +70,7 @@ minetest.register_entity("shooter:turret_entity", {
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
self.pos = self.object:getpos() self.pos = self.object:getpos()
self.yaw = self.object:getyaw() self.yaw = self.object:getyaw()
if minetest.get_node(self.pos).name ~= "shooter:turret" then if minetest.get_node(self.pos).name ~= "shooter_turret:turret" then
self.object:remove() self.object:remove()
return return
end end
@ -147,7 +147,7 @@ minetest.register_entity("shooter:turret_entity", {
minetest.sound_play("shooter_click", {object=self.object}) minetest.sound_play("shooter_click", {object=self.object})
return return
end end
minetest.sound_play("shooter_shotgun", {object=self.object}) minetest.sound_play("guns_shotgun", {object=self.object})
if not minetest.setting_getbool("creative_mode") then if not minetest.setting_getbool("creative_mode") then
inv:remove_item("main", "tnt:tnt") inv:remove_item("main", "tnt:tnt")
end end
@ -160,7 +160,7 @@ minetest.register_entity("shooter:turret_entity", {
}) })
local pos = {x=self.pos.x, y=self.pos.y + 0.87, z=self.pos.z} local pos = {x=self.pos.x, y=self.pos.y + 0.87, z=self.pos.z}
pos = vector.add(pos, {x=dir.x * 1.5, y=dir.y * 1.5, z=dir.z * 1.5}) pos = vector.add(pos, {x=dir.x * 1.5, y=dir.y * 1.5, z=dir.z * 1.5})
local obj = minetest.add_entity(pos, "shooter:tnt_entity") local obj = minetest.add_entity(pos, "shooter_turret:tnt_entity")
if obj then if obj then
local ent = obj:get_luaentity() local ent = obj:get_luaentity()
if ent then if ent then
@ -183,7 +183,7 @@ minetest.register_entity("shooter:turret_entity", {
end end
}) })
minetest.register_node("shooter:turret", { minetest.register_node("shooter_turret:turret", {
description = "Turret Gun", description = "Turret Gun",
tiles = {"shooter_turret_base.png"}, tiles = {"shooter_turret_base.png"},
inventory_image = "shooter_turret_gun.png", inventory_image = "shooter_turret_gun.png",
@ -217,7 +217,7 @@ minetest.register_node("shooter:turret", {
local node = minetest.get_node({x=pos.x, y=pos.y + 1, z=pos.z}) local node = minetest.get_node({x=pos.x, y=pos.y + 1, z=pos.z})
if node.name == "air" then if node.name == "air" then
if not get_turret_entity(pos) then if not get_turret_entity(pos) then
minetest.add_entity(pos, "shooter:turret_entity") minetest.add_entity(pos, "shooter_turret:turret_entity")
end end
end end
end, end,
@ -255,7 +255,7 @@ minetest.register_node("shooter:turret", {
if SHOOTER_ENABLE_CRAFTING == true then if SHOOTER_ENABLE_CRAFTING == true then
minetest.register_craft({ minetest.register_craft({
output = "shooter:turret", output = "shooter_turret:turret",
recipe = { recipe = {
{"default:bronze_ingot", "default:bronze_ingot", "default:steel_ingot"}, {"default:bronze_ingot", "default:bronze_ingot", "default:steel_ingot"},
{"", "default:bronze_ingot", "default:steel_ingot"}, {"", "default:bronze_ingot", "default:steel_ingot"},
@ -264,3 +264,7 @@ if SHOOTER_ENABLE_CRAFTING == true then
}) })
end end
--Backward compatibility
minetest.register_alias("shooter:turret", "shooter_turret:turret")

View file

Before

Width:  |  Height:  |  Size: 178 B

After

Width:  |  Height:  |  Size: 178 B

View file

Before

Width:  |  Height:  |  Size: 354 B

After

Width:  |  Height:  |  Size: 354 B

View file

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 364 B