forked from mff/fishing
mores changes
write config add functions load|save config add tresor system chance
This commit is contained in:
parent
ab21ae6cdc
commit
ab67ad83b3
103
bobber.lua
103
bobber.lua
@ -1,8 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
minetest.register_alias("flowers_plus:seaweed", "flowers:seaweed") -- exception
|
|
||||||
|
|
||||||
|
|
||||||
-- bobber
|
-- bobber
|
||||||
minetest.register_node("fishing:bobber_box", {
|
minetest.register_node("fishing:bobber_box", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
@ -37,23 +34,21 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
textures = {"fishing:bobber_box"},
|
textures = {"fishing:bobber_box"},
|
||||||
-- {left ,bottom, front, right, top , back}
|
-- {left ,bottom, front, right, top , back}
|
||||||
collisionbox = {-2/16, -4/16, -2/16, 2/16, 0/16, 2/16},
|
collisionbox = {-2/16, -4/16, -2/16, 2/16, 0/16, 2/16},
|
||||||
view_range = 7,
|
|
||||||
randomtime = 50,
|
randomtime = 50,
|
||||||
chance = 0,
|
amorce = 0,
|
||||||
amorce = false,
|
|
||||||
prize = "",
|
prize = "",
|
||||||
|
|
||||||
-- DESTROY BOBBER WHEN PUNCHING IT
|
-- DESTROY BOBBER WHEN PUNCHING IT
|
||||||
on_punch = function (self, puncher, time_from_last_punch, tool_capabilities, dir)
|
on_punch = function (self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
if not puncher:is_player() then return end
|
if not puncher:is_player() then return end
|
||||||
local player = puncher:get_player_name()
|
local player = puncher:get_player_name()
|
||||||
if player ~= self.object.owner then return end
|
if player ~= self.owner then return end
|
||||||
if MESSAGES == true then minetest.chat_send_player(player, fishing_setting.S("You didn't prizes anything."), false) end -- fish escaped
|
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player, fishing_setting.S("You didn't prizes anything."), false) end
|
||||||
if not fishing_setting.is_creative_mode then
|
if not fishing_setting.is_creative_mode then
|
||||||
local inv = puncher:get_inventory()
|
local inv = puncher:get_inventory()
|
||||||
if inv:room_for_item("main", {name="fishing:bait_corn", count=1, wear=0, metadata=""}) then
|
if inv:room_for_item("main", {name=self.bait, count=1, wear=0, metadata=""}) then
|
||||||
inv:add_item("main", {name="fishing:bait_corn", count=1, wear=0, metadata=""})
|
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
|
||||||
if MESSAGES == true then minetest.chat_send_player(player, fishing_setting.S("The bait is still there."), false) end -- bait still there
|
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player, fishing_setting.S("The bait is still there."), false) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- make sound and remove bobber
|
-- make sound and remove bobber
|
||||||
@ -72,25 +67,17 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
local item_name = item:get_name()
|
local item_name = item:get_name()
|
||||||
if string.find(item_name, "fishing:pole_") ~= nil then
|
if string.find(item_name, "fishing:pole_") ~= nil then
|
||||||
|
if player ~= self.owner then return end
|
||||||
--##############################################################################################################
|
|
||||||
if self.prize ~= "" then
|
if self.prize ~= "" then
|
||||||
local name = self.prize[1]..":"..self.prize[2]
|
local name = self.prize[1]..":"..self.prize[2]
|
||||||
local desc = self.prize[4]
|
local desc = self.prize[4]
|
||||||
print("You caught "..name.." "..desc)
|
print("You caught "..name.." "..desc)
|
||||||
minetest.chat_send_player(player, "You caught "..desc, false)
|
minetest.chat_send_player(player, "You caught "..desc, false)
|
||||||
if inv:room_for_item("main", {name=name, count=1, wear=0, metadata=""}) then
|
local wear_value = fishing_setting.func.wear_value(self.prize[3])
|
||||||
local used
|
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
|
||||||
if self.prize[3] == "random" then
|
inv:add_item("main", {name=name, count=1, wear=wear_value, metadata=""})
|
||||||
used = (2000*(math.random(20, 29)))
|
|
||||||
elseif self.prize[3] == "randomtools" then
|
|
||||||
used = (65535/(30-(math.random(15, 29))))
|
|
||||||
else
|
else
|
||||||
used = 0
|
minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""})
|
||||||
end
|
|
||||||
inv:add_item("main", {name=name, count=1, wear=used, metadata=""})
|
|
||||||
else
|
|
||||||
minetest.spawn_item(clicker:getpos(), name)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,18 +85,11 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
|
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
||||||
|
|
||||||
--##############################################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
elseif item:get_name() == "fishing:amorce" then
|
elseif item:get_name() == "fishing:amorce" then
|
||||||
|
|
||||||
|
|
||||||
if not fishing_setting.is_creative_mode then
|
if not fishing_setting.is_creative_mode then
|
||||||
inv:remove_item("main", "fishing:amorce")
|
inv:remove_item("main", "fishing:amorce")
|
||||||
end
|
end
|
||||||
self.amorce = true
|
self.amorce = 20
|
||||||
--addparticle
|
--addparticle
|
||||||
minetest.add_particlespawner(30, 0.5, -- for how long (?) -- Particles on splash
|
minetest.add_particlespawner(30, 0.5, -- for how long (?) -- Particles on splash
|
||||||
{x=pos.x,y=pos.y-0.0625,z=pos.z}, {x=pos.x,y=pos.y,z=pos.z}, -- position min, pos max
|
{x=pos.x,y=pos.y-0.0625,z=pos.z}, {x=pos.x,y=pos.y,z=pos.z}, -- position min, pos max
|
||||||
@ -120,8 +100,6 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
false, "fishing_particle_amorce.png")
|
false, "fishing_particle_amorce.png")
|
||||||
-- add sound
|
-- add sound
|
||||||
minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(), gain = 0.2, })
|
minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(), gain = 0.2, })
|
||||||
--inc hp
|
|
||||||
print("amorce")
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -132,14 +110,13 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
-- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE
|
-- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE
|
||||||
on_step = function(self, dtime)
|
on_step = function(self, dtime)
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
|
--remove if no owner, no player, owner no in bobber_view_range
|
||||||
if self.owner == nil then self.object:remove(); return end
|
if self.owner == nil then self.object:remove(); return end
|
||||||
local player = minetest.get_player_by_name(self.owner)
|
local player = minetest.get_player_by_name(self.owner)
|
||||||
if not player then self.object:remove(); return end
|
if not player then self.object:remove(); return end
|
||||||
--remove if nobody in radius
|
|
||||||
local p = player:getpos()
|
local p = player:getpos()
|
||||||
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
||||||
if dist > self.view_range then
|
if dist > fishing_setting.settings["bobber_view_range"] then
|
||||||
minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(),gain = 0.5,})
|
minetest.sound_play("fishing_bobber1", {pos = self.object:getpos(),gain = 0.5,})
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
@ -150,61 +127,61 @@ local FISHING_BOBBER_ENTITY={
|
|||||||
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
|
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
|
||||||
end
|
end
|
||||||
|
|
||||||
--###################
|
|
||||||
self.timer = self.timer + 1
|
self.timer = self.timer + 1
|
||||||
|
|
||||||
if self.timer < self.randomtime then
|
if self.timer < self.randomtime then
|
||||||
if self.prize ~= "" then
|
-- if fish or others items, move bobber to simulate fish on the line
|
||||||
local n = math.random(1,3)
|
if self.prize ~= "" and math.random(1,3) == 1 then
|
||||||
if n == 1 then
|
|
||||||
if self.old_pos2 == true then
|
if self.old_pos2 == true then
|
||||||
pos.y = pos.y-0.0325
|
pos.y = pos.y-0.0325
|
||||||
self.object:moveto(pos, false)
|
self.object:moveto(pos, false)
|
||||||
self.old_pos2 = false
|
self.old_pos2 = false
|
||||||
|
--minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
|
||||||
else
|
else
|
||||||
pos.y = pos.y+0.0325
|
pos.y = pos.y+0.0325
|
||||||
self.object:moveto(pos, false)
|
self.object:moveto(pos, false)
|
||||||
self.old_pos2 = true
|
self.old_pos2 = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if self.prize == fishing_setting.prizes.tresor then
|
||||||
|
minetest.chat_send_player(player, "You lost the tresor, bad luck", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
--change item on line
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
|
self.prize = ""
|
||||||
self.object:moveto(self.old_pos, false)
|
self.object:moveto(self.old_pos, false)
|
||||||
self.randomtime = math.random(2,12)*10
|
self.randomtime = math.random(2,12)*10
|
||||||
--self.object:moveto({x=pos.x,y=pos.y-0.015625,z=pos.z})
|
--Once the fish are not hungry :)
|
||||||
--print("randomtime:"..tostring(self.randomtime))
|
-- amorce increase lucky + 20%
|
||||||
if math.random(1, 100) > FISH_CHANCE then
|
if math.random(1, 100) > fishing_setting.settings.chance["hungry_fish"] + self.amorce then
|
||||||
self.prize = ""
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local c = 0
|
|
||||||
if self.amorce then
|
|
||||||
c = 20
|
|
||||||
end
|
|
||||||
|
|
||||||
|
local chance = math.random(1, 100)
|
||||||
local chance = math.random(1, 100)+c
|
|
||||||
print(" chance: " .. tostring(chance) .. " randomtime: "..tostring(self.randomtime))
|
print(" chance: " .. tostring(chance) .. " randomtime: "..tostring(self.randomtime))
|
||||||
|
--if 1 you catch a tresor, maybe ...
|
||||||
if chance == 1 then
|
if chance == 1 then
|
||||||
local r = math.random(1, 100)
|
--You are lucky ? :)
|
||||||
if r < 10 then
|
if math.random(1, 100) <= fishing_setting.settings.chance["tresor"] then
|
||||||
self.prize = fishing_setting.prizes.tresor[math.random(1,#fishing_setting.prizes.tresor)]
|
self.prize = fishing_setting.prizes.tresor
|
||||||
else
|
else
|
||||||
self.prize = ""
|
self.prize = fishing_setting.prizes.stuff[math.random(1,#fishing_setting.prizes.stuff)]
|
||||||
end
|
end
|
||||||
elseif chance < 10 then
|
elseif chance <= fishing_setting.settings.chance["fish"] then
|
||||||
self.prize = ""
|
|
||||||
elseif chance < 40 then
|
|
||||||
self.prize = fishing_setting.prizes.loose[math.random(1,#fishing_setting.prizes.loose)]
|
|
||||||
else
|
|
||||||
self.prize = fishing_setting.prizes.fish[math.random(1,#fishing_setting.prizes.fish)]
|
self.prize = fishing_setting.prizes.fish[math.random(1,#fishing_setting.prizes.fish)]
|
||||||
|
else
|
||||||
|
if math.random(1, 100) <= 10 then
|
||||||
|
self.prize = fishing_setting.prizes.loose[math.random(1,#fishing_setting.prizes.loose)]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.amorce = false
|
if self.prize ~= nil and self.prize ~= "" then
|
||||||
if self.prize ~= nil then
|
|
||||||
pos.y = self.old_pos.y-0.1
|
pos.y = self.old_pos.y-0.1
|
||||||
self.object:moveto(pos, false)
|
self.object:moveto(pos, false)
|
||||||
minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
|
minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--FIXME server set fishing enable|disable treasure
|
--FIXME server set fishing enable|disable treasure
|
||||||
minetest.register_chatcommand("fishing_enable", {
|
minetest.register_chatcommand("fishing_enable", {
|
||||||
params = "",
|
params = "",
|
||||||
@ -14,8 +19,8 @@ minetest.register_chatcommand("fishing_enable", {
|
|||||||
fishing_setting.enable = false
|
fishing_setting.enable = false
|
||||||
minetest.chat_send_player(name, "treasure is disabled")
|
minetest.chat_send_player(name, "treasure is disabled")
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, "unknow param ".. tostring(param))
|
minetest.chat_send_player(name, "treasure is " .. tostring(fishing_setting.enable))
|
||||||
minetest.chat_send_player(name, "command is /fishing_enable <true|false>")
|
minetest.chat_send_player(name, "To change, type:/fishing_enable <true|false>")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
102
functions.lua
Normal file
102
functions.lua
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
|
||||||
|
|
||||||
|
function fishing_setting.func.save()
|
||||||
|
local input = io.open(fishing_setting.file, "w")
|
||||||
|
if input then
|
||||||
|
input:write(minetest.serialize(fishing_setting.settings))
|
||||||
|
input:close()
|
||||||
|
else
|
||||||
|
minetest.log("action","echec d'ouverture (mode:w) de " .. fishing_setting.file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function fishing_setting.func.load()
|
||||||
|
local file = io.open(fishing_setting.file, "r")
|
||||||
|
local settings = {}
|
||||||
|
if file then
|
||||||
|
settings = minetest.deserialize(file:read("*all"))
|
||||||
|
file:close()
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if settings == nil or type(settings) ~= "table" then return end
|
||||||
|
|
||||||
|
if settings["message"] ~= nil then
|
||||||
|
fishing_setting.settings["message"] = settings["message"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings["worm_is_mob"] ~= nil then
|
||||||
|
fishing_setting.settings["worm_is_mob"] = settings["worm_is_mob"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings["worm_chance"] ~= nil then
|
||||||
|
fishing_setting.settings["worm_chance"] = settings["worm_chance"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings["new_worm_source"] ~= nil then
|
||||||
|
fishing_setting.settings["new_worm_source"] = settings["new_worm_source"]
|
||||||
|
end
|
||||||
|
if settings["wear_out"] ~= nil then
|
||||||
|
fishing_setting.settings["wear_out"] = settings["wear_out"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings["bobber_view_range"] ~= nil then
|
||||||
|
fishing_setting.settings["bobber_view_range"] = settings["bobber_view_range"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings["simple_deco_fishing_pole"] ~= nil then
|
||||||
|
fishing_setting.settings["simple_deco_fishing_pole"] = settings["simple_deco_fishing_pole"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings.chance["fish"] ~= nil then
|
||||||
|
fishing_setting.settings.chance["fish"] = settings.chance["fish"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings.chance["tresor"] ~= nil then
|
||||||
|
fishing_setting.settings.chance["tresor"] = settings.chance["tresor"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings.chance["shark"] ~= nil then
|
||||||
|
fishing_setting.settings.chance["shark"] = settings.chance["shark"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings.chance["hungry_fish"] ~= nil then
|
||||||
|
fishing_setting.settings.chance["hungry_fish"] = settings.chance["hungry_fish"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings["tresor_timer"] ~= nil then
|
||||||
|
fishing_setting.settings["tresor_timer"] = settings["tresor_timer"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if settings["tresor_random_enable"] ~= nil then
|
||||||
|
fishing_setting.settings["tresor_random_enable"] = settings["tresor_random_enable"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--function return wear tool value (old or new)
|
||||||
|
function fishing_setting.func.wear_value(wear)
|
||||||
|
local used = 0
|
||||||
|
if wear == "random" then
|
||||||
|
used = (2000*(math.random(20, 29)))
|
||||||
|
elseif wear == "randomtools" then
|
||||||
|
used = (65535/(30-(math.random(15, 29))))
|
||||||
|
end
|
||||||
|
return used
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_on_shutdown(function()
|
||||||
|
minetest.log("action", "[fishing] Server shuts down. Saving config")
|
||||||
|
fishing_setting.func.save()
|
||||||
|
end)
|
||||||
|
|
57
init.lua
57
init.lua
@ -1,6 +1,18 @@
|
|||||||
print("loading [fishing] mod")
|
print("loading [fishing] mod")
|
||||||
fishing_setting = {}
|
local path = minetest.get_modpath("fishing").."/"
|
||||||
|
|
||||||
|
fishing_setting = {}
|
||||||
|
fishing_setting.func = {}
|
||||||
|
fishing_setting.is_creative_mode = minetest.setting_getbool("creative_mode")
|
||||||
|
fishing_setting.file = minetest.get_worldpath() .. "/fishing_config.txt"
|
||||||
|
|
||||||
|
fishing_setting.settings = {}
|
||||||
|
--for random object
|
||||||
|
random_objects = {}
|
||||||
|
fishing_setting.baits = {}
|
||||||
|
fishing_setting.prizes = {}
|
||||||
|
fishing_setting.settings["timer_tresor"] = 3600
|
||||||
|
fishing_setting.settings.chance = {}
|
||||||
|
|
||||||
if (minetest.get_modpath("intllib")) then
|
if (minetest.get_modpath("intllib")) then
|
||||||
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
dofile(minetest.get_modpath("intllib").."/intllib.lua")
|
||||||
@ -10,19 +22,30 @@ else
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fishing_setting.file = minetest.get_worldpath() .. "/fishing_config.txt"
|
|
||||||
fishing_setting.is_creative_mode = minetest.setting_getbool("creative_mode")
|
|
||||||
fishing_setting.setting = {}
|
|
||||||
fishing_setting.random_timer = 3600
|
|
||||||
fishing_setting.prizes = {}
|
|
||||||
|
|
||||||
--for random object
|
|
||||||
random_objects = {}
|
|
||||||
|
|
||||||
fishing_setting.baits = {}
|
|
||||||
local path = minetest.get_modpath("fishing").."/"
|
|
||||||
dofile(path .."settings.txt")
|
dofile(path .."settings.txt")
|
||||||
|
dofile(path .."functions.lua")
|
||||||
|
|
||||||
|
|
||||||
|
fishing_setting.settings["message"] = MESSAGES
|
||||||
|
fishing_setting.settings["worm_is_mob"] = WORM_IS_MOB
|
||||||
|
fishing_setting.settings["worm_chance"] = WORM_CHANCE
|
||||||
|
fishing_setting.settings["new_worm_source"] = NEW_WORM_SOURCE
|
||||||
|
fishing_setting.settings["wear_out"] = WEAR_OUT
|
||||||
|
fishing_setting.settings["simple_deco_fishing_pole"] = SIMPLE_DECO_FISHING_POLE
|
||||||
|
fishing_setting.settings["bobber_view_range"] = BOBBER_VIEW_RANGE
|
||||||
|
fishing_setting.settings.chance["fish"] = CHANCE_FISH
|
||||||
|
fishing_setting.settings.chance["tresor"] = CHANCE_TRESOR
|
||||||
|
fishing_setting.settings.chance["shark"] = CHANCE_SHARK
|
||||||
|
fishing_setting.settings.chance["hungry_fish"] = HUNGRY_FISH
|
||||||
|
fishing_setting.settings["tresor_timer"] = TRESOR_TIMER
|
||||||
|
fishing_setting.settings["tresor_random_enable"] = TRESOR_RANDOM_ENABLE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- load config file if exist in worldpath
|
||||||
|
fishing_setting.func.load()
|
||||||
|
|
||||||
|
|
||||||
dofile(path .."crafting.lua")
|
dofile(path .."crafting.lua")
|
||||||
dofile(path .."baits.lua")
|
dofile(path .."baits.lua")
|
||||||
dofile(path .."prizes.lua")
|
dofile(path .."prizes.lua")
|
||||||
@ -36,13 +59,13 @@ dofile(path .."poles.lua")
|
|||||||
|
|
||||||
|
|
||||||
-- timer
|
-- timer
|
||||||
fishing_setting.timer = 0
|
fishing_setting.timer = fishing_setting.settings["timer_tresor"]
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
if fishing_setting.enable == false then return end
|
if fishing_setting.enable == false then return end
|
||||||
fishing_setting.timer = fishing_setting.timer - dtime
|
fishing_setting.timer = fishing_setting.timer - dtime
|
||||||
-- if fishing.new_object then
|
-- if fishing.new_object then
|
||||||
-- new object is item, time to catch is timer
|
-- new object is item, time to catch is timer
|
||||||
-- fishing_setting.timer = fishing_setting.random_timer
|
-- fishing_setting.timer = fishing_setting.settings["timer_tresor"]
|
||||||
-- end
|
-- end
|
||||||
-- if timer == 300 then
|
-- if timer == 300 then
|
||||||
--you have 5min for catch item
|
--you have 5min for catch item
|
||||||
@ -53,9 +76,9 @@ minetest.register_globalstep(function(dtime)
|
|||||||
--FIXME display message
|
--FIXME display message
|
||||||
end
|
end
|
||||||
--get random object
|
--get random object
|
||||||
fishing_setting.timer = fishing_setting.random_timer
|
fishing_setting.timer = fishing_setting.settings["timer_tresor"]
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
print("loaded [fishing] mod")
|
||||||
|
14
poles.lua
14
poles.lua
@ -26,7 +26,7 @@ for _,pole in pairs(fishing_setting.poles) do
|
|||||||
if pointed_thing and pointed_thing.under then
|
if pointed_thing and pointed_thing.under then
|
||||||
local pt = pointed_thing
|
local pt = pointed_thing
|
||||||
local node = minetest.get_node(pt.under)
|
local node = minetest.get_node(pt.under)
|
||||||
if string.find(node.name, "default:water") == nil then return nil end
|
if node.name ~= "default:water_source" and node.name ~= "noairblocks:water_sourcex" and node.name ~= "default:river_water_source" then return nil end
|
||||||
local player = user:get_player_name()
|
local player = user:get_player_name()
|
||||||
local inv = user:get_inventory()
|
local inv = user:get_inventory()
|
||||||
local bait = inv:get_stack("main", user:get_wield_index()+1 ):get_name()
|
local bait = inv:get_stack("main", user:get_wield_index()+1 ):get_name()
|
||||||
@ -45,7 +45,8 @@ for _,pole in pairs(fishing_setting.poles) do
|
|||||||
local i = 1
|
local i = 1
|
||||||
for _,k in pairs({ 1, 0, -1}) do
|
for _,k in pairs({ 1, 0, -1}) do
|
||||||
for _,l in pairs({ -1, 0, 1}) do
|
for _,l in pairs({ -1, 0, 1}) do
|
||||||
if string.find(minetest.get_node({x=pt.under.x+l, y=pt.under.y, z=pt.under.z+k}).name, "default:water") ~= nil
|
local node_name = minetest.get_node({x=pt.under.x+l, y=pt.under.y, z=pt.under.z+k}).name
|
||||||
|
if (node_name == "default:water_source" or node_name == "noairblocks:water_sourcex" or node_name == "default:river_water_source")
|
||||||
and minetest.get_node({x=pt.under.x+l, y=pt.under.y+1, z=pt.under.z+k}).name == "air" then
|
and minetest.get_node({x=pt.under.x+l, y=pt.under.y+1, z=pt.under.z+k}).name == "air" then
|
||||||
local empty = true
|
local empty = true
|
||||||
for o, obj in pairs(bobbers) do
|
for o, obj in pairs(bobbers) do
|
||||||
@ -64,14 +65,17 @@ for _,pole in pairs(fishing_setting.poles) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
--if water == -3 nodes
|
--if water == -3 nodes
|
||||||
if #nodes < 1 then return nil end
|
if #nodes < 2 then
|
||||||
|
minetest.chat_send_player(player, "You don't fishing in a bottle!!! ")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
local new_pos = nodes[math.random(1, #nodes)]
|
local new_pos = nodes[math.random(1, #nodes)]
|
||||||
new_pos.y=new_pos.y+(45/64)
|
new_pos.y=new_pos.y+(45/64)
|
||||||
local ent = minetest.add_entity({interval = 1,x=new_pos.x, y=new_pos.y, z=new_pos.z}, fishing_setting.baits[bait].bobber)
|
local ent = minetest.add_entity({interval = 1,x=new_pos.x, y=new_pos.y, z=new_pos.z}, fishing_setting.baits[bait].bobber)
|
||||||
if not ent then return nil end
|
if not ent then return nil end
|
||||||
local luaentity = ent:get_luaentity()
|
local luaentity = ent:get_luaentity()
|
||||||
luaentity.owner = player
|
luaentity.owner = player
|
||||||
luaentity.prize = ""
|
luaentity.bait = bait
|
||||||
luaentity.old_pos = new_pos
|
luaentity.old_pos = new_pos
|
||||||
luaentity.old_pos2 = true
|
luaentity.old_pos2 = true
|
||||||
if not fishing_setting.is_creative_mode then
|
if not fishing_setting.is_creative_mode then
|
||||||
@ -79,7 +83,7 @@ for _,pole in pairs(fishing_setting.poles) do
|
|||||||
end
|
end
|
||||||
minetest.sound_play("fishing_bobber2", {pos = new_pos, gain = 0.5})
|
minetest.sound_play("fishing_bobber2", {pos = new_pos, gain = 0.5})
|
||||||
|
|
||||||
if WEAR_OUT == true and not fishing_setting.is_creative_mode then
|
if fishing_setting.settings["wear_out"] == true and not fishing_setting.is_creative_mode then
|
||||||
return rod_wear(itemstack, user, pointed_thing, pole.max_use)
|
return rod_wear(itemstack, user, pointed_thing, pole.max_use)
|
||||||
else
|
else
|
||||||
return {name="fishing:pole_".. pole.name, count=1, wear=0, metadata=""}
|
return {name="fishing:pole_".. pole.name, count=1, wear=0, metadata=""}
|
||||||
|
28
prizes.lua
28
prizes.lua
@ -1,28 +1,26 @@
|
|||||||
|
minetest.register_alias("flowers_plus:seaweed", "flowers:seaweed") -- exception
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fishing_setting.prizes.fish = {
|
fishing_setting.prizes.fish = {
|
||||||
{"fishing", "fish_raw", 0, "a Fish.", 1, 60}
|
{"fishing", "fish_raw", 0, "a Fish."}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-- Here's what you can prizes
|
-- Here's what you can prizes
|
||||||
fishing_setting.prizes.loose = {
|
fishing_setting.prizes.loose = {
|
||||||
-- MoD iTeM WeaR MeSSaGe ("You caught "..) NRMiN CHaNCe (../120)
|
-- MoD iTeM WeaR MeSSaGe ("You caught "..)
|
||||||
{"default", "stick", 0, "a Twig.", 81, 2},
|
{"default", "stick", 0, "a Twig."},
|
||||||
{"mobs", "rat", 0, "a Rat.", 83, 1},
|
{"mobs", "rat", 0, "a Rat."},
|
||||||
{"flowers_plus", "seaweed", 0, "some Seaweed.", 86, 20},
|
{"flowers_plus", "seaweed", 0, "some Seaweed."},
|
||||||
{"seaplants", "kelpgreen", 0, "a Green Kelp.", 106, 10},
|
{"seaplants", "kelpgreen", 0, "a Green Kelp."},
|
||||||
{"farming", "string", 0, "a String.", 116, 2},
|
{"farming", "string", 0, "a String."},
|
||||||
{"trunks", "twig_1", 0, "a Twig.", 121, 2}
|
{"trunks", "twig_1", 0, "a Twig."}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fishing_setting.prizes.tresor = {
|
fishing_setting.prizes.stuff = {
|
||||||
{"fishing", "pole_wood", "randomtools", "an old Fishing Pole.", 118, 2},
|
{"fishing", "pole_wood", "randomtools", "an old Fishing Pole."},
|
||||||
{"3d_armor", "boots_wood", "random", "some very old Boots.", 120, 1}
|
{"3d_armor", "boots_wood", "random", "some very old Boots."}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fishing_setting.prizes.tresor = {"default", "mese", 0, "a mese block."}
|
||||||
|
14
settings.txt
14
settings.txt
@ -1,9 +1,13 @@
|
|||||||
MESSAGES = true
|
MESSAGES = true
|
||||||
FISH_CHANCE = 60
|
SIMPLE_DECO_FISHING_POLE = true
|
||||||
|
WEAR_OUT = true
|
||||||
NEW_WORM_SOURCE = true
|
NEW_WORM_SOURCE = true
|
||||||
WORM_IS_MOB = true
|
WORM_IS_MOB = true
|
||||||
WORM_CHANCE = 66
|
WORM_CHANCE = 66
|
||||||
WEAR_OUT = true
|
BOBBER_VIEW_RANGE = 7
|
||||||
BOBBER_CHECK_RADIUS = 5
|
CHANCE_FISH = 60
|
||||||
SIMPLE_DECO_FISHING_POLE = true
|
CHANCE_SHARK = 30
|
||||||
SHARK_CHANCE = 30
|
CHANCE_TRESOR = 5
|
||||||
|
HUNGRY_FISH = 80
|
||||||
|
TRESOR_TIMER = 3600
|
||||||
|
TRESOR_RANDOM_ENABLE = true
|
||||||
|
Loading…
Reference in New Issue
Block a user