mirror of
https://github.com/MinetestForFun/fishing.git
synced 2025-01-09 18:30:16 +01:00
add bobbers limit nb to contest
add menu admin add translations
This commit is contained in:
parent
fa4df8187d
commit
48484d59bc
@ -46,14 +46,14 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||||||
-- 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 playername = puncher:get_player_name()
|
local player_name = puncher:get_player_name()
|
||||||
if playername ~= self.owner then return end
|
if player_name ~= self.owner then return end
|
||||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("You didn't catch anything."), false) end
|
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("You didn't catch 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=self.bait, 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=self.bait, count=1, wear=0, metadata=""})
|
inv:add_item("main", {name=self.bait, count=1, wear=0, metadata=""})
|
||||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("The bait is still there."), false) end
|
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("The bait is still there."), false) end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- make sound and remove bobber
|
-- make sound and remove bobber
|
||||||
@ -65,19 +65,19 @@ local FISHING_BOBBER_SHARK_ENTITY={
|
|||||||
-- WHEN RIGHTCLICKING THE BOBBER THE FOLLOWING HAPPENS (CLICK AT THE RIGHT TIME WHILE HOLDING A FISHING POLE)
|
-- WHEN RIGHTCLICKING THE BOBBER THE FOLLOWING HAPPENS (CLICK AT THE RIGHT TIME WHILE HOLDING A FISHING POLE)
|
||||||
on_rightclick = function (self, clicker)
|
on_rightclick = function (self, clicker)
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
local playername = clicker:get_player_name()
|
local player_name = clicker:get_player_name()
|
||||||
local inv = clicker:get_inventory()
|
local inv = clicker:get_inventory()
|
||||||
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 playername ~= self.owner then return end
|
if player_name ~= self.owner then return end
|
||||||
if self.prize ~= "" then
|
if self.prize ~= "" then
|
||||||
if math.random(1, 100) <= fishing_setting.settings["escape_chance"] then
|
if math.random(1, 100) <= fishing_setting.settings["escape_chance"] then
|
||||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("Your fish escaped."), false) end -- fish escaped
|
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("Your fish escaped."), false) end -- fish escaped
|
||||||
else
|
else
|
||||||
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]
|
||||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(playername, fishing_setting.func.S("You caught "..desc), false) end
|
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("You caught "..desc), false) end
|
||||||
fishing_setting.func.add_to_trophies(clicker, self.prize[2], desc)
|
fishing_setting.func.add_to_trophies(clicker, self.prize[2], desc)
|
||||||
local wear_value = fishing_setting.func.wear_value(self.prize[3])
|
local wear_value = fishing_setting.func.wear_value(self.prize[3])
|
||||||
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
|
if inv:room_for_item("main", {name=name, count=1, wear=wear_value, metadata=""}) then
|
||||||
|
207
functions.lua
207
functions.lua
@ -128,8 +128,7 @@ fishing_setting.func.on_show_settings = function(player_name)
|
|||||||
fishing_setting.tmp_setting = {}
|
fishing_setting.tmp_setting = {}
|
||||||
fishing_setting.func.set_settings(fishing_setting.tmp_setting, fishing_setting.settings)
|
fishing_setting.func.set_settings(fishing_setting.tmp_setting, fishing_setting.settings)
|
||||||
end
|
end
|
||||||
|
local formspec = "size[10.8,9]label[4,0;FISHING CONFIGURATION]"..
|
||||||
local formspec = "size[11,9]bgcolor[#99a8ba;]label[4,0;FISHING CONFIGURATION]"..
|
|
||||||
--Chance fish
|
--Chance fish
|
||||||
"label[1.6,0.5;Chance fish]"..
|
"label[1.6,0.5;Chance fish]"..
|
||||||
"button[0,1;1,1;cfish;-1]"..
|
"button[0,1;1,1;cfish;-1]"..
|
||||||
@ -159,10 +158,12 @@ fishing_setting.func.on_show_settings = function(player_name)
|
|||||||
"button[8.7,1;1,1;cworm;+10]"..
|
"button[8.7,1;1,1;cworm;+10]"..
|
||||||
"button[9.7,1;1,1;cworm;+1]"..
|
"button[9.7,1;1,1;cworm;+1]"..
|
||||||
--Chance escape
|
--Chance escape
|
||||||
"label[7.3,2;Chance escape]"..
|
"label[7.4,2;Chance escape]"..
|
||||||
"button[7,2.5;1,1;cescape;-1]"..
|
"button[6,2.5;1,1;cescape;-1]"..
|
||||||
|
"button[7,2.5;1,1;cescape;-10]"..
|
||||||
"label[8.1,2.7;"..tostring(fishing_setting.tmp_setting["escape_chance"]).."]"..
|
"label[8.1,2.7;"..tostring(fishing_setting.tmp_setting["escape_chance"]).."]"..
|
||||||
"button[8.7,2.5;1,1;cescape;+1]"..
|
"button[8.7,2.5;1,1;cescape;+10]"..
|
||||||
|
"button[9.7,2.5;1,1;cescape;+1]"..
|
||||||
--Bobber view range
|
--Bobber view range
|
||||||
"label[7.2,3.5;Bobber view range]"..
|
"label[7.2,3.5;Bobber view range]"..
|
||||||
"button[7,4;1,1;bvrange;-1]"..
|
"button[7,4;1,1;bvrange;-1]"..
|
||||||
@ -181,18 +182,16 @@ fishing_setting.func.on_show_settings = function(player_name)
|
|||||||
"label[6,5.7;Tresor enable]"..
|
"label[6,5.7;Tresor enable]"..
|
||||||
"button[9.7,5.5;1,1;tresorenable;"..tostring(fishing_setting.tmp_setting["tresor_enable"]).."]"..
|
"button[9.7,5.5;1,1;tresorenable;"..tostring(fishing_setting.tmp_setting["tresor_enable"]).."]"..
|
||||||
--NEW_WORM_SOURCE
|
--NEW_WORM_SOURCE
|
||||||
"label[6,6.5;New worm source]"..
|
"label[6,6.5;New worm source (reboot)]"..
|
||||||
"button[9.7,6.3;1,1;newworm;"..tostring(fishing_setting.tmp_setting["new_worm_source"]).."]"..
|
"button[9.7,6.3;1,1;newworm;"..tostring(fishing_setting.tmp_setting["new_worm_source"]).."]"..
|
||||||
--WORM_IS_MOB
|
--WORM_IS_MOB
|
||||||
"label[6,7.3;Worm is mob]"..
|
"label[6,7.3;Worm is mob (reboot)]"..
|
||||||
"button[9.7,7.1;1,1;wormmob;"..tostring(fishing_setting.tmp_setting["worm_is_mob"]).."]"..
|
"button[9.7,7.1;1,1;wormmob;"..tostring(fishing_setting.tmp_setting["worm_is_mob"]).."]"..
|
||||||
"button_exit[0.5,8.2;1.5,1;save;Abort]"..
|
"button_exit[0,8.2;1.5,1;save;Abort]"..
|
||||||
"button_exit[9,8.2;1.5,1;save;Ok]"
|
"button_exit[9.2,8.2;1.5,1;save;Ok]"
|
||||||
|
|
||||||
minetest.show_formspec(player_name, "fishing:settings", formspec)
|
minetest.show_formspec(player_name, "fishing:settings", formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local inc = function(value, field, min, max)
|
local inc = function(value, field, min, max)
|
||||||
local v
|
local v
|
||||||
if field == "+1" then
|
if field == "+1" then
|
||||||
@ -236,9 +235,9 @@ local bool = function(field)
|
|||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
if not player_name then return end
|
||||||
if formname == "fishing:settings" then
|
if formname == "fishing:settings" then
|
||||||
local name = player:get_player_name()
|
|
||||||
if not name then return end
|
|
||||||
if fields["save"] == "Ok" then
|
if fields["save"] == "Ok" then
|
||||||
fishing_setting.func.set_settings(fishing_setting.settings, fishing_setting.tmp_setting)
|
fishing_setting.func.set_settings(fishing_setting.settings, fishing_setting.tmp_setting)
|
||||||
fishing_setting.func.save()
|
fishing_setting.func.save()
|
||||||
@ -258,7 +257,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
elseif fields["cworm"] then
|
elseif fields["cworm"] then
|
||||||
fishing_setting.tmp_setting["worm_chance"] = inc(fishing_setting.tmp_setting["worm_chance"], fields["cworm"], 1, 100)
|
fishing_setting.tmp_setting["worm_chance"] = inc(fishing_setting.tmp_setting["worm_chance"], fields["cworm"], 1, 100)
|
||||||
elseif fields["cescape"] then
|
elseif fields["cescape"] then
|
||||||
fishing_setting.tmp_setting["escape_chance"] = inc(fishing_setting.tmp_setting["escape_chance"], fields["cescape"], 1, 30)
|
fishing_setting.tmp_setting["escape_chance"] = inc(fishing_setting.tmp_setting["escape_chance"], fields["cescape"], 1, 50)
|
||||||
elseif fields["dmessages"] then
|
elseif fields["dmessages"] then
|
||||||
fishing_setting.tmp_setting["message"] = bool(fields["dmessages"])
|
fishing_setting.tmp_setting["message"] = bool(fields["dmessages"])
|
||||||
elseif fields["poledeco"] then
|
elseif fields["poledeco"] then
|
||||||
@ -275,7 +274,16 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
fishing_setting.func.on_show_settings(name)
|
fishing_setting.func.on_show_settings(player_name)
|
||||||
|
elseif formname == "fishing:admin_conf" then
|
||||||
|
if fields["classement"] then
|
||||||
|
local formspec = fishing_setting.func.get_stat()
|
||||||
|
minetest.show_formspec(player_name, "fishing:classement", formspec)
|
||||||
|
elseif fields["concours"] then
|
||||||
|
fishing_setting.func.on_show_settings_concours(player_name)
|
||||||
|
elseif fields["configuration"] then
|
||||||
|
fishing_setting.func.on_show_settings(player_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -309,14 +317,32 @@ minetest.register_on_shutdown(function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
--[[
|
|
||||||
|
function fishing_setting.func.timetostr(time)
|
||||||
|
local countdown = time
|
||||||
|
local answer = ""
|
||||||
|
if countdown >= 3600 then
|
||||||
|
local hours = math.floor(countdown / 3600)
|
||||||
|
countdown = countdown % 3600
|
||||||
|
answer = hours .. "H"
|
||||||
|
end
|
||||||
|
if countdown >= 60 then
|
||||||
|
local minutes = math.floor(countdown / 60)
|
||||||
|
countdown = countdown % 60
|
||||||
|
answer = answer .. minutes .. "M"
|
||||||
|
end
|
||||||
|
local seconds = countdown
|
||||||
|
answer = answer .. math.floor(seconds) .. "S"
|
||||||
|
return answer
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local playername = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
-- if fishing_setting.trophies[fish][playername] == nil then
|
if fishing_setting.concours["concours"] == true then
|
||||||
-- fishing_setting.trophies[fish][playername] = { ["fish_raw"] = 0,["shark_raw"] = 0, ["pike_raw"] = 0, ["clownfish_raw"]= 0, ["bluefish_raw"] = 0 }
|
minetest.chat_send_player(player_name, fishing_setting.func.S("A fishing contest is in progress. (remaining time %s)"):format(fishing_setting.func.timetostr(fishing_setting.concours["duration"])))
|
||||||
-- end
|
end
|
||||||
end)
|
end)
|
||||||
--]]
|
|
||||||
|
|
||||||
function fishing_setting.func.add_to_trophies(player, fish, desc)
|
function fishing_setting.func.add_to_trophies(player, fish, desc)
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
@ -348,6 +374,15 @@ function fishing_setting.func.add_to_trophies(player, fish, desc)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--Menu fishing configuration
|
||||||
|
fishing_setting.func.on_show_admin_menu = function(player_name)
|
||||||
|
local formspec = "size[5,5]label[1.6,0;FISHING MENU]"..
|
||||||
|
"button[1,0.5;3,1;classement;Classement concours]"..
|
||||||
|
"button[1,1.5;3,1;concours;Concours]"..
|
||||||
|
"button[1,2.5;3,1;configuration;Configuration]"..
|
||||||
|
"button_exit[1,4.5;3,1;close;Close]"
|
||||||
|
minetest.show_formspec(player_name, "fishing:admin_conf", formspec)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if (minetest.get_modpath("unified_inventory")) then
|
if (minetest.get_modpath("unified_inventory")) then
|
||||||
@ -359,28 +394,16 @@ if (minetest.get_modpath("unified_inventory")) then
|
|||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
if not player_name then return end
|
if not player_name then return end
|
||||||
if minetest.check_player_privs(player_name, {server=true}) then
|
if minetest.check_player_privs(player_name, {server=true}) then
|
||||||
fishing_setting.func.on_show_settings(player_name)
|
fishing_setting.func.on_show_admin_menu(player_name)
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(player_name, fishing_setting.func.S("You don't have the server priviledge!"))
|
local formspec = fishing_setting.func.get_stat()
|
||||||
|
minetest.show_formspec(player_name, "fishing:classement", formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("fishing_config", {
|
|
||||||
params = "",
|
|
||||||
description = "Display fishing configuration menu (admin only)",
|
|
||||||
privs = {server=true},
|
|
||||||
func = function(player_name, param)
|
|
||||||
if not player_name then return end
|
|
||||||
fishing_setting.func.on_show_settings(player_name)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--function save settings
|
--function save settings
|
||||||
function fishing_setting.func.save_concours()
|
function fishing_setting.func.save_concours()
|
||||||
@ -397,56 +420,50 @@ end
|
|||||||
function fishing_setting.func.load_concours()
|
function fishing_setting.func.load_concours()
|
||||||
local file = io.open(fishing_setting.file_concours, "r")
|
local file = io.open(fishing_setting.file_concours, "r")
|
||||||
local settings = {}
|
local settings = {}
|
||||||
fishing_setting.concours = {["concours"] = false, ["duration"] = 3600}
|
fishing_setting.concours = {["concours"] = false, ["duration"] = 3600, ["bobber_nb"] = 4}
|
||||||
if file then
|
if file then
|
||||||
fishing_setting.concours= minetest.deserialize(file:read("*all"))
|
fishing_setting.concours= minetest.deserialize(file:read("*all"))
|
||||||
file:close()
|
file:close()
|
||||||
if settings == nil or type(settings) ~= "table" then
|
if settings == nil or type(settings) ~= "table" then
|
||||||
fishing_setting.concours = {["concours"] = false, ["duration"] = 3600}
|
fishing_setting.concours = {["concours"] = false, ["duration"] = 3600, ["bobber_nb"] = 4}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--Menu fishing configuration
|
--Menu fishing configuration
|
||||||
fishing_setting.func.on_show_settings_concours = function(player_name)
|
fishing_setting.func.on_show_settings_concours = function(player_name)
|
||||||
|
|
||||||
if not fishing_setting.tmp_setting then
|
if not fishing_setting.tmp_setting then
|
||||||
fishing_setting.tmp_setting = {["concours"] = (fishing_setting.concours["concours"] or false), ["duration"] = 3600, ["reset"] = ""}
|
fishing_setting.tmp_setting = { ["concours"] = (fishing_setting.concours["concours"] or false),
|
||||||
|
["duration"] = (math.floor(fishing_setting.concours["duration"]) or 3600),
|
||||||
|
["bobber_nb"] = (fishing_setting.concours["bobber_nb"] or 2),
|
||||||
|
["reset"] = ""
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
local formspec = "size[6.1,7]label[1.9,0;FISHING CONCOURS]"..
|
||||||
local formspec = "size[6,6]bgcolor[#99a8ba;]label[1.8,0;FISHING CONCOURS]"..
|
|
||||||
--Time concours
|
--Time concours
|
||||||
"label[2,0.5;Duration]"..
|
"label[2.2,0.5;Duration(in sec)]"..
|
||||||
"button[1,1;1,1;duration;-60]"..
|
"button[0.8,1;1,1;duration;-60]"..
|
||||||
"button[2,1;1,1;duration;-600]"..
|
"button[1.8,1;1,1;duration;-600]"..
|
||||||
"label[2.9,1.2;"..tostring(fishing_setting.tmp_setting["duration"]).."]"..
|
"label[2.7,1.2;"..tostring(fishing_setting.tmp_setting["duration"]).."]"..
|
||||||
"button[3.7,1;1,1;duration;+600]"..
|
"button[3.5,1;1,1;duration;+600]"..
|
||||||
"button[4.7,1;1,1;duration;+60]"..
|
"button[4.5,1;1,1;duration;+60]"..
|
||||||
|
--bobber nb
|
||||||
|
"label[2,2;Bobber number limit]"..
|
||||||
|
"button[1.8,2.5;1,1;bobbernb;-1]"..
|
||||||
|
"label[2.9,2.7;"..tostring(fishing_setting.tmp_setting["bobber_nb"]).."]"..
|
||||||
|
"button[3.5,2.5;1,1;bobbernb;+1]"..
|
||||||
--concours enable
|
--concours enable
|
||||||
"label[1,2.5;concours enable]"..
|
"label[0.8,3.8;concours enable]"..
|
||||||
"button[4.7,2.3;1,1;concours;"..tostring(fishing_setting.tmp_setting["concours"]).."]"..
|
"button[4.5,3.6;1,1;concours;"..tostring(fishing_setting.tmp_setting["concours"]).."]"..
|
||||||
--reset
|
--reset
|
||||||
"label[1,3.3;reset classements(type 'yes')]"..
|
"label[0.8,5.2;reset classements (type 'yes')]"..
|
||||||
"field[5,3.5;1,1;reset;;]"..
|
"field[4.8,5.4;1,1;reset;;]"..
|
||||||
|
"button_exit[0.8,6.2;1.5,1;save;Abort]"..
|
||||||
|
"button_exit[4,6.2;1.5,1;save;Ok]"
|
||||||
"button_exit[0.5,5.2;1.5,1;save;Abort]"..
|
|
||||||
"button_exit[4,5.2;1.5,1;save;Ok]"
|
|
||||||
|
|
||||||
minetest.show_formspec(player_name, "fishing:concours", formspec)
|
minetest.show_formspec(player_name, "fishing:concours", formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function timetostr(time)
|
|
||||||
--TODO transform time in H:M:S str
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return time
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
if formname == "fishing:concours" then
|
if formname == "fishing:concours" then
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
@ -463,14 +480,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
local progress = (fishing_setting.concours["concours"] or false)
|
local progress = (fishing_setting.concours["concours"] or false)
|
||||||
fishing_setting.concours["duration"] = fishing_setting.tmp_setting["duration"]
|
fishing_setting.concours["duration"] = fishing_setting.tmp_setting["duration"]
|
||||||
fishing_setting.concours["concours"] = fishing_setting.tmp_setting["concours"]
|
fishing_setting.concours["concours"] = fishing_setting.tmp_setting["concours"]
|
||||||
|
fishing_setting.concours["bobber_nb"] = fishing_setting.tmp_setting["bobber_nb"]
|
||||||
if progress == false and fishing_setting.tmp_setting["concours"] == true then
|
if progress == false and fishing_setting.tmp_setting["concours"] == true then
|
||||||
fishing_setting.concours["concours"] = true
|
fishing_setting.concours["concours"] = true
|
||||||
fishing_setting.concours["warning_said"] = false
|
fishing_setting.concours["warning_said"] = false
|
||||||
--TODO show time in H:M:S
|
--TODO show time in H:M:S
|
||||||
local time = timetostr(fishing_setting.concours["duration"])
|
local time = fishing_setting.func.timetostr(fishing_setting.concours["duration"])
|
||||||
minetest.chat_send_all(fishing_setting.func.S("Attention, Fishing contest go(duration %s)!!!"):format(time))
|
minetest.chat_send_all(fishing_setting.func.S("Attention, Fishing contest start (duration %s)!!!"):format(time))
|
||||||
--TODO play sound go contest
|
--TODO play sound go contest
|
||||||
|
minetest.sound_play("fishing_contest_depart",{gain=0.8})
|
||||||
|
|
||||||
elseif progress == true and fishing_setting.tmp_setting["concours"] == false then
|
elseif progress == true and fishing_setting.tmp_setting["concours"] == false then
|
||||||
fishing_setting.concours["concours"] = false
|
fishing_setting.concours["concours"] = false
|
||||||
@ -485,6 +503,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
fishing_setting.tmp_setting["duration"] = inc(fishing_setting.tmp_setting["duration"], fields["duration"], 120, 14400)
|
fishing_setting.tmp_setting["duration"] = inc(fishing_setting.tmp_setting["duration"], fields["duration"], 120, 14400)
|
||||||
elseif fields["concours"] then
|
elseif fields["concours"] then
|
||||||
fishing_setting.tmp_setting["concours"] = bool(fields["concours"])
|
fishing_setting.tmp_setting["concours"] = bool(fields["concours"])
|
||||||
|
elseif fields["bobbernb"] then
|
||||||
|
fishing_setting.tmp_setting["bobber_nb"] = inc(fishing_setting.tmp_setting["bobber_nb"], fields["bobbernb"], 1, 8)
|
||||||
else
|
else
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -493,17 +513,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("fishing_concours", {
|
|
||||||
params = "fishing_concours <true|false> <time-in-sec>",
|
|
||||||
description = "enable|disable fishing concours (admin only)",
|
|
||||||
privs = {server=true},
|
|
||||||
func = function(player_name, param)
|
|
||||||
if not player_name then return end
|
|
||||||
fishing_setting.func.on_show_settings_concours(player_name)
|
|
||||||
end
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
function spairs(t, order)
|
function spairs(t, order)
|
||||||
-- collect the keys
|
-- collect the keys
|
||||||
local keys = {}
|
local keys = {}
|
||||||
@ -526,7 +535,6 @@ function spairs(t, order)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function fishing_setting.func.set_winners(list)
|
function fishing_setting.func.set_winners(list)
|
||||||
local win = {}
|
local win = {}
|
||||||
local i = 1
|
local i = 1
|
||||||
@ -541,10 +549,6 @@ function fishing_setting.func.set_winners(list)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function fishing_setting.func.get_stat()
|
function fishing_setting.func.get_stat()
|
||||||
local winners= {}
|
local winners= {}
|
||||||
for k,v in pairs(fishing_setting.concours) do
|
for k,v in pairs(fishing_setting.concours) do
|
||||||
@ -553,14 +557,14 @@ function fishing_setting.func.get_stat()
|
|||||||
winners[k] = fishing_setting.func.set_winners(fishing_setting.concours[k])
|
winners[k] = fishing_setting.func.set_winners(fishing_setting.concours[k])
|
||||||
else
|
else
|
||||||
winners[k] = {}
|
winners[k] = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local formspec = {"size[12,8]bgcolor[#99a8ba;]label[3.5,0;FISHING CONCOURS CLASSEMENT]"}
|
local formspec = {"size[12,8]label[3.7,0;FISHING CONCOURS CLASSEMENT]"}
|
||||||
local X = 0
|
local X = 0
|
||||||
local Y
|
local Y
|
||||||
for fish, fishers in pairs(winners) do
|
for fish, fishers in pairs(winners) do
|
||||||
Y = 1.4
|
Y = 1.1
|
||||||
table.insert(formspec, "label["..(X+0.4)..",0.5;"..string.gsub(fish, "_raw", ""):upper().."]") --fish name
|
table.insert(formspec, "label["..(X+0.4)..",0.5;"..string.gsub(fish, "_raw", ""):upper().."]") --fish name
|
||||||
for _,s in ipairs(fishers) do
|
for _,s in ipairs(fishers) do
|
||||||
for pl,nb in pairs(s) do
|
for pl,nb in pairs(s) do
|
||||||
@ -571,30 +575,38 @@ function fishing_setting.func.get_stat()
|
|||||||
end
|
end
|
||||||
X = X + 2.3
|
X = X + 2.3
|
||||||
end
|
end
|
||||||
|
table.insert(formspec, "button_exit[5.5,7.5;1.2,1;close;CLose]")
|
||||||
return table.concat(formspec)
|
return table.concat(formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.register_chatcommand("fishing_class", {
|
minetest.register_chatcommand("fishing_menu", {
|
||||||
|
params = "",
|
||||||
|
description = "Show fishing menu (admin only)",
|
||||||
|
privs = {server=true},
|
||||||
|
func = function(player_name, param)
|
||||||
|
if not player_name then return end
|
||||||
|
fishing_setting.func.on_show_admin_menu(player_name)
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_chatcommand("fishing_classement", {
|
||||||
params = "display classement",
|
params = "display classement",
|
||||||
description = "",
|
description = "",
|
||||||
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
|
||||||
local formspec = fishing_setting.func.get_stat()
|
local formspec = fishing_setting.func.get_stat()
|
||||||
|
|
||||||
minetest.show_formspec(player_name, "fishing:classement", formspec)
|
minetest.show_formspec(player_name, "fishing:classement", formspec)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
local function show_result()
|
local function show_result()
|
||||||
minetest.after(3, function()
|
minetest.after(3, function()
|
||||||
print("debug1")
|
|
||||||
local formspec = fishing_setting.func.get_stat()
|
local formspec = fishing_setting.func.get_stat()
|
||||||
for _,player in pairs(minetest.get_connected_players()) do
|
for _,player in pairs(minetest.get_connected_players()) do
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
if player_name ~= nil then
|
if player_name ~= nil then
|
||||||
print("debug2")
|
|
||||||
minetest.show_formspec(player_name, "fishing:classement", formspec)
|
minetest.show_formspec(player_name, "fishing:classement", formspec)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -606,11 +618,12 @@ minetest.register_globalstep(function(dtime)
|
|||||||
fishing_setting.concours["duration"] = fishing_setting.concours["duration"] - dtime
|
fishing_setting.concours["duration"] = fishing_setting.concours["duration"] - dtime
|
||||||
|
|
||||||
if fishing_setting.concours["duration"] < 30 and fishing_setting.concours["warning_said"] ~= true then
|
if fishing_setting.concours["duration"] < 30 and fishing_setting.concours["warning_said"] ~= true then
|
||||||
minetest.chat_send_all("WARNING, Fishing contest will finish in 30 seconds")
|
minetest.chat_send_all(fishing_setting.func.S("WARNING, Fishing contest will finish in 30 seconds."))
|
||||||
fishing_setting.concours["warning_said"] = true
|
fishing_setting.concours["warning_said"] = true
|
||||||
end
|
end
|
||||||
if fishing_setting.concours["duration"] < 0 then
|
if fishing_setting.concours["duration"] < 0 then
|
||||||
minetest.chat_send_all("End of fishing contest")
|
minetest.chat_send_all(fishing_setting.func.S("End of fishing contest."))
|
||||||
|
minetest.sound_play("fishing_contest_end",{gain=0.8})
|
||||||
fishing_setting.concours["concours"] = false
|
fishing_setting.concours["concours"] = false
|
||||||
show_result()
|
show_result()
|
||||||
end
|
end
|
||||||
|
6
locale/fr.txt
Executable file → Normal file
6
locale/fr.txt
Executable file → Normal file
@ -64,7 +64,10 @@ Yeah, %s catch a Clownfish. = Wouah, %s a attrappe un poisson clown.
|
|||||||
Yeah, %s catch a Bluefish. = Wouah, %s a attrappe un poisson bleu.
|
Yeah, %s catch a Bluefish. = Wouah, %s a attrappe un poisson bleu.
|
||||||
Yeah, %s catch a Northern Pike. = Wouah, %s a attrappe un brochet.
|
Yeah, %s catch a Northern Pike. = Wouah, %s a attrappe un brochet.
|
||||||
Yeah, %s catch a small Shark. = Wouah, %s a attrappe un requin.
|
Yeah, %s catch a small Shark. = Wouah, %s a attrappe un requin.
|
||||||
|
A fishing contest is in progress. (remaining time %s) = Un concour de peche est en cours. (temps restant %s)
|
||||||
|
Attention, Fishing contest start(duration %s)!!! = Attention, un concours de peche viens de commence(duree %s)!!!
|
||||||
|
WARNING, Fishing contest will finish in 30 seconds. = Attention, le concours de peche se termine dans 30 secondes
|
||||||
|
End of fishing contest. = Le concours est fini
|
||||||
|
|
||||||
### material.lua ###
|
### material.lua ###
|
||||||
View information about hunger fish = Afficher les informations sur la faim des poissons
|
View information about hunger fish = Afficher les informations sur la faim des poissons
|
||||||
@ -74,6 +77,7 @@ View information about hunger fish = Afficher les informations sur la faim des p
|
|||||||
Fishing Pole = Canne a peche
|
Fishing Pole = Canne a peche
|
||||||
Perfect Fishing Pole = Canne a peche parfaite
|
Perfect Fishing Pole = Canne a peche parfaite
|
||||||
You don't fishing in a bottle! = Vous ne pouvez pas pecher dans une bouteille!
|
You don't fishing in a bottle! = Vous ne pouvez pas pecher dans une bouteille!
|
||||||
|
You don't have mores %s bobbers! = Vous ne pouvez pas avoir plus de %s flotteurs
|
||||||
|
|
||||||
### trophies.lua ###
|
### trophies.lua ###
|
||||||
Fish Trophy = Trophee poisson
|
Fish Trophy = Trophee poisson
|
||||||
|
6
locale/template.txt
Executable file → Normal file
6
locale/template.txt
Executable file → Normal file
@ -63,7 +63,10 @@ Yeah, %s catch a Clownfish. =
|
|||||||
Yeah, %s catch a Bluefish. =
|
Yeah, %s catch a Bluefish. =
|
||||||
Yeah, %s catch a Northern Pike. =
|
Yeah, %s catch a Northern Pike. =
|
||||||
Yeah, %s catch a small Shark. =
|
Yeah, %s catch a small Shark. =
|
||||||
|
A fishing contest is in progress. (remaining time %s) =
|
||||||
|
Attention, Fishing contest start(duration %s)!!! =
|
||||||
|
WARNING, Fishing contest will finish in 30 seconds. =
|
||||||
|
End of fishing contest. =
|
||||||
|
|
||||||
### material.lua ###
|
### material.lua ###
|
||||||
Show information about hunger fish =
|
Show information about hunger fish =
|
||||||
@ -73,6 +76,7 @@ Show information about hunger fish =
|
|||||||
Fishing Pole =
|
Fishing Pole =
|
||||||
Perfect Fishing Pole =
|
Perfect Fishing Pole =
|
||||||
You don't fishing in a bottle! =
|
You don't fishing in a bottle! =
|
||||||
|
You don't have mores %s bobbers! =
|
||||||
|
|
||||||
### trophies.lua ###
|
### trophies.lua ###
|
||||||
Fish Trophy =
|
Fish Trophy =
|
||||||
|
24
poles.lua
Executable file → Normal file
24
poles.lua
Executable file → Normal file
@ -26,11 +26,29 @@ for _,pole in pairs(fishing_setting.poles) do
|
|||||||
local pt = pointed_thing
|
local pt = pointed_thing
|
||||||
local node = minetest.get_node(pt.under)
|
local node = minetest.get_node(pt.under)
|
||||||
if not node or string.find(node.name, "water_source") == nil then return nil end
|
if not node or string.find(node.name, "water_source") == nil then return nil end
|
||||||
local player = user:get_player_name()
|
local player_name = 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()
|
||||||
if fishing_setting.baits[bait] == nil then return nil end
|
if fishing_setting.baits[bait] == nil then return nil end
|
||||||
|
|
||||||
|
--if contest then player must have only 2 boober
|
||||||
|
local bobber_nb = 0
|
||||||
|
if fishing_setting.concours["concours"] ~= nil and fishing_setting.concours["concours"] == true then
|
||||||
|
for m, obj in pairs(minetest.get_objects_inside_radius(pt.under, 20)) do
|
||||||
|
if obj:get_luaentity() ~= nil and string.find(obj:get_luaentity().name, "fishing:bobber") ~= nil then
|
||||||
|
if obj:get_luaentity().owner == player_name then
|
||||||
|
bobber_nb = bobber_nb + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if bobber_nb >= fishing_setting.concours["bobber_nb"] then
|
||||||
|
if fishing_setting.settings["message"] == true then
|
||||||
|
minetest.chat_send_player(player_name, fishing_setting.func.S("You don't have mores %s bobbers!"):format(fishing_setting.concours["bobber_nb"]))
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local bobbers = {}
|
local bobbers = {}
|
||||||
local objs = minetest.get_objects_inside_radius(pt.under, 3)
|
local objs = minetest.get_objects_inside_radius(pt.under, 3)
|
||||||
@ -65,7 +83,7 @@ for _,pole in pairs(fishing_setting.poles) do
|
|||||||
end
|
end
|
||||||
--if water == -3 nodes
|
--if water == -3 nodes
|
||||||
if #nodes < 2 then
|
if #nodes < 2 then
|
||||||
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player, fishing_setting.func.S("You don't fishing in a bottle!")) end
|
if fishing_setting.settings["message"] == true then minetest.chat_send_player(player_name, fishing_setting.func.S("You don't fishing in a bottle!")) end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local new_pos = nodes[math.random(1, #nodes)]
|
local new_pos = nodes[math.random(1, #nodes)]
|
||||||
@ -73,7 +91,7 @@ for _,pole in pairs(fishing_setting.poles) do
|
|||||||
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_name
|
||||||
luaentity.bait = bait
|
luaentity.bait = bait
|
||||||
luaentity.old_pos = new_pos
|
luaentity.old_pos = new_pos
|
||||||
luaentity.old_pos2 = true
|
luaentity.old_pos2 = true
|
||||||
|
Loading…
Reference in New Issue
Block a user