Compare commits

...

13 Commits

Author SHA1 Message Date
Panquesito7 2a8650bc4b
Remove various deprecated functions 2020-05-15 12:41:44 -05:00
Darcidride f81a90c20a
Merge pull request #4 from Panquesito7/master
Replace deprecated functions with newer ones
2019-08-23 13:33:24 +00:00
Panquesito7 df660f25a9
Create mod.conf 2019-08-22 19:44:48 -05:00
Panquesito7 fa391d1a08
Update functions.lua 2019-08-22 19:39:59 -05:00
Panquesito7 936b528a4a
Update worms.lua 2019-08-22 19:34:30 -05:00
Panquesito7 c66a45e1f9
Update bobber_shark.lua 2019-08-22 19:32:32 -05:00
Panquesito7 ae9b315884
Update bobber.lua 2019-08-22 19:30:52 -05:00
crabman77 091611b1cd use groups to create baitball and cooked craft instead of redundant code, thanks Chem871
fix indentation
2017-12-09 01:19:28 +01:00
crabman77 7a88dd9e1f fix typo 2017-12-08 20:02:11 +01:00
crabman77 d0a79be624 added schedule contest 2017-12-08 19:17:18 +01:00
upsilon bc37d001c6 worms on_place: check whether placer is not nil before checking for protection 2017-01-30 17:51:21 +01:00
crabman77 26f79a8f36 Merge pull request #2 from Mynetest/worm_protected
Check for protection before placing a worm
2017-01-27 19:25:37 +01:00
upsilon 2389efbc87 Check for protection before placing a worm 2017-01-27 17:25:35 +01:00
10 changed files with 296 additions and 282 deletions

View File

@ -4,13 +4,13 @@
### Original by Mossmanikin https://github.com/Mossmanikin/fishing
### Rewrited by Crabman77 (MFF team)
###9 fish type
**fish in rivers**
### **9 fish type**
**fish in rivers**
> - 2 small fish (fish, carp)
> - 3 predator fish (perch, catfish, Northern Pike)
**fish in sea**
>- 3 small fish (clownfish,bluewhite fish, exotic fish)
**fish in sea**
> - 3 small fish (clownfish,bluewhite fish, exotic fish)
> - 1 predator fish (small shark)
@ -20,7 +20,7 @@
The baits have a variable luck(15% to 80%) changed between 30 minutes to 6 hours for a better gameplay
Baitball improves lucky bait of 20%
###**Contest Game **
### **Contest Game **
Contest game can be launched by admin, duration variable 2min to 4heures
Start/End is announced in chat and sound
A ranking appears(formspec) after contest
@ -29,6 +29,18 @@ Adjustable settings in formspec
if the unified_inventory mod is actived there is a button for classification or settings for the admin only
## **schedule**
### **Chatcommand**
**contest_show**
**contest_stop**
**contest_del number(view with contest_show)**
**contest_start duration(in seconds)**
> - contest_start 3600
**contest_add wday hour minutes duration**
> - contest_add 0 15 30 3600
> - Wday 0=all, 1=sunday, 2=Monday, ..., 7=Saturday
[demo video youtube](https://youtu.be/8rt8g3F2Gmk)

View File

@ -24,35 +24,6 @@ minetest.register_craftitem("fishing:baitball_shark", {
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:fish_raw", "fishing:fish_raw"}
recipe = {"group:fishbait", "group:fishbait"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:shark_raw", "fishing:shark_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:pike_raw", "fishing:pike_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:fish_raw", "fishing:shark_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:fish_raw", "fishing:pike_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:shark_raw", "fishing:pike_raw"}
})

View File

@ -64,7 +64,7 @@ local FISHING_BOBBER_ENTITY={
end
end
-- make sound and remove bobber
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
self.object:remove()
end,
@ -78,7 +78,7 @@ local FISHING_BOBBER_ENTITY={
return
end
local inv = clicker:get_inventory()
local pos = self.object:getpos()
local pos = self.object:get_pos()
local item_name = item:get_name()
if string.find(item_name, "fishing:pole_") ~= nil then
@ -99,7 +99,7 @@ local FISHING_BOBBER_ENTITY={
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
inv:add_item("main", {name=name, count=1, wear=wear_value, metadata=""})
else
minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""})
minetest.spawn_item(clicker:get_pos(), {name=name, count=1, wear=wear_value, metadata=""})
end
end
else
@ -110,7 +110,7 @@ local FISHING_BOBBER_ENTITY={
end
end
-- weither player has fishing pole or not
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
self.object:remove()
elseif item_name == "fishing:baitball" then
@ -127,14 +127,14 @@ local FISHING_BOBBER_ENTITY={
0.25, 0.5, -- min size, max size
false, "fishing_particle_baitball.png")
-- add sound
minetest.sound_play("fishing_baitball", {pos = self.object:getpos(), gain = 0.2, })
minetest.sound_play("fishing_baitball", {pos = self.object:get_pos(), gain = 0.2, })
end
end,
-- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE
on_step = function(self, dtime)
local pos = self.object:getpos()
local pos = self.object:get_pos()
--remove if no owner, no player, owner no in bobber_view_range
if self.owner == nil then self.object:remove(); return end
--remove if not node water
@ -148,17 +148,17 @@ local FISHING_BOBBER_ENTITY={
end
local player = minetest.get_player_by_name(self.owner)
if not player then self.object:remove(); return end
local p = player:getpos()
local p = player:get_pos()
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
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:get_pos(),gain = 0.5,})
self.object:remove()
return
end
--rotate bobber
if math.random(1, 4) == 1 then
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
self.object:set_yaw(self.object:get_yaw()+((math.random(0,360)-180)/2880*math.pi))
end
self.timer = self.timer + 1
@ -167,11 +167,11 @@ local FISHING_BOBBER_ENTITY={
if self.prize ~= "" and math.random(1,3) == 1 then
if self.old_pos2 == true then
pos.y = pos.y-0.0280
self.object:moveto(pos, false)
self.object:move_to(pos, false)
self.old_pos2 = false
else
pos.y = pos.y+0.0280
self.object:moveto(pos, false)
self.object:move_to(pos, false)
self.old_pos2 = true
end
end
@ -184,7 +184,7 @@ local FISHING_BOBBER_ENTITY={
minetest.add_entity({x=pos.x, y=pos.y-1, z=pos.z}, self.prize[1]..":"..self.prize[2])
end
self.prize = ""
self.object:moveto(self.old_pos, false)
self.object:move_to(self.old_pos, false)
--Once the fish are not hungry :), baitball increase hungry + 20%
if math.random(1, 100) > fishing_setting.baits[self.bait]["hungry"] + self.baitball then
--Fish not hungry !(
@ -221,7 +221,7 @@ local FISHING_BOBBER_ENTITY={
if self.prize ~= "" then
pos.y = self.old_pos.y-0.1
self.object:moveto(pos, false)
self.object:move_to(pos, false)
minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
end
end,

View File

@ -62,7 +62,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
end
end
-- make sound and remove bobber
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
self.object:remove()
end,
@ -76,7 +76,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
return
end
local inv = clicker:get_inventory()
local pos = self.object:getpos()
local pos = self.object:get_pos()
local item_name = item:get_name()
if string.find(item_name, "fishing:pole_") ~= nil then
@ -97,7 +97,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
inv:add_item("main", {name=name, count=1, wear=wear_value, metadata=""})
else
minetest.spawn_item(clicker:getpos(), {name=name, count=1, wear=wear_value, metadata=""})
minetest.spawn_item(clicker:get_pos(), {name=name, count=1, wear=wear_value, metadata=""})
end
end
else
@ -108,7 +108,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
end
end
-- weither player has fishing pole or not
minetest.sound_play("fishing_bobber1", { pos = self.object:getpos(), gain = 0.5, })
minetest.sound_play("fishing_bobber1", { pos = self.object:get_pos(), gain = 0.5, })
self.object:remove()
elseif item_name == "fishing:baitball_shark" then
@ -125,14 +125,14 @@ local FISHING_BOBBER_SHARK_ENTITY={
0.25, 0.40, -- min size, max size
false, "fishing_particle_baitball_shark.png")
-- add sound
minetest.sound_play("fishing_baitball", {pos = self.object:getpos(), gain = 0.2, })
minetest.sound_play("fishing_baitball", {pos = self.object:get_pos(), gain = 0.2, })
end
end,
-- AS SOON AS THE BOBBER IS PLACED IT WILL ACT LIKE
on_step = function(self, dtime)
local pos = self.object:getpos()
local pos = self.object:get_pos()
--remove if no owner, no player, owner no in bobber_view_range
if self.owner == nil then self.object:remove(); return end
--remove if not node water
@ -146,17 +146,17 @@ local FISHING_BOBBER_SHARK_ENTITY={
end
local player = minetest.get_player_by_name(self.owner)
if not player then self.object:remove(); return end
local p = player:getpos()
local p = player:get_pos()
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
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:get_pos(),gain = 0.5,})
self.object:remove()
return
end
--rotate bobber
if math.random(1, 4) == 1 then
self.object:setyaw(self.object:getyaw()+((math.random(0,360)-180)/2880*math.pi))
self.object:set_yaw(self.object:get_yaw()+((math.random(0,360)-180)/2880*math.pi))
end
self.timer = self.timer + 1
@ -165,11 +165,11 @@ local FISHING_BOBBER_SHARK_ENTITY={
if self.prize ~= "" and math.random(1,3) == 1 then
if self.old_pos2 == true then
pos.y = pos.y-0.050
self.object:moveto(pos, false)
self.object:move_to(pos, false)
self.old_pos2 = false
else
pos.y = pos.y+0.050
self.object:moveto(pos, false)
self.object:move_to(pos, false)
self.old_pos2 = true
end
end
@ -182,7 +182,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
minetest.add_entity({x=pos.x, y=pos.y-1, z=pos.z}, self.prize[1]..":"..self.prize[2])
end
self.prize = ""
self.object:moveto(self.old_pos, false)
self.object:move_to(self.old_pos, false)
--Once the fish are not hungry :), baitball increase hungry + 20%
if math.random(1, 100) > fishing_setting.baits[self.bait]["hungry"] + self.baitball then
--Fish not hungry !(
@ -225,7 +225,7 @@ local FISHING_BOBBER_SHARK_ENTITY={
if self.prize ~= "" then
pos.y = self.old_pos.y-0.140
self.object:moveto(pos, false)
self.object:move_to(pos, false)
minetest.sound_play("fishing_bobber1", {pos=pos,gain = 0.5,})
end
end,

View File

@ -82,49 +82,7 @@ minetest.register_craft({
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:fish_raw",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:clownfish_raw",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:bluewhite_raw",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:exoticfish_raw",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:carp_raw",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:perch_raw",
cooktime = 2,
})
minetest.register_craft({
type = "cooking",
output = "fishing:fish_cooked",
recipe = "fishing:catfish_raw",
recipe = "group:fishraw",
cooktime = 2,
})
@ -214,110 +172,3 @@ minetest.register_craft({
})
-- baitball
minetest.register_craftitem("fishing:baitball", {
description = fishing_setting.func.S("Bait Ball"),
inventory_image = "fishing_baitball.png",
stack_max = 99,
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball 20",
recipe = {"farming:flour", "farming:corn", "bucket:bucket_water"},
replacements = {{ "bucket:bucket_water", "bucket:bucket_empty"}}
})
-- baitball_shark
minetest.register_craftitem("fishing:baitball_shark", {
description = fishing_setting.func.S("Shark Bait Ball"),
inventory_image = "fishing_baitball_shark.png",
stack_max = 99,
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:fish_raw", "fishing:fish_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:clownfish_raw", "fishing:clownfish_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:clownfish_raw", "fishing:fish_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:bluewhite_raw", "fishing:bluewhite_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:bluewhite_raw", "fishing:fish_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:clownfish_raw", "fishing:bluewhite_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:clownfish_raw", "fishing:shark_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:clownfish_raw", "fishing:pike_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:bluewhite_raw", "fishing:shark_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:bluewhite_raw", "fishing:pike_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:shark_raw", "fishing:shark_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:pike_raw", "fishing:pike_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:fish_raw", "fishing:shark_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:fish_raw", "fishing:pike_raw"}
})
minetest.register_craft({
type = "shapeless",
output = "fishing:baitball_shark 20",
recipe = {"fishing:shark_raw", "fishing:pike_raw"}
})

View File

@ -9,35 +9,36 @@
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:fish_raw", {
description = fishing_setting.func.S("Fish"),
groups = {},
groups = {fishbait=1, fishraw=1},
inventory_image = "fishing_fish_raw.png",
on_use = minetest.item_eat(2),
})
-----------------------------------------------------
-- Roasted Fish
-----------------------------------------------------
minetest.register_craftitem("fishing:fish_cooked", {
description = fishing_setting.func.S("Roasted Fish"),
groups = {},
inventory_image = "fishing_fish_cooked.png",
on_use = minetest.item_eat(4),
})
-----------------------------------------------------
-- Sushi
-----------------------------------------------------
minetest.register_craftitem("fishing:sushi", {
description = fishing_setting.func.S("Sushi (Hoso Maki)"),
groups = {},
inventory_image = "fishing_sushi.png",
on_use = minetest.item_eat(6),
})
-----------------------------------------------------
-- Roasted Fish
-----------------------------------------------------
minetest.register_craftitem("fishing:fish_cooked", {
description = fishing_setting.func.S("Roasted Fish"),
groups = {},
inventory_image = "fishing_fish_cooked.png",
on_use = minetest.item_eat(4),
})
-----------------------------------------------------
-- Sushi
-----------------------------------------------------
minetest.register_craftitem("fishing:sushi", {
description = fishing_setting.func.S("Sushi (Hoso Maki)"),
groups = {},
inventory_image = "fishing_sushi.png",
on_use = minetest.item_eat(6),
})
-----------------------------------------------------------------------------------------------
-- clownfish
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:clownfish_raw", {
description = fishing_setting.func.S("Clownfish"),
groups = {},
groups = {fishbait=1, fishraw=1},
inventory_image = "fishing_clownfish_raw.png",
on_use = minetest.item_eat(2),
})
@ -47,7 +48,7 @@ minetest.register_craftitem("fishing:clownfish_raw", {
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:bluewhite_raw", {
description = fishing_setting.func.S("Bluewhite"),
groups = {},
groups = {fishbait=1, fishraw=1},
inventory_image = "fishing_bluewhite_raw.png",
on_use = minetest.item_eat(2),
})
@ -56,7 +57,7 @@ minetest.register_craftitem("fishing:bluewhite_raw", {
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:exoticfish_raw", {
description = fishing_setting.func.S("Exotic"),
groups = {},
groups = {fishbait=1, fishraw=1},
inventory_image = "fishing_exoticfish_raw.png",
on_use = minetest.item_eat(2),
})
@ -66,7 +67,7 @@ minetest.register_craftitem("fishing:exoticfish_raw", {
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:carp_raw", {
description = fishing_setting.func.S("Carp"),
groups = {},
groups = {fishbait=1, fishraw=1},
inventory_image = "fishing_carp_raw.png",
on_use = minetest.item_eat(2),
})
@ -76,7 +77,7 @@ minetest.register_craftitem("fishing:carp_raw", {
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:perch_raw", {
description = fishing_setting.func.S("Perch"),
groups = {},
groups = {fishbait=1, fishraw=1},
inventory_image = "fishing_perch_raw.png",
on_use = minetest.item_eat(2),
})
@ -86,7 +87,7 @@ minetest.register_craftitem("fishing:perch_raw", {
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:catfish_raw", {
description = fishing_setting.func.S("Catfish"),
groups = {},
groups = {fishbait=1, fishraw=1},
inventory_image = "fishing_catfish_raw.png",
on_use = minetest.item_eat(2),
})
@ -97,35 +98,36 @@ minetest.register_craftitem("fishing:catfish_raw", {
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:shark_raw", {
description = fishing_setting.func.S("Shark"),
groups = {},
groups = {fishbait=1},
inventory_image = "fishing_shark_raw.png",
on_use = minetest.item_eat(2),
})
-----------------------------------------------------
-- Roasted Shark
-----------------------------------------------------
minetest.register_craftitem("fishing:shark_cooked", {
description = fishing_setting.func.S("Roasted Shark"),
groups = {},
inventory_image = "fishing_shark_cooked.png",
on_use = minetest.item_eat(6),
})
-----------------------------------------------------
-- Roasted Shark
-----------------------------------------------------
minetest.register_craftitem("fishing:shark_cooked", {
description = fishing_setting.func.S("Roasted Shark"),
groups = {},
inventory_image = "fishing_shark_cooked.png",
on_use = minetest.item_eat(6),
})
-----------------------------------------------------------------------------------------------
-- Pike
-----------------------------------------------------------------------------------------------
minetest.register_craftitem("fishing:pike_raw", {
description = fishing_setting.func.S("Northern Pike"),
groups = {},
groups = {fishbait=1},
inventory_image = "fishing_pike_raw.png",
on_use = minetest.item_eat(2),
})
-----------------------------------------------------
-- Roasted Pike
-----------------------------------------------------
minetest.register_craftitem("fishing:pike_cooked", {
description = fishing_setting.func.S("Roasted Northern Pike"),
groups = {},
inventory_image = "fishing_pike_cooked.png",
on_use = minetest.item_eat(6),
})
-----------------------------------------------------
-- Roasted Pike
-----------------------------------------------------
minetest.register_craftitem("fishing:pike_cooked", {
description = fishing_setting.func.S("Roasted Northern Pike"),
groups = {},
inventory_image = "fishing_pike_cooked.png",
on_use = minetest.item_eat(6),
})

View File

@ -370,7 +370,7 @@ function fishing_setting.func.add_to_trophies(player, fish, desc)
if inv:room_for_item("main", {name=name, count=1, wear=0, metadata=""}) then
inv:add_item("main", {name=name, count=1, wear=0, metadata=""})
else
minetest.spawn_item(player:getpos(), {name=name, count=1, wear=0, metadata=""})
minetest.spawn_item(player:get_pos(), {name=name, count=1, wear=0, metadata=""})
end
end
end
@ -452,13 +452,186 @@ function fishing_setting.func.load_contest()
end
end
function fishing_setting.func.start_contest(duration)
fishing_setting.contest["contest"] = true
fishing_setting.contest["warning_said"] = false
fishing_setting.contest["duration"] = duration
minetest.chat_send_all(S("Attention, Fishing contest start (duration %s)!!!"):format(duration))
minetest.sound_play("fishing_contest_start",{gain=0.8})
fishing_setting.func.save_contest()
fishing_setting.func.tick()
end
function fishing_setting.func.end_contest()
fishing_setting.contest["contest"] = false
fishing_setting.func.save_contest()
minetest.chat_send_all(S("End of fishing contest."))
minetest.sound_play("fishing_contest_end",{gain=0.8})
fishing_setting.func.show_result()
end
--function load planned contest from file
function fishing_setting.func.load_planned()
local file = io.open(fishing_setting.file_planned, "r")
local settings = {}
if file then
settings = minetest.deserialize(file:read("*all"))
file:close()
if settings and type(settings) == "table" then
for i, p in pairs(settings) do
if p["wday"] ~= nil and p["hour"] ~= nil and p["min"] ~= nil and p["duration"] ~= nil then
table.insert(fishing_setting.planned, {["wday"]=p["wday"], ["hour"]=p["hour"], ["min"]=p["min"], ["duration"]=p["duration"]})
end
end
end
end
end
fishing_setting.func.load_planned()
function fishing_setting.func.save_planned()
local input = io.open(fishing_setting.file_planned, "w")
if input then
input:write(minetest.serialize(fishing_setting.planned))
input:close()
else
minetest.log("action","Open failed (mode:w) of " .. fishing_setting.file_planned)
end
end
minetest.register_chatcommand("contest_add", {
params = "Wday Hours Minutes duration(in sec) (ex: 1 15 40 3600)",
description = "Add contest (admin only)",
privs = {server=true},
func = function(player_name, param)
if not player_name then return end
local wday, hour, min, duration = param:match("^(%d+)%s(%d+)%s(%d+)%s(%d+)$")
if ((not wday or not tonumber(wday)) or (not hour or not tonumber(hour)) or (not min and not tonumber(min)) or (not duration or not tonumber(duration))) then
return false, "Invalid usage, see /help contest_add."
end
wday = tonumber(wday)
hour = tonumber(hour)
min = tonumber(min)
duration = tonumber(duration)
if (wday < 0 or wday > 7) then
return false, "Invalid argument wday, 0-7 (0=all 1=Sunday)."
end
if (hour < 0 or hour > 23) then
return false, "Invalid argument hour, 0-23."
end
if (min < 0 or min > 59) then
return false, "Invalid argument minutes, 0-59."
end
if duration < 600 then
duration = 600
elseif duration > 14400 then
duration = 14400
end
table.insert(fishing_setting.planned, {["wday"]=wday, ["hour"]=hour, ["min"]=min, ["duration"]=duration})
fishing_setting.func.save_planned()
return true, ("new contest registered %d %d:%d duration %d."):format(wday, hour, min, duration)
end
})
minetest.register_chatcommand("contest_del", {
params = "List number(show by contest_show command) ",
description = "Delete planned contest(admin only)",
privs = {server=true},
func = function(player_name, param)
if not player_name then return end
local i = tonumber(param)
if not i then
return false, "Invalid usage, see /help contest_del."
end
if i < 1 then
return false, "Invalid usage, see /help contest_del."
end
local c = fishing_setting.planned[i]
if not c then
return false, "Contest no found"
end
table.remove(fishing_setting.planned, i)
fishing_setting.func.save_planned()
return true, "contest deleted"
end
})
minetest.register_chatcommand("contest_show", {
params = "",
description = "Display planned contest(admin only)",
privs = {server=true},
func = function(player_name, param)
if not player_name then return end
local text = "Registered contest:\n"
for i, plan in pairs(fishing_setting.planned) do
text = text ..("%d) wday:%d hour:%d min:%d duration %d.\n"):format(i, plan.wday, plan.hour, plan.min, plan.duration)
end
return true, text
end
})
minetest.register_chatcommand("contest_start", {
params = "Duration in seconds",
description = "Start contest (admin only)",
privs = {server=true},
func = function(player_name, param)
if not player_name then return end
if fishing_setting.contest["contest"] == true then
return false, "Contest already in progress."
end
local duration = tonumber(param)
if not duration then
duration = 3600
end
fishing_setting.contest["nb_fish"] = {}
fishing_setting.func.start_contest(duration)
return true, ("Contest started, duration:%d sec."):format(duration)
end
})
minetest.register_chatcommand("contest_stop", {
params = "",
description = "Stop contest (admin only)",
privs = {server=true},
func = function(player_name, param)
if not player_name then return end
if fishing_setting.contest["contest"] == false then
return false, "No contest in progress."
end
fishing_setting.func.end_contest()
return true, "Contest finished."
end
})
function fishing_setting.func.planned_tick()
if fishing_setting.contest["contest"] == nil or fishing_setting.contest["contest"] == false then
for i, plan in pairs(fishing_setting.planned) do
local wday = plan.wday
local hour = plan.hour
local min = plan.min
local duration = plan.duration
local time = os.date("*t",os.time())
if (wday == 0 or wday == time.wday) then
if time.hour == hour and time.min == min then
minetest.log("action", ("Starting fishing contest at %d:%d duration %d"):format( hour, min, duration))
fishing_setting.contest["nb_fish"] = {}
fishing_setting.func.start_contest(duration)
break
end
end
end
end
minetest.after(50, fishing_setting.func.planned_tick)
end
--Menu fishing configuration
fishing_setting.func.on_show_settings_contest = function(player_name)
if not fishing_setting.tmp_setting then
@ -506,12 +679,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
fishing_setting.contest["contest"] = fishing_setting.tmp_setting["contest"]
fishing_setting.contest["bobber_nb"] = fishing_setting.tmp_setting["bobber_nb"]
if progress == false and fishing_setting.tmp_setting["contest"] == true then
fishing_setting.contest["contest"] = true
fishing_setting.contest["warning_said"] = false
local time = fishing_setting.func.timetostr(fishing_setting.contest["duration"])
minetest.chat_send_all(S("Attention, Fishing contest start (duration %s)!!!"):format(time))
minetest.sound_play("fishing_contest_start",{gain=0.8})
fishing_setting.func.tick()
local duration = fishing_setting.func.timetostr(fishing_setting.contest["duration"])
fishing_setting.func.start_contest(duration)
elseif progress == true and fishing_setting.tmp_setting["contest"] == false then
fishing_setting.func.end_contest()
end
@ -617,8 +786,8 @@ minetest.register_chatcommand("fishing_menu", {
})
minetest.register_chatcommand("fishing_classement", {
params = "display classement",
description = "",
params = "",
description = "display classement",
privs = {interact=true},
func = function(player_name, param)
if not player_name then return end
@ -654,4 +823,3 @@ function fishing_setting.func.tick()
end
end
end

View File

@ -22,8 +22,10 @@ fishing_setting.is_creative_mode = minetest.setting_getbool("creative_mode")
fishing_setting.file_settings = minetest.get_worldpath() .. "/fishing_config.txt"
fishing_setting.file_trophies = minetest.get_worldpath() .. "/fishing_trophies.txt"
fishing_setting.file_contest = minetest.get_worldpath() .. "/fishing_contest.txt"
fishing_setting.file_planned = minetest.get_worldpath() .. "/fishing_planned.txt"
fishing_setting.settings = {}
fishing_setting.contest = {}
fishing_setting.planned = {}
--for random object
random_objects = {}
fishing_setting.baits = {}
@ -81,7 +83,7 @@ fishing_setting.func.load_trophies()
--load table contest
fishing_setting.func.load_contest()
fishing_setting.func.tick()
fishing_setting.func.planned_tick()
-----------------------------------------------------------------------------------------------
minetest.log("action", "[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
-----------------------------------------------------------------------------------------------

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = fishing
depends = default, farming
optional_depends = unified_inventory, moreblocks, ropes, moreores, mobs, flowers_plus, seaplants, mobs_fish, mobs_shark

View File

@ -16,9 +16,14 @@ minetest.register_craftitem("fishing:bait_worm", {
groups = { fishing_bait=1 },
inventory_image = "fishing_bait_worm.png",
on_place = function(itemstack, placer, pointed_thing)
if not placer then -- can happen, e.g. if placed using minetest.place_node
return itemstack
end
local pt = pointed_thing
minetest.add_entity({x=pt.under.x, y=pt.under.y+0.6, z=pt.under.z}, "fishing:bait_worm_entity")
itemstack:take_item()
if not minetest.is_protected(pt.under, placer:get_player_name()) then
minetest.add_entity({x=pt.under.x, y=pt.under.y+0.6, z=pt.under.z}, "fishing:bait_worm_entity")
itemstack:take_item()
end
return itemstack
end,
on_drop = function(itemstack, dropper, pos)
@ -52,11 +57,11 @@ minetest.register_entity("fishing:bait_worm_entity", {
end,
-- AI :D
on_step = function(self, dtime)
local pos = self.object:getpos()
local pos = self.object:get_pos()
-- despawn when no player in range
local remove_entity = true
for _,player in pairs(minetest.get_connected_players()) do
local p = player:getpos()
local p = player:get_pos()
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
if dist < 25 then
remove_entity = false
@ -72,24 +77,24 @@ minetest.register_entity("fishing:bait_worm_entity", {
local look_whats_up = function(self)
self.object:set_hp(self.object:get_hp()-self.damage_over_time) -- creature is getting older
if n.name == "air" then -- fall when in air
self.object:moveto({x=pos.x,y=pos.y-0.5,z=pos.z})
self.object:move_to({x=pos.x,y=pos.y-0.5,z=pos.z})
self.object:set_hp(self.object:get_hp()-75)
--if n.name == "snappy" then -- fall when leaves or similar
elseif minetest.get_item_group(n.name, "snappy") ~= 0 then
self.object:moveto({x=pos.x+(0.001*(math.random(-32, 32))),y=pos.y-(0.001*(math.random(0, 64))),z=pos.z+(0.001*(math.random(-32, 32)))})
self.object:move_to({x=pos.x+(0.001*(math.random(-32, 32))),y=pos.y-(0.001*(math.random(0, 64))),z=pos.z+(0.001*(math.random(-32, 32)))})
elseif string.find(n.name, "default:water") then -- sink when in water
self.object:moveto({x=pos.x,y=pos.y-0.25,z=pos.z})
self.object:move_to({x=pos.x,y=pos.y-0.25,z=pos.z})
self.object:set_hp(self.object:get_hp()-37)
elseif minetest.get_item_group(n.name, "soil") ~= 0 then
if minetest.get_item_group(minetest.get_node({x=pos.x,y=pos.y-0.1,z=pos.z}).name, "soil") == 0 and self.object:get_hp() > 200 then
self.object:set_hp(199)
elseif self.object:get_hp() > 200 then -- leave dirt to see whats going on
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y+0.003,z=pos.z+(0.001*(math.random(-2, 2)))})
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y+0.003,z=pos.z+(0.001*(math.random(-2, 2)))})
elseif self.object:get_hp() < 199 then -- no rain here, let's get outa here
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y-0.001,z=pos.z+(0.001*(math.random(-2, 2)))})
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y-0.001,z=pos.z+(0.001*(math.random(-2, 2)))})
elseif self.object:get_hp() == 0 then
self.object:remove()
end
@ -106,15 +111,15 @@ minetest.register_entity("fishing:bait_worm_entity", {
local goal_4a = check_group(minetest.get_node({x = pos.x, y = pos.y+0.6, z = pos.z - 1}).name, "soil")
-- if there's dirt nearby, go there
if goal_01 ~= 0 or goal_1a ~= 0 then
self.object:moveto({x=pos.x+0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
self.object:move_to({x=pos.x+0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
elseif goal_02 ~= 0 or goal_2a ~= 0 then
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z+0.002})
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z+0.002})
elseif goal_03 ~= 0 or goal_3a ~= 0 then
self.object:moveto({x=pos.x-0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
self.object:move_to({x=pos.x-0.002,y=pos.y,z=pos.z+(0.001*(math.random(-2, 2)))})
elseif goal_04 ~= 0 or goal_4a ~= 0 then
self.object:moveto({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z-0.002})
self.object:move_to({x=pos.x+(0.001*(math.random(-2, 2))),y=pos.y,z=pos.z-0.002})
else -- I'm lost, no dirt
self.object:moveto({x=pos.x+(0.001*(math.random(-8, 8))),y=pos.y,z=pos.z+(0.001*(math.random(-8, 8)))})
self.object:move_to({x=pos.x+(0.001*(math.random(-8, 8))),y=pos.y,z=pos.z+(0.001*(math.random(-8, 8)))})
end
end
end
@ -214,7 +219,7 @@ else
itemstack:add_wear(65535/(uses-1))
if itemstack:get_wear() == 0 and minetest.get_modpath("invtweak") then
local index = user:get_wield_index()
minetest.sound_play("invtweak_tool_break", {pos = user:getpos(), gain = 0.9, max_hear_distance = 5})
minetest.sound_play("invtweak_tool_break", {pos = user:get_pos(), gain = 0.9, max_hear_distance = 5})
minetest.after(0.20, refill, user, tool_name, index)
end
end