67 lines
1.8 KiB
Lua
Raw Normal View History

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
if math.random(6) == 2 then
2016-11-19 13:21:34 +01:00
user:get_inventory():add_item("main", fishing.get_fish())
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())
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-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),
})