From 911cd00cec5b8bf1f959e4b2b5ecefdf6de9867d Mon Sep 17 00:00:00 2001 From: Vitaliy Olkhin Date: Mon, 12 Feb 2024 17:12:12 +0500 Subject: [PATCH] update jail v1 --- init.lua | 40 +++++++++++++++++++++++++++++----------- locale/jail.ru.tr | 4 +++- mod.conf | 3 ++- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/init.lua b/init.lua index 8d145ea..5eabe74 100644 --- a/init.lua +++ b/init.lua @@ -2,6 +2,7 @@ local S = minetest.get_translator("jail") jail = {} jail.escape_boundary = 50 --радиус обхвата тюрмы jail.display_node = { x = 675, y = 3.55, z = 5 } +jail.forced_labor = {y = -14848} --Начало глубины принудительных работ local jailpos = { x = 690, y = 5, z = -7 } local releasepos = { x = 684, y = 5, z = -7 } local timer = 0 @@ -18,6 +19,13 @@ for line in prisoners:gmatch("[^\n]+") do table.insert(prisoners_list, line) end +jail.set_permissions_for_the_jail = function (player) + minetest.set_player_privs(player, { + interact = true, + shout = true, + }) +end + minetest.register_chatcommand("jail", { params = "", description = S("Sends a player to Jail"), @@ -36,10 +44,7 @@ minetest.register_chatcommand("jail", { minetest.chat_send_player(param, minetest.colorize("red", S("You have been sent to jail"))) minetest.chat_send_all(minetest.colorize("red", "" .. param .. " " .. S("has been sent to jail by") .. " " .. name)) - minetest.set_player_privs(param, { - interact = true, - shout = true, - }) + jail.set_permissions_for_the_jail(param) end end, }) @@ -135,7 +140,10 @@ minetest.register_on_shutdown(function() mod_storage:set_string("prisoners", prisoners) end) + minetest.register_globalstep(function(dtime) + local forced_labor = 0 + -- every 5 seconds if timer > os.time() then return @@ -151,18 +159,28 @@ minetest.register_globalstep(function(dtime) local max_pos_x = jail.display_node.x + jail.escape_boundary local min_pos_x = jail.display_node.x - jail.escape_boundary local max_pos_y = jail.display_node.y + jail.escape_boundary - local min_pos_y = jail.display_node.y - jail.escape_boundary local max_pos_z = jail.display_node.z + jail.escape_boundary local min_pos_z = jail.display_node.z - jail.escape_boundary - if (max_pos_x < pos.x or pos.x < min_pos_x) or max_pos_y < pos.y or pos.y < min_pos_y or max_pos_z < pos.z or pos.z < min_pos_z then + forced_labor = jail.forced_labor.y + 1000 + if (max_pos_x < pos.x or pos.x < min_pos_x or max_pos_z < pos.z or pos.z < min_pos_z) and pos.y > -5 then object:set_pos(jailpos) - - minetest.set_player_privs(prisoners_list[i], { - interact = true, - shout = true, - }) minetest.chat_send_all(minetest.colorize("red", S("Escape attempt: ") .. prisoners_list[i])) + jail.set_permissions_for_the_jail(prisoners_list[i]) + end + + --Проверка если игрок копает в низ по кординатам тюрьмы + if pos.y < -5 and pos.y > forced_labor then + object:set_pos(jailpos) + minetest.chat_send_all(minetest.colorize("red", prisoners_list[i] .. S(": He dug under the prison"))) + jail.set_permissions_for_the_jail(prisoners_list[i]) + end + + --Условие если игрок находится взаданом параметре jail.forced_labor.y под землей + if pos.y > jail.forced_labor.y and pos.y < -10 then + object:set_pos(jailpos) + minetest.chat_send_player(prisoners_list[i], minetest.colorize("red", S("You are prohibited from leaving this area"))) + jail.set_permissions_for_the_jail(prisoners_list[i]) end end end diff --git a/locale/jail.ru.tr b/locale/jail.ru.tr index 8816f44..b1e249d 100644 --- a/locale/jail.ru.tr +++ b/locale/jail.ru.tr @@ -19,4 +19,6 @@ Total number of prisoners:=Общее число заключенных: Show border=Показать границу Border display=Отображение границы The border is hidden=Граница скрыта -Escape attempt: =Попытка побега: \ No newline at end of file +Escape attempt: =Попытка побега: +: He dug under the prison=: Совершил подкоп под тюрьмой +You are prohibited from leaving this area=Вам запрещается покидать данный участок \ No newline at end of file diff --git a/mod.conf b/mod.conf index f0676c6..2fbf1b1 100644 --- a/mod.conf +++ b/mod.conf @@ -2,4 +2,5 @@ name = jail description = Adds jail for game depends = default min_minetest_version = 5.7 -title = Jail \ No newline at end of file +title = Jail +release = 1 \ No newline at end of file