2016-11-19 13:21:34 +01:00
|
|
|
fishing = {}
|
|
|
|
fishing.fish = {}
|
|
|
|
|
|
|
|
function fishing.register_fish(name, def)
|
|
|
|
minetest.register_craftitem(name, def)
|
|
|
|
table.insert(fishing.fish, name)
|
|
|
|
end
|
|
|
|
|
|
|
|
function fishing.get_fish()
|
|
|
|
return fishing.fish[math.random(#fishing.fish)]
|
|
|
|
end
|
|
|
|
|
2016-01-10 17:41:07 +01:00
|
|
|
minetest.register_craftitem("fishing:fishing_rod", {
|
|
|
|
description = "Fishing rod",
|
|
|
|
inventory_image = "fishing_fishing_rod.png",
|
|
|
|
wield_image = "fishing_fishing_rod_wield.png",
|
|
|
|
liquids_pointable = true,
|
|
|
|
range = 10.0,
|
|
|
|
on_use = function(itemstack, user, pointed_thing)
|
|
|
|
if pointed_thing.above then
|
|
|
|
if minetest.get_node(pointed_thing.under).name == "default:water_source" then
|
2016-11-19 13:21:34 +01:00
|
|
|
if skills.lvls[user:get_player_name()] and
|
|
|
|
(skills.lvls[user:get_player_name()]["hunter"] and
|
|
|
|
skills.lvls[user:get_player_name()]["hunter"] > 3) or
|
|
|
|
(skills.lvls[user:get_player_name()]["farmer"] and
|
|
|
|
skills.lvls[user:get_player_name()]["farmer"] > 3) then
|
2016-08-31 19:33:32 +02:00
|
|
|
if math.random(6) == 2 then
|
2016-11-19 13:21:34 +01:00
|
|
|
user:get_inventory():add_item("main", fishing.get_fish())
|
2016-08-31 19:33:32 +02:00
|
|
|
end
|
|
|
|
else
|
|
|
|
if math.random(10) == 2 then
|
2016-11-19 13:21:34 +01:00
|
|
|
user:get_inventory():add_item("main", fishing.get_fish())
|
2016-08-31 19:33:32 +02:00
|
|
|
end
|
2016-01-10 17:41:07 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "fishing:fishing_rod",
|
|
|
|
recipe = {
|
2016-02-20 12:13:32 +01:00
|
|
|
{"default:stick", "default:string", ""},
|
|
|
|
{"default:stick", "default:string", ""},
|
|
|
|
{"default:stick", "default:string", ""},
|
2016-01-10 17:41:07 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2016-12-19 09:37:31 +01:00
|
|
|
-- fish
|
|
|
|
|
2016-11-19 13:21:34 +01:00
|
|
|
fishing.register_fish("fishing:fish", {
|
2016-01-10 17:41:07 +01:00
|
|
|
description = "Fish",
|
|
|
|
inventory_image = "fishing_fish.png",
|
2016-01-24 12:42:37 +01:00
|
|
|
on_use = minetest.item_eat(3),
|
2016-01-10 17:41:07 +01:00
|
|
|
})
|
2016-11-19 13:21:34 +01:00
|
|
|
|
|
|
|
fishing.register_fish("fishing:fish_1", {
|
|
|
|
description = "Fish",
|
|
|
|
inventory_image = "fishing_fish_1.png",
|
|
|
|
on_use = minetest.item_eat(4),
|
|
|
|
})
|
|
|
|
|
|
|
|
fishing.register_fish("fishing:fish_2", {
|
|
|
|
description = "Fish",
|
|
|
|
inventory_image = "fishing_fish_2.png",
|
|
|
|
on_use = minetest.item_eat(2),
|
|
|
|
})
|
2016-12-19 09:37:31 +01:00
|
|
|
|
|
|
|
-- cooked fish
|
|
|
|
|
|
|
|
fishing.register_fish("fishing:cooked_fish", {
|
|
|
|
description = "Cooked Fish",
|
|
|
|
inventory_image = "fishing_cooked_fish.png",
|
|
|
|
on_use = minetest.item_eat(6),
|
|
|
|
})
|
|
|
|
|
|
|
|
furnace.register_recipe({
|
|
|
|
input = "fishing:fish",
|
|
|
|
output = "fishing:cooked_fish",
|
|
|
|
})
|