mirror of
https://github.com/MinetestForFun/fishing.git
synced 2025-07-19 16:50:23 +02:00
Compare commits
6 Commits
v1.0.0
...
091611b1cd
Author | SHA1 | Date | |
---|---|---|---|
091611b1cd | |||
7a88dd9e1f | |||
d0a79be624 | |||
bc37d001c6 | |||
26f79a8f36 | |||
2389efbc87 |
18
README.md
18
README.md
@ -4,13 +4,13 @@
|
|||||||
### Original by Mossmanikin https://github.com/Mossmanikin/fishing
|
### Original by Mossmanikin https://github.com/Mossmanikin/fishing
|
||||||
### Rewrited by Crabman77 (MFF team)
|
### Rewrited by Crabman77 (MFF team)
|
||||||
|
|
||||||
###9 fish type
|
### **9 fish type**
|
||||||
**fish in rivers**
|
**fish in rivers**
|
||||||
> - 2 small fish (fish, carp)
|
> - 2 small fish (fish, carp)
|
||||||
> - 3 predator fish (perch, catfish, Northern Pike)
|
> - 3 predator fish (perch, catfish, Northern Pike)
|
||||||
|
|
||||||
**fish in sea**
|
**fish in sea**
|
||||||
>- 3 small fish (clownfish,bluewhite fish, exotic fish)
|
> - 3 small fish (clownfish,bluewhite fish, exotic fish)
|
||||||
> - 1 predator fish (small shark)
|
> - 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
|
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%
|
Baitball improves lucky bait of 20%
|
||||||
|
|
||||||
###**Contest Game **
|
### **Contest Game **
|
||||||
Contest game can be launched by admin, duration variable 2min to 4heures
|
Contest game can be launched by admin, duration variable 2min to 4heures
|
||||||
Start/End is announced in chat and sound
|
Start/End is announced in chat and sound
|
||||||
A ranking appears(formspec) after contest
|
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
|
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)
|
[demo video youtube](https://youtu.be/8rt8g3F2Gmk)
|
||||||
|
|
||||||
|
|
||||||
|
31
baitball.lua
31
baitball.lua
@ -24,35 +24,6 @@ minetest.register_craftitem("fishing:baitball_shark", {
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shapeless",
|
||||||
output = "fishing:baitball_shark 20",
|
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"}
|
|
||||||
})
|
|
||||||
|
151
crafting.lua
151
crafting.lua
@ -82,49 +82,7 @@ minetest.register_craft({
|
|||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "cooking",
|
type = "cooking",
|
||||||
output = "fishing:fish_cooked",
|
output = "fishing:fish_cooked",
|
||||||
recipe = "fishing:fish_raw",
|
recipe = "group:fishraw",
|
||||||
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",
|
|
||||||
cooktime = 2,
|
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"}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
92
fishes.lua
92
fishes.lua
@ -9,35 +9,36 @@
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:fish_raw", {
|
minetest.register_craftitem("fishing:fish_raw", {
|
||||||
description = fishing_setting.func.S("Fish"),
|
description = fishing_setting.func.S("Fish"),
|
||||||
groups = {},
|
groups = {fishbait=1, fishraw=1},
|
||||||
inventory_image = "fishing_fish_raw.png",
|
inventory_image = "fishing_fish_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
-----------------------------------------------------
|
|
||||||
-- Roasted Fish
|
-----------------------------------------------------
|
||||||
-----------------------------------------------------
|
-- Roasted Fish
|
||||||
minetest.register_craftitem("fishing:fish_cooked", {
|
-----------------------------------------------------
|
||||||
description = fishing_setting.func.S("Roasted Fish"),
|
minetest.register_craftitem("fishing:fish_cooked", {
|
||||||
groups = {},
|
description = fishing_setting.func.S("Roasted Fish"),
|
||||||
inventory_image = "fishing_fish_cooked.png",
|
groups = {},
|
||||||
on_use = minetest.item_eat(4),
|
inventory_image = "fishing_fish_cooked.png",
|
||||||
})
|
on_use = minetest.item_eat(4),
|
||||||
-----------------------------------------------------
|
})
|
||||||
-- Sushi
|
-----------------------------------------------------
|
||||||
-----------------------------------------------------
|
-- Sushi
|
||||||
minetest.register_craftitem("fishing:sushi", {
|
-----------------------------------------------------
|
||||||
description = fishing_setting.func.S("Sushi (Hoso Maki)"),
|
minetest.register_craftitem("fishing:sushi", {
|
||||||
groups = {},
|
description = fishing_setting.func.S("Sushi (Hoso Maki)"),
|
||||||
inventory_image = "fishing_sushi.png",
|
groups = {},
|
||||||
on_use = minetest.item_eat(6),
|
inventory_image = "fishing_sushi.png",
|
||||||
})
|
on_use = minetest.item_eat(6),
|
||||||
|
})
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
-- clownfish
|
-- clownfish
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:clownfish_raw", {
|
minetest.register_craftitem("fishing:clownfish_raw", {
|
||||||
description = fishing_setting.func.S("Clownfish"),
|
description = fishing_setting.func.S("Clownfish"),
|
||||||
groups = {},
|
groups = {fishbait=1, fishraw=1},
|
||||||
inventory_image = "fishing_clownfish_raw.png",
|
inventory_image = "fishing_clownfish_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
@ -47,7 +48,7 @@ minetest.register_craftitem("fishing:clownfish_raw", {
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:bluewhite_raw", {
|
minetest.register_craftitem("fishing:bluewhite_raw", {
|
||||||
description = fishing_setting.func.S("Bluewhite"),
|
description = fishing_setting.func.S("Bluewhite"),
|
||||||
groups = {},
|
groups = {fishbait=1, fishraw=1},
|
||||||
inventory_image = "fishing_bluewhite_raw.png",
|
inventory_image = "fishing_bluewhite_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
@ -56,7 +57,7 @@ minetest.register_craftitem("fishing:bluewhite_raw", {
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:exoticfish_raw", {
|
minetest.register_craftitem("fishing:exoticfish_raw", {
|
||||||
description = fishing_setting.func.S("Exotic"),
|
description = fishing_setting.func.S("Exotic"),
|
||||||
groups = {},
|
groups = {fishbait=1, fishraw=1},
|
||||||
inventory_image = "fishing_exoticfish_raw.png",
|
inventory_image = "fishing_exoticfish_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
@ -66,7 +67,7 @@ minetest.register_craftitem("fishing:exoticfish_raw", {
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:carp_raw", {
|
minetest.register_craftitem("fishing:carp_raw", {
|
||||||
description = fishing_setting.func.S("Carp"),
|
description = fishing_setting.func.S("Carp"),
|
||||||
groups = {},
|
groups = {fishbait=1, fishraw=1},
|
||||||
inventory_image = "fishing_carp_raw.png",
|
inventory_image = "fishing_carp_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
@ -76,7 +77,7 @@ minetest.register_craftitem("fishing:carp_raw", {
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:perch_raw", {
|
minetest.register_craftitem("fishing:perch_raw", {
|
||||||
description = fishing_setting.func.S("Perch"),
|
description = fishing_setting.func.S("Perch"),
|
||||||
groups = {},
|
groups = {fishbait=1, fishraw=1},
|
||||||
inventory_image = "fishing_perch_raw.png",
|
inventory_image = "fishing_perch_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
@ -86,7 +87,7 @@ minetest.register_craftitem("fishing:perch_raw", {
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:catfish_raw", {
|
minetest.register_craftitem("fishing:catfish_raw", {
|
||||||
description = fishing_setting.func.S("Catfish"),
|
description = fishing_setting.func.S("Catfish"),
|
||||||
groups = {},
|
groups = {fishbait=1, fishraw=1},
|
||||||
inventory_image = "fishing_catfish_raw.png",
|
inventory_image = "fishing_catfish_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
@ -97,35 +98,36 @@ minetest.register_craftitem("fishing:catfish_raw", {
|
|||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:shark_raw", {
|
minetest.register_craftitem("fishing:shark_raw", {
|
||||||
description = fishing_setting.func.S("Shark"),
|
description = fishing_setting.func.S("Shark"),
|
||||||
groups = {},
|
groups = {fishbait=1},
|
||||||
inventory_image = "fishing_shark_raw.png",
|
inventory_image = "fishing_shark_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
-----------------------------------------------------
|
|
||||||
-- Roasted Shark
|
-----------------------------------------------------
|
||||||
-----------------------------------------------------
|
-- Roasted Shark
|
||||||
minetest.register_craftitem("fishing:shark_cooked", {
|
-----------------------------------------------------
|
||||||
description = fishing_setting.func.S("Roasted Shark"),
|
minetest.register_craftitem("fishing:shark_cooked", {
|
||||||
groups = {},
|
description = fishing_setting.func.S("Roasted Shark"),
|
||||||
inventory_image = "fishing_shark_cooked.png",
|
groups = {},
|
||||||
on_use = minetest.item_eat(6),
|
inventory_image = "fishing_shark_cooked.png",
|
||||||
})
|
on_use = minetest.item_eat(6),
|
||||||
|
})
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
-- Pike
|
-- Pike
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:pike_raw", {
|
minetest.register_craftitem("fishing:pike_raw", {
|
||||||
description = fishing_setting.func.S("Northern Pike"),
|
description = fishing_setting.func.S("Northern Pike"),
|
||||||
groups = {},
|
groups = {fishbait=1},
|
||||||
inventory_image = "fishing_pike_raw.png",
|
inventory_image = "fishing_pike_raw.png",
|
||||||
on_use = minetest.item_eat(2),
|
on_use = minetest.item_eat(2),
|
||||||
})
|
})
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
-- Roasted Pike
|
-- Roasted Pike
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
minetest.register_craftitem("fishing:pike_cooked", {
|
minetest.register_craftitem("fishing:pike_cooked", {
|
||||||
description = fishing_setting.func.S("Roasted Northern Pike"),
|
description = fishing_setting.func.S("Roasted Northern Pike"),
|
||||||
groups = {},
|
groups = {},
|
||||||
inventory_image = "fishing_pike_cooked.png",
|
inventory_image = "fishing_pike_cooked.png",
|
||||||
on_use = minetest.item_eat(6),
|
on_use = minetest.item_eat(6),
|
||||||
})
|
})
|
||||||
|
186
functions.lua
186
functions.lua
@ -452,13 +452,187 @@ function fishing_setting.func.load_contest()
|
|||||||
end
|
end
|
||||||
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()
|
function fishing_setting.func.end_contest()
|
||||||
fishing_setting.contest["contest"] = false
|
fishing_setting.contest["contest"] = false
|
||||||
|
fishing_setting.func.save_contest()
|
||||||
minetest.chat_send_all(S("End of fishing contest."))
|
minetest.chat_send_all(S("End of fishing contest."))
|
||||||
minetest.sound_play("fishing_contest_end",{gain=0.8})
|
minetest.sound_play("fishing_contest_end",{gain=0.8})
|
||||||
fishing_setting.func.show_result()
|
fishing_setting.func.show_result()
|
||||||
end
|
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
|
--Menu fishing configuration
|
||||||
fishing_setting.func.on_show_settings_contest = function(player_name)
|
fishing_setting.func.on_show_settings_contest = function(player_name)
|
||||||
if not fishing_setting.tmp_setting then
|
if not fishing_setting.tmp_setting then
|
||||||
@ -506,12 +680,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
fishing_setting.contest["contest"] = fishing_setting.tmp_setting["contest"]
|
fishing_setting.contest["contest"] = fishing_setting.tmp_setting["contest"]
|
||||||
fishing_setting.contest["bobber_nb"] = fishing_setting.tmp_setting["bobber_nb"]
|
fishing_setting.contest["bobber_nb"] = fishing_setting.tmp_setting["bobber_nb"]
|
||||||
if progress == false and fishing_setting.tmp_setting["contest"] == true then
|
if progress == false and fishing_setting.tmp_setting["contest"] == true then
|
||||||
fishing_setting.contest["contest"] = true
|
local duration = fishing_setting.func.timetostr(fishing_setting.contest["duration"])
|
||||||
fishing_setting.contest["warning_said"] = false
|
fishing_setting.func.start_contest(duration)
|
||||||
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()
|
|
||||||
elseif progress == true and fishing_setting.tmp_setting["contest"] == false then
|
elseif progress == true and fishing_setting.tmp_setting["contest"] == false then
|
||||||
fishing_setting.func.end_contest()
|
fishing_setting.func.end_contest()
|
||||||
end
|
end
|
||||||
@ -617,8 +787,8 @@ minetest.register_chatcommand("fishing_menu", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_chatcommand("fishing_classement", {
|
minetest.register_chatcommand("fishing_classement", {
|
||||||
params = "display classement",
|
params = "",
|
||||||
description = "",
|
description = "display classement",
|
||||||
privs = {interact=true},
|
privs = {interact=true},
|
||||||
func = function(player_name, param)
|
func = function(player_name, param)
|
||||||
if not player_name then return end
|
if not player_name then return end
|
||||||
|
4
init.lua
4
init.lua
@ -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_settings = minetest.get_worldpath() .. "/fishing_config.txt"
|
||||||
fishing_setting.file_trophies = minetest.get_worldpath() .. "/fishing_trophies.txt"
|
fishing_setting.file_trophies = minetest.get_worldpath() .. "/fishing_trophies.txt"
|
||||||
fishing_setting.file_contest = minetest.get_worldpath() .. "/fishing_contest.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.settings = {}
|
||||||
fishing_setting.contest = {}
|
fishing_setting.contest = {}
|
||||||
|
fishing_setting.planned = {}
|
||||||
--for random object
|
--for random object
|
||||||
random_objects = {}
|
random_objects = {}
|
||||||
fishing_setting.baits = {}
|
fishing_setting.baits = {}
|
||||||
@ -81,7 +83,7 @@ fishing_setting.func.load_trophies()
|
|||||||
--load table contest
|
--load table contest
|
||||||
fishing_setting.func.load_contest()
|
fishing_setting.func.load_contest()
|
||||||
fishing_setting.func.tick()
|
fishing_setting.func.tick()
|
||||||
|
fishing_setting.func.planned_tick()
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
minetest.log("action", "[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
|
minetest.log("action", "[Mod] "..title.." ["..version.."] ["..mname.."] Loaded...")
|
||||||
-----------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------
|
||||||
|
@ -16,9 +16,14 @@ minetest.register_craftitem("fishing:bait_worm", {
|
|||||||
groups = { fishing_bait=1 },
|
groups = { fishing_bait=1 },
|
||||||
inventory_image = "fishing_bait_worm.png",
|
inventory_image = "fishing_bait_worm.png",
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
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
|
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")
|
if not minetest.is_protected(pt.under, placer:get_player_name()) then
|
||||||
itemstack:take_item()
|
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
|
return itemstack
|
||||||
end,
|
end,
|
||||||
on_drop = function(itemstack, dropper, pos)
|
on_drop = function(itemstack, dropper, pos)
|
||||||
|
Reference in New Issue
Block a user