Compare commits

...

5 Commits

5 changed files with 87 additions and 43 deletions

View File

@ -81,6 +81,7 @@ arena_lib.on_end("skywars", function(arena, players)
remove_privs(pl_name)
skywars.remove_HUD(arena, pl_name)
skywars.remove_armor(player)
minetest.close_formspec(pl_name, "")
end
end)
@ -135,7 +136,6 @@ end)
arena_lib.on_disconnect("skywars", function(arena, pl_name)
local player = minetest.get_player_by_name(pl_name)
skywars.update_players_counter(arena, false)
end)
@ -257,7 +257,7 @@ function create_barrier_cage(player)
}
player:set_physics_override({gravity=0, jump=0})
player:add_player_velocity(vector.multiply(player:get_player_velocity(), -1))
player:add_velocity(vector.multiply(player:get_velocity(), -1))
for _, relative_pos in pairs(glass_nodes) do
local node_pos = vector.round(vector.add(original_pos, relative_pos))
@ -303,7 +303,7 @@ function keep_teleporting(player, pos, seconds, current_second)
if current_second > seconds then return end
minetest.after(step, function()
player:add_player_velocity(vector.multiply(player:get_player_velocity(), -1))
player:add_velocity(vector.multiply(player:get_velocity(), -1))
player:set_pos(pos)
keep_teleporting(player, pos, seconds, current_second + step)
end)

View File

@ -1,6 +1,7 @@
local saved_huds = {} -- id = hud
local get_player_by_name = minetest.get_player_by_name
function skywars.generate_HUD(arena, pl_name)
local player = get_player_by_name(pl_name)
local players_count_
@ -113,7 +114,7 @@ function skywars.update_players_counter(arena, players_amount_updated)
for pl_name in pairs(arena.players) do
local player = get_player_by_name(pl_name)
if arena.players_original_amount == nil then return end
if not arena.players_original_amount or not saved_huds[pl_name].players_count then return end
local players_counter = tostring(arena.players_amount) .. "/" .. tostring(arena.players_original_amount)
player:hud_change(saved_huds[pl_name].players_count, "text", players_counter)

View File

@ -1,14 +1,14 @@
local function delete_drops() end
local function async_reset_map() end
local function reset_node_inventory() end
local on_step = minetest.registered_entities["__builtin:item"].on_step
minetest.registered_entities["__builtin:item"].match_id = -2
minetest.registered_entities["__builtin:item"].last_age = 0
local get_position_from_hash = minetest.get_position_from_hash
local hash_node_position = minetest.hash_node_position
local deserialize = minetest.deserialize
local add_node = minetest.add_node
local get_node = minetest.get_node
local get_inventory = minetest.get_inventory
local on_step = minetest.registered_entities["__builtin:item"].on_step
minetest.registered_entities["__builtin:item"].match_id = -2
function skywars.reset_map(arena, debug, debug_data)
@ -22,8 +22,15 @@ end
-- Removing drops based on the match_id.
minetest.registered_entities["__builtin:item"].on_step = function(self, dtime, moveresult)
-- Returning if it passed less than 1s from the last check.
if self.age - self.last_age < 1 then
on_step(self, dtime, moveresult)
return
end
local pos = self.object:get_pos()
local arena = skywars.get_arena_by_pos(pos)
self.last_age = self.age
if arena and arena.match_id then
-- If the drop has not been initializated yet.
@ -60,8 +67,8 @@ function async_reset_map(arena, debug, recursive_data)
local nodes_per_tick = recursive_data.nodes_per_tick or skywars_settings.nodes_per_tick
local initial_time = recursive_data.initial_time or minetest.get_us_time()
-- Resets a node if it hasn't been reset yet and if it resets more than "nodes_per_tick"
-- nodes it invokes this function again after one step.
-- Resets a node if it hasn't been reset yet and, if it resets more than "nodes_per_tick"
-- nodes, invokes this function again after one step.
arena.is_resetting = true
for hash_pos, node in pairs(original_nodes_to_reset) do
if current_index > last_index then
@ -70,6 +77,7 @@ function async_reset_map(arena, debug, recursive_data)
add_node(pos, node)
reset_node_inventory(pos)
end
-- If more than nodes_per_tick nodes have been reset this cycle.
if current_index - last_index >= nodes_per_tick then
minetest.after(0, function()
@ -91,12 +99,15 @@ function async_reset_map(arena, debug, recursive_data)
-- changes made to the latter during the reset.
local current_maps = skywars.load_table("maps")
if not current_maps[arena.name] or not current_maps[arena.name].changed_nodes then
return
return
end
local current_nodes_to_reset = current_maps[arena.name].changed_nodes
for hash_pos, node in pairs(current_nodes_to_reset) do
local always_to_be_reset = original_maps[arena.name].always_to_be_reset_nodes[hash_pos]
-- If in the old map this block hadn't been changed or it always has
-- to be reset, continue.
if not original_nodes_to_reset[hash_pos] or always_to_be_reset then
goto continue
end

View File

@ -3,7 +3,7 @@ local get_inventory = minetest.get_inventory
local hash_node_position = minetest.hash_node_position
minetest.register_on_placenode(function(pos, newnode, player, oldnode, itemstack, pointed_thing)
minetest.register_on_placenode(function(pos, newnode, player, oldnode)
local pl_name = player:get_player_name()
local arena = arena_lib.get_arena_by_player(pl_name)
if arena_lib.get_mod_by_player(pl_name) ~= "skywars" then return end
@ -113,7 +113,7 @@ function save_node(arena, pos, node)
if not arena then return end
initialize_map_data(maps, arena)
-- If this block has not been changed yet then save it.
-- If this node has not been changed yet then save it.
if not maps[arena.name].changed_nodes[hash_pos] then
maps[arena.name].changed_nodes[hash_pos] = node
skywars.overwrite_table("maps", maps)
@ -127,34 +127,4 @@ function initialize_map_data(maps, arena)
if not maps[arena.name] then maps[arena.name] = {} end
if not maps[arena.name].changed_nodes then maps[arena.name].changed_nodes = {} end
if not maps[arena.name].always_to_be_reset_nodes then maps[arena.name].always_to_be_reset_nodes = {} end
end
--
-- ! LEGACY SUPPORT FOR SERIALIZED POSITIONS.
-- Converting all the serialized positions into
-- hashes.
--
local maps = skywars.load_table("maps")
for arena_name, map in pairs(maps) do
initialize_map_data(maps, {name = arena_name})
for pos, node in pairs(map.changed_nodes) do
if minetest.deserialize(pos) and pos then
local hash_pos = minetest.hash_node_position(minetest.deserialize(pos))
map.changed_nodes[pos] = nil
map.changed_nodes[hash_pos] = node
end
end
for pos, bool in pairs(map.always_to_be_reset_nodes) do
if minetest.deserialize(pos) and pos then
local hash_pos = minetest.hash_node_position(minetest.deserialize(pos))
map.always_to_be_reset_nodes[pos] = nil
map.always_to_be_reset_nodes[hash_pos] = bool
end
end
end
skywars.overwrite_table("maps", maps)
end

62
locale/skywars.eo.tr Normal file
View File

@ -0,0 +1,62 @@
# version 1.1.4
# author(s): Tirifto
# reviewer(s):
# textdomain: skywars
# @n means "newline"
# @<number> (@1, @2, ecc) is a value that the mod will pass at runtime
# In-game messages
Time is out, the match is over!=Tempo plenumiĝis, ludo finiĝis!
@1 was killed by @2=@2 mortigis ludanton @1
@1 killed you with @2 HPs=@1 vin mortigis kun @2 saneroj
Nobody=Neniu
Select a kit using the item in your inventory=Elektu ilaron per la portaĵo en via portaĵujo
Kit Selector=Elektilo de ilaroj
# Nodes
Unbreakable without skywars_admin priv transparent node=Travidebla mondero, nerompebla sen la rajto skywars_admin
# Arena configuration
Count has to be greater than 0!=Kvanto devas esti super 0!
Rarity has to be between 1 and 10!=Malofteco devas esti inter 1 kaj 10!
@1 doesn't exist!=@1 ne ekzistas!
Your hand is empty!=Via mano malplenas!
Treasure not found!=Trezoro ne troviĝis!
Treasures list:=Listo de trezoroj:
You're not looking at anything!=Vi nenion rigardas!
The minimum or maximum amount of treasures has to be greater than 0!=La minimuma kaj maksimuma kvantoj de trezoroj devas esti super 0!
@1 treasures have been copied to @2!=@1 trezoroj kopiiĝis al @2!
The arenas must be different!=La arenoj devas esti malsamaj!
ID: @1, name: @2, rarity: @3, preciousness: @4, count: @5=Identigilo: @1, nomo: @2, malofteco: @3, valoreco: @4, kvanto: @5
Chest removed!=Kesto foriĝis!
Chest not found!=Kesto ne troviĝis!
Chest list:=Listo de kestoj:
The chest already exists!=La kesto jam ekzistas!
ID: @1, position: @2, preciousness: @3-@4, treasures amount: @5-@6=Identigilo: @1, pozicio: @2, valoreco: @3-@4, kvanto de trezoroj: @5-@6
Position saved!=Pozicio konserviĝis!
You didn't set the treasures!=Vi ne agordis la trezorojn!
You didn't set the chests!=Vi ne agordis la kestojn!
You didn't set the map corners!=Vi ne agordis angulojn de la mapo!
@1 must be disabled!=@1 devas esti malŝaltita!
@1 must be enabled!=@1 devas esti ŝaltita!
@1 already exists!=@1 jam ekzistas!
@1 added to @2!=@1 aldoniĝis al @2!
@1 removed from @2!=@1 foriĝis de @2!
Kit @1 created!=Ilaro @1 kreiĝis!
@1 texture set to @2!=Teksturo de @1 agordiĝis al @2!
Kit @1 deleted!=Ilaro @1 foriĝis!
Kits list:=Listo de ilaroj:
@1 items:=@1 portaĵoj:
Kit not found!=Ilaro ne troviĝis!
x@1 @2 added to @3!=×@1 @2 aldoniĝis al @3!
@1 reset!=@1 restariĝis!
@1 kits have been copied to @2!=@1 ilaroj kopiiĝis al @2!
Nobody must be in the editor!=Neniu estu en la redaktilo!
The enabling process may take a few moments, please wait...=La proceso de ŝaltado eble daŭros kelkan tempon, bonvolu atendi…
@1 is being reset!=@1 rekomenciĝas!