1 local players_fishing = {}
3 minetest.register_craftitem("fishing:pole", {
4 description = "Fishing Pole",
5 inventory_image = "fishing_rod.png",
8 on_use = function(itemstack, user, pointed_thing)
9 --minetest.sound_play("reload_gun",{object=user, pitch = math.random(80,100)/100})
13 on_secondary_use = function(itemstack, user, pointed_thing)
14 if not players_fishing[name] then
15 local pos = user:get_pos()
16 local anchor = table.copy(pos)
18 --minetest.sound_play("gun_shot",{object=user, pitch = math.random(80,100)/100})
19 local dir = user:get_look_dir()
20 local force = vector.multiply(dir,20)
21 local name = user:get_player_name()
22 local obj = minetest.add_entity(pos,"fishing:lure")
24 minetest.sound_play("woosh",{pos=pos})
25 obj:get_luaentity().player=name
27 obj:set_velocity(force)
28 players_fishing[name] = obj
36 lure.initial_properties = {
38 collide_with_objects = false,
39 collisionbox = {-0.1, -0.1, -0.1, 0.1, 0.1, 0.1},
41 visual_size = {x = 1, y = 1},
49 --automatic_face_movement_dir = 0.0,
50 --automatic_face_movement_max_rotation_per_sec = 600,
52 lure.on_activate = function(self)
53 self.object:set_acceleration(vector.new(0,-10,0))
56 lure.interplayer = nil
57 lure.on_step = function(self, dtime)
58 local pos = self.object:get_pos()
59 local node = minetest.get_node(pos).name
60 if node == "main:water" then
62 local new_pos = vector.floor(pos)
63 new_pos.y = new_pos.y + 0.5
64 self.object:move_to(vector.new(pos.x,new_pos.y,pos.z))
65 self.object:set_acceleration(vector.new(0,0,0))
66 self.object:set_velocity(vector.new(0,0,0))
68 local newp = table.copy(pos)
70 local node = minetest.get_node(newp).name
71 if node ~= "air" and node ~= "main:water" and node ~= "main:waterflow" then
73 players_fishing[self.player] = nil
78 if self.in_water == true then
80 local p = minetest.get_player_by_name(self.player)
81 if p:get_player_control().RMB then
82 local pos2 = p:get_pos()
83 local vel = vector.direction(pos,pos2)
84 self.object:set_velocity(vector.multiply(vel,2))
85 if math.random() > 0.97 then
86 local obj = minetest.add_item(pos, "main:dirt")
88 local distance = vector.distance(pos,pos2)
89 local dir = vector.direction(pos,pos2)
90 local force = vector.multiply(dir,distance)
92 obj:set_velocity(force)
94 players_fishing[self.player] = nil
98 self.object:set_velocity(vector.new(0,0,0))
101 local pos2 = p:get_pos()
102 if vector.distance(pos, pos2) < 1 then
103 players_fishing[self.player] = nil
109 if self.player == nil then
113 minetest.register_entity("fishing:lure", lure)