2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_bow("bow_wood", {
|
|
|
|
itemcraft = "default:wood",
|
|
|
|
description = "Wooden Bow",
|
|
|
|
texture = "throwing_bow_wood.png"
|
|
|
|
})
|
|
|
|
throwing.register_bow("bow_stone", {
|
|
|
|
itemcraft = "default:cobble",
|
|
|
|
description = "Stone Bow",
|
|
|
|
texture = "throwing_bow_stone.png"
|
|
|
|
})
|
|
|
|
throwing.register_bow("bow_steel", {
|
|
|
|
itemcraft = "default:steel_ingot",
|
|
|
|
description = "Steel Bow",
|
|
|
|
texture = "throwing_bow_steel.png"
|
|
|
|
})
|
|
|
|
throwing.register_bow("bow_bronze", {
|
|
|
|
itemcraft = "default:bronze_ingot",
|
|
|
|
description = "Bronze Bow",
|
|
|
|
texture = "throwing_bow_bronze.png"
|
|
|
|
})
|
|
|
|
throwing.register_bow("bow_mese", {
|
|
|
|
itemcraft = "default:mese_crystal",
|
|
|
|
description = "Mese Bow",
|
|
|
|
texture = "throwing_bow_mese.png"
|
|
|
|
})
|
|
|
|
throwing.register_bow("bow_diamond", {
|
|
|
|
itemcraft = "default:diamond",
|
|
|
|
description = "Diamond Bow",
|
|
|
|
texture = "throwing_bow_diamond.png"
|
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
|
|
|
|
local function get_setting(name)
|
|
|
|
local value = minetest.setting_getbool("throwing.enable_"..name)
|
|
|
|
if value == true or value == nil then
|
|
|
|
return true
|
|
|
|
else
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if get_setting("arrow") then
|
2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_arrow("arrow", {
|
|
|
|
itemcraft = "default:steel_ingot",
|
|
|
|
craft_quantity = 16,
|
|
|
|
description = "Arrow",
|
|
|
|
tiles = {"throwing_arrow.png", "throwing_arrow.png", "throwing_arrow_back.png", "throwing_arrow_front.png", "throwing_arrow_2.png", "throwing_arrow.png"},
|
|
|
|
target = throwing.target_object,
|
|
|
|
on_hit_sound = "throwing_arrow",
|
|
|
|
on_hit = function(pos, _, _, object, hitter)
|
|
|
|
object:punch(hitter, 1, {
|
|
|
|
full_punch_interval = 1,
|
|
|
|
damage_groups = {fleshy = 3}
|
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
2017-01-17 17:43:10 +01:00
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if get_setting("golden_arrow") then
|
2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_arrow("arrow_gold", {
|
|
|
|
itemcraft = "default:gold_ingot",
|
|
|
|
craft_quantity = 16,
|
|
|
|
description = "Golden Arrow",
|
|
|
|
tiles = {"throwing_arrow_gold.png", "throwing_arrow_gold.png", "throwing_arrow_gold_back.png", "throwing_arrow_gold_front.png", "throwing_arrow_gold_2.png", "throwing_arrow_gold.png"},
|
|
|
|
target = throwing.target_object,
|
|
|
|
on_hit_sound = "throwing_arrow",
|
|
|
|
on_hit = function(pos, _, _, object, hitter)
|
|
|
|
object:punch(hitter, 1, {
|
|
|
|
full_punch_interval = 1,
|
|
|
|
damage_groups = {fleshy = 5}
|
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
2017-01-17 17:43:10 +01:00
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if get_setting("dig_arrow") then
|
2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_arrow("arrow_dig", {
|
|
|
|
itemcraft = "default:pick_wood",
|
|
|
|
description = "Dig Arrow",
|
|
|
|
tiles = {"throwing_arrow_dig.png", "throwing_arrow_dig.png", "throwing_arrow_dig_back.png", "throwing_arrow_dig_front.png", "throwing_arrow_dig_2.png", "throwing_arrow_dig.png"},
|
|
|
|
target = throwing.target_node,
|
|
|
|
on_hit_sound = "throwing_dig_arrow",
|
|
|
|
on_hit = function(pos, _, node, _, hitter)
|
|
|
|
return minetest.dig_node(pos)
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
2017-01-17 17:43:10 +01:00
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if get_setting("dig_arrow_admin") then
|
2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_arrow("arrow_dig_admin", {
|
|
|
|
description = "Admin Dig Arrow",
|
|
|
|
tiles = {"throwing_arrow_dig.png", "throwing_arrow_dig.png", "throwing_arrow_dig_back.png", "throwing_arrow_dig_front.png", "throwing_arrow_dig_2.png", "throwing_arrow_dig.png"},
|
|
|
|
target = throwing.target_node,
|
|
|
|
on_hit = function(pos, _, node, _, _)
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
end,
|
|
|
|
groups = {not_in_creative_inventory = 1}
|
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if get_setting("teleport_arrow") then
|
2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_arrow("arrow_teleport", {
|
|
|
|
itemcraft = "default:diamond",
|
|
|
|
description = "Teleport Arrow",
|
|
|
|
tiles = {"throwing_arrow_teleport.png", "throwing_arrow_teleport.png", "throwing_arrow_teleport_back.png", "throwing_arrow_teleport_front.png", "throwing_arrow_teleport_2.png", "throwing_arrow_teleport.png"},
|
|
|
|
on_hit_sound = "throwing_teleport_arrow",
|
|
|
|
on_hit = function(_, last_pos, _, _, hitter)
|
|
|
|
if minetest.get_node(last_pos).name ~= "air" then
|
|
|
|
minetest.log("warning", "[throwing] BUG: node at last_pos was not air")
|
|
|
|
return
|
|
|
|
end
|
2017-01-04 18:53:37 +01:00
|
|
|
|
2017-01-17 17:43:10 +01:00
|
|
|
hitter:moveto(last_pos)
|
|
|
|
end
|
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if get_setting("fire_arrow") then
|
2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_arrow("arrow_fire", {
|
|
|
|
itemcraft = "default:torch",
|
|
|
|
description = "Torch Arrow",
|
|
|
|
tiles = {"throwing_arrow_fire.png", "throwing_arrow_fire.png", "throwing_arrow_fire_back.png", "throwing_arrow_fire_front.png", "throwing_arrow_fire_2.png", "throwing_arrow_fire.png"},
|
|
|
|
on_hit_sound = "default_place_node",
|
|
|
|
on_hit = function(_, last_pos, _, _, hitter)
|
|
|
|
if minetest.get_node(last_pos).name ~= "air" then
|
|
|
|
minetest.log("warning", "[throwing] BUG: node at last_pos was not air")
|
|
|
|
return
|
|
|
|
end
|
2017-01-12 20:49:42 +01:00
|
|
|
|
2017-01-17 17:43:10 +01:00
|
|
|
local under_node_name = minetest.get_node({x = last_pos.x, y = last_pos.y-1, z = last_pos.z}).name
|
|
|
|
if under_node_name ~= "air" and name ~= "ignore" then
|
|
|
|
minetest.place_node(last_pos, {name="default:torch"})
|
|
|
|
else
|
|
|
|
return false, "Attached node default:torch can not be placed"
|
|
|
|
end
|
2017-01-12 20:49:42 +01:00
|
|
|
end
|
2017-01-17 17:43:10 +01:00
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
if get_setting("build_arrow") then
|
2017-01-17 17:43:10 +01:00
|
|
|
throwing.register_arrow("arrow_build", {
|
|
|
|
itemcraft = "default:obsidian_glass",
|
|
|
|
description = "Build Arrow",
|
|
|
|
tiles = {"throwing_arrow_build.png", "throwing_arrow_build.png", "throwing_arrow_build_back.png", "throwing_arrow_build_front.png", "throwing_arrow_build_2.png", "throwing_arrow_build.png"},
|
|
|
|
on_hit_sound = "throwing_build_arrow",
|
|
|
|
on_hit = function(_, last_pos, _, _, hitter)
|
|
|
|
if minetest.get_node(last_pos).name ~= "air" then
|
|
|
|
minetest.log("warning", "[throwing] BUG: node at last_pos was not air")
|
|
|
|
return
|
|
|
|
end
|
|
|
|
local playername = hitter:get_player_name()
|
|
|
|
if minetest.is_protected(last_pos, playername) then
|
|
|
|
minetest.record_protection_violation(last_pos, playername)
|
|
|
|
return false, "protected position"
|
|
|
|
end
|
|
|
|
return minetest.place_node(last_pos, {name="default:obsidian_glass"})
|
2017-01-15 13:05:05 +01:00
|
|
|
end
|
2017-01-17 17:43:10 +01:00
|
|
|
})
|
2017-01-04 18:53:37 +01:00
|
|
|
end
|