+ BIG code refactoring, fixing and cleaning (part 1)
parent
197c69a907
commit
680d9780a1
52
TUTORIAL.txt
52
TUTORIAL.txt
|
@ -2,39 +2,47 @@ These are the steps to follow in order to create and configure an
|
||||||
arena:
|
arena:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1) Creating the arena using:
|
1) Creating the arena using:
|
||||||
|
|
||||||
/skywars create <arena name> [min players] [max players]
|
/skywars create <arena name> [min players] [max players]
|
||||||
where min players is equal to the minimun amount of players to make
|
|
||||||
|
Where min players is equal to the minimun amount of players to make
|
||||||
the arena start, and max players to the maximum amount of players that
|
the arena start, and max players to the maximum amount of players that
|
||||||
an arena can have.
|
an arena can have.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2) Saving the map area using:
|
2) Saving the map area using:
|
||||||
|
|
||||||
/skywars pos1 <arena name>
|
/skywars pos1 <arena name>
|
||||||
/skywars pos2 <arena name>
|
/skywars pos2 <arena name>
|
||||||
in order to kill players that go out of the map and to properly recognize
|
|
||||||
|
In order to kill players that go out of the map and to properly recognize
|
||||||
the arena you have to define a map area; to do so, simply specify its
|
the arena you have to define a map area; to do so, simply specify its
|
||||||
corners by using the two commands above.
|
corners by using the two commands above.
|
||||||
Once you've done this you can put "@" instead of the arena name in any command
|
Once you've done this you can put "@" instead of the arena name in any command
|
||||||
to automatically get the one you're standing in.
|
to automatically get the one you're standing in.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3) Editing the arena using:
|
3) Editing the arena using:
|
||||||
|
|
||||||
/skywars edit <arena name>
|
/skywars edit <arena name>
|
||||||
in this menu you can add spawn points, set up the timer and the sign to
|
|
||||||
|
In this menu you can add spawn points, set up the timer and the sign to
|
||||||
enter the arena: the spawn points are where the players will spawn when
|
enter the arena: the spawn points are where the players will spawn when
|
||||||
they enter the arena, the timer's a value decrementing from whatever you set
|
they enter the arena, the timer's a value decrementing from whatever you set
|
||||||
it until 0, and the sign is just the way to enter the arena (by clicking it).
|
it until 0, and the sign is just the way to enter the arena (by clicking it).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
4) Setting the arena treasures (the items that can spawn in the
|
4) Setting the arena treasures (the items that can spawn in the
|
||||||
chests):
|
chests):
|
||||||
|
|
||||||
/skywars addtreasure <arena name> <item> <count> <rarity (min 1.0, max
|
/skywars addtreasure <arena name> <item> <count> <preciousness>
|
||||||
10.0)> <preciousness>
|
<rarity (min 1.0, max 10.0)>
|
||||||
|
|
||||||
item: the item name;
|
item: the item name;
|
||||||
rarity: how often it will spawn in chests;
|
rarity: how often it will spawn in chests;
|
||||||
preciousness: in which chests it can be put, for example a chest with
|
preciousness: in which chests it can be put, for example a chest with
|
||||||
|
@ -42,19 +50,25 @@ a preciousness range 2-4 can just spawn items with a preciousness
|
||||||
between 2 and 4;
|
between 2 and 4;
|
||||||
count: the item amount.
|
count: the item amount.
|
||||||
|
|
||||||
|
|
||||||
You can also use:
|
You can also use:
|
||||||
/skywars addtreasure hand <arena name> <rarity (min 1.0, max 10.0)>
|
|
||||||
<preciousness>
|
/skywars addtreasure hand <arena name> <preciousness>
|
||||||
this will get the item name and count from the one in your hand.
|
<rarity (min 1.0, max 10.0)>
|
||||||
|
|
||||||
|
that will get the item name and count from the one in your hand.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
5) Setting the chests in the arena using:
|
5) Setting the chests in the arena using:
|
||||||
|
|
||||||
/skywars addchest <min_preciousness> <max_preciousness>
|
/skywars addchest <min_preciousness> <max_preciousness>
|
||||||
<min_treasures_amount (min. 1)> <max_treasures_amount>
|
<min_treasures_amount (min. 1)> <max_treasures_amount>
|
||||||
to add a chest that will be filled with the right treasures when the match
|
|
||||||
|
To add a chest that will be filled with the right treasures when the match
|
||||||
starts, this will set the position to the node you're looking at (not over it).
|
starts, this will set the position to the node you're looking at (not over it).
|
||||||
|
|
||||||
|
|
||||||
! WARNING !
|
! WARNING !
|
||||||
To modify a map you must use use /skywars reset <arena name> and then disable
|
To modify a map you must use use /skywars reset <arena name> and then disable
|
||||||
the arena, otherwise your changes may get lost.
|
the arena, otherwise your changes may get lost.
|
||||||
|
@ -64,18 +78,26 @@ flowing lava and water created some stone it won't be reset the first time, so
|
||||||
you'll have to reset it until the map is clear).
|
you'll have to reset it until the map is clear).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
6) (Optional) Creating and setting the kits using:
|
6) (Optional) Creating and setting the kits using:
|
||||||
|
|
||||||
/skywars createkit <kit name> <texture name>: texture name is the texture
|
/skywars createkit <kit name> <texture name>
|
||||||
that the kit button will have in the selector menu at the start of the match,
|
|
||||||
|
<texture name> is the texture that the kit button will have in the selector menu at the start of the match,
|
||||||
it must be a file name that you put in the "<SKYWARS MOD FOLDER>/textures" folder.
|
it must be a file name that you put in the "<SKYWARS MOD FOLDER>/textures" folder.
|
||||||
|
|
||||||
/skywars additem <kit name> <item> <count>: with this you can add items to it.
|
|
||||||
|
/skywars additem <kit name> <item> <count>
|
||||||
or
|
or
|
||||||
/skywars additem hand <kit name>
|
/skywars additem hand <kit name>
|
||||||
|
|
||||||
/skywars arenakit add <arena name> <kit name>: each arena has a "kits" property
|
With this you can add items to it.
|
||||||
that contains the choosable kits, with this command you add one to it.
|
|
||||||
|
|
||||||
|
/skywars arenakit add <arena name> <kit name>
|
||||||
|
|
||||||
|
Each arena has a "kits" property that contains the choosable kits, with this command you add one to it.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
7) Enabling the arena using
|
7) Enabling the arena using
|
||||||
|
@ -83,6 +105,8 @@ that contains the choosable kits, with this command you add one to it.
|
||||||
/skywars enable <arena name>
|
/skywars enable <arena name>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Once you've done this you can click the sign and start playing :).
|
Once you've done this you can click the sign and start playing :).
|
||||||
You should use /help skywars to read all the commands.
|
You should use /help skywars to read all the commands.
|
||||||
To modify the game settings (such as the messages prefix or the
|
To modify the game settings (such as the messages prefix or the
|
||||||
|
|
|
@ -25,7 +25,7 @@ end)
|
||||||
|
|
||||||
|
|
||||||
arena_lib.on_start("skywars", function(arena)
|
arena_lib.on_start("skywars", function(arena)
|
||||||
arena.match_players = arena.players_amount
|
arena.players_original_amount = arena.players_amount
|
||||||
|
|
||||||
skywars.reset_map(arena)
|
skywars.reset_map(arena)
|
||||||
skywars.place_chests(arena)
|
skywars.place_chests(arena)
|
||||||
|
|
|
@ -20,7 +20,6 @@ function skywars.generate_HUD(arena, pl_name)
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
background_kill_counter_ = player:hud_add({
|
background_kill_counter_ = player:hud_add({
|
||||||
hud_elem_type = "image",
|
hud_elem_type = "image",
|
||||||
position = {x = x_pos, y = y_pos},
|
position = {x = x_pos, y = y_pos},
|
||||||
|
@ -31,33 +30,29 @@ function skywars.generate_HUD(arena, pl_name)
|
||||||
number = 0xFFFFFF,
|
number = 0xFFFFFF,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- The number of players in the game
|
|
||||||
players_count_ = player:hud_add({
|
players_count_ = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = {x = x_pos, y = y_pos},
|
position = {x = x_pos, y = y_pos},
|
||||||
offset = {x = distance_x+background_width+39, y = 50+6},
|
offset = {x = distance_x+background_width+39, y = 50+6},
|
||||||
text = tostring(arena.players_amount) .. "/" .. tostring(arena.match_players),
|
text = tostring(arena.players_amount) .. "/" .. tostring(arena.players_original_amount),
|
||||||
alignment = {x = 0},
|
alignment = {x = 0},
|
||||||
scale = {x = 100, y = 100},
|
scale = {x = 100, y = 100},
|
||||||
number = 0xdff6f5,
|
number = 0xdff6f5,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- The number of players killed
|
|
||||||
players_killed_ = player:hud_add({
|
players_killed_ = player:hud_add({
|
||||||
hud_elem_type = "text",
|
hud_elem_type = "text",
|
||||||
position = {x = x_pos, y = y_pos},
|
position = {x = x_pos, y = y_pos},
|
||||||
offset = {x = -distance_x+33, y = 50+5},
|
offset = {x = -distance_x+34, y = 50+4},
|
||||||
text = 0,
|
text = 0,
|
||||||
alignment = {x = 0},
|
alignment = {x = 0},
|
||||||
scale = {x = 100, y = 100},
|
scale = {x = 100, y = 100},
|
||||||
number = 0xdff6f5,
|
number = 0xdff6f5,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Save the huds of each player
|
|
||||||
arena.HUDs[pl_name] = {
|
arena.HUDs[pl_name] = {
|
||||||
background_players_counter = background_players_counter_,
|
background_players_counter = background_players_counter_,
|
||||||
players_count = players_count_,
|
players_count = players_count_,
|
||||||
-- HUD ID, amount of players killed
|
|
||||||
players_killed = {id = players_killed_, amount = 0},
|
players_killed = {id = players_killed_, amount = 0},
|
||||||
background_kill_counter = background_kill_counter_
|
background_kill_counter = background_kill_counter_
|
||||||
}
|
}
|
||||||
|
@ -77,20 +72,19 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function skywars.update_players_counter(arena, players_updated)
|
function skywars.update_players_counter(arena, players_amount_updated)
|
||||||
local pl_amount = arena.players_amount
|
local pl_amount = arena.players_amount
|
||||||
|
|
||||||
-- if arena.players_amount hasn't been updated yet
|
if not players_amount_updated then
|
||||||
if players_updated == false then
|
|
||||||
pl_amount = pl_amount-1
|
pl_amount = pl_amount-1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- updating the players counter HUD
|
|
||||||
for pl_name in pairs(arena.players) do
|
for pl_name in pairs(arena.players) do
|
||||||
local player = minetest.get_player_by_name(pl_name)
|
local player = minetest.get_player_by_name(pl_name)
|
||||||
|
|
||||||
if arena.match_players == nil then return end
|
if arena.players_original_amount == nil then return end
|
||||||
|
|
||||||
player:hud_change(arena.HUDs[pl_name].players_count, "text", tostring(arena.players_amount) .. "/" .. tostring(arena.match_players))
|
local players_counter = tostring(arena.players_amount) .. "/" .. tostring(arena.players_original_amount)
|
||||||
|
player:hud_change(arena.HUDs[pl_name].players_count, "text", players_counter)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -16,7 +16,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
|
||||||
local pl_name = player:get_player_name()
|
local pl_name = player:get_player_name()
|
||||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
|
|
||||||
-- if the pressed button's name is equal to one of the kits in the arena then select it
|
-- if the pressed button's name is equal to one of the kits in the arena then select it
|
||||||
for i=1, #arena.kits do
|
for i=1, #arena.kits do
|
||||||
|
@ -57,7 +57,7 @@ function create_formspec(arena)
|
||||||
local distance_y = skywars_settings.distance_y
|
local distance_y = skywars_settings.distance_y
|
||||||
local offset_x = 0
|
local offset_x = 0
|
||||||
local offset_y = 0
|
local offset_y = 0
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
|
|
||||||
-- generates the formspec buttons
|
-- generates the formspec buttons
|
||||||
for i=1, #arena.kits do
|
for i=1, #arena.kits do
|
||||||
|
|
|
@ -9,7 +9,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
function skywars.reset_map(arena)
|
function skywars.reset_map(arena)
|
||||||
local maps = skywars.load_maps()
|
local maps = skywars.load_table("maps")
|
||||||
local pos1, pos2 = reorder_positions(arena.pos1, arena.pos2)
|
local pos1, pos2 = reorder_positions(arena.pos1, arena.pos2)
|
||||||
local distance_from_center = vector.distance(pos1, pos2) / 2
|
local distance_from_center = vector.distance(pos1, pos2) / 2
|
||||||
local map_center = {x = (pos1.x+pos2.x)/2, y = (pos1.y+pos2.y)/2, z = (pos1.z+pos2.z)/2}
|
local map_center = {x = (pos1.x+pos2.x)/2, y = (pos1.y+pos2.y)/2, z = (pos1.z+pos2.z)/2}
|
||||||
|
@ -34,7 +34,7 @@ function skywars.reset_map(arena)
|
||||||
minetest.add_node(pos, node)
|
minetest.add_node(pos, node)
|
||||||
end
|
end
|
||||||
maps[arena.name].blocks = {}
|
maps[arena.name].blocks = {}
|
||||||
skywars.overwrite_maps(maps)
|
skywars.overwrite_table("maps", maps)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
function save_block(arena, pos, node)
|
function save_block(arena, pos, node)
|
||||||
local maps = skywars.load_maps()
|
local maps = skywars.load_table("maps")
|
||||||
local serialized_pos = minetest.serialize(pos)
|
local serialized_pos = minetest.serialize(pos)
|
||||||
|
|
||||||
if not arena then return end
|
if not arena then return end
|
||||||
|
@ -112,6 +112,6 @@ function save_block(arena, pos, node)
|
||||||
-- if this block has not been changed yet then save it
|
-- if this block has not been changed yet then save it
|
||||||
if maps[arena.name].blocks[serialized_pos] == nil then
|
if maps[arena.name].blocks[serialized_pos] == nil then
|
||||||
maps[arena.name].blocks[serialized_pos] = node
|
maps[arena.name].blocks[serialized_pos] = node
|
||||||
skywars.overwrite_maps(maps)
|
skywars.overwrite_table("maps", maps)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,36 +1,18 @@
|
||||||
local storage = minetest.get_mod_storage()
|
local storage = minetest.get_mod_storage()
|
||||||
|
|
||||||
|
|
||||||
function skywars.load_kits()
|
function skywars.load_table(metadata_name)
|
||||||
local kits = minetest.deserialize(storage:get_string("kits"))
|
local metadata = minetest.deserialize(storage:get_string(metadata_name))
|
||||||
|
|
||||||
if kits == "" or kits == nil then
|
if metadata == "" or metadata == nil then
|
||||||
kits = {}
|
metadata = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
return kits
|
return metadata
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function skywars.overwrite_kits(kits_table)
|
function skywars.overwrite_table(metadata_name, table)
|
||||||
storage:set_string("kits", minetest.serialize(kits_table))
|
storage:set_string(metadata_name, minetest.serialize(table))
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function skywars.load_maps() -- {pos = node, ...}
|
|
||||||
local maps = minetest.deserialize(storage:get_string("maps"))
|
|
||||||
|
|
||||||
if maps == "" or maps == nil then
|
|
||||||
maps = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
return maps
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function skywars.overwrite_maps(maps_table)
|
|
||||||
storage:set_string("maps", minetest.serialize(maps_table))
|
|
||||||
end
|
end
|
233
commands.lua
233
commands.lua
|
@ -1,17 +1,13 @@
|
||||||
local function get_valid_arena() end
|
local function get_valid_arena() end
|
||||||
local function get_looking_node_pos() end
|
local function get_looking_node_pos() end
|
||||||
local function print_chest() end
|
local function from_chest_to_string() end
|
||||||
local function print_treasure() end
|
local function from_treasure_to_string() end
|
||||||
local function get_wielded_item() end
|
local function get_wielded_item() end
|
||||||
|
|
||||||
|
|
||||||
ChatCmdBuilder.new("skywars",
|
ChatCmdBuilder.new("skywars", function(cmd)
|
||||||
function(cmd)
|
cmd:sub("tutorial", function(sender)
|
||||||
cmd:sub("tutorial",
|
skywars.print_msg(sender, "You can read it from TUTORIAL.txt in the mod folder.")
|
||||||
function(sender)
|
|
||||||
skywars.print_msg(sender, [[
|
|
||||||
You can read it from TUTORIAL.txt in the mod folder.
|
|
||||||
]])
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,14 +122,11 @@ function(cmd)
|
||||||
|
|
||||||
if not arena then
|
if not arena then
|
||||||
return
|
return
|
||||||
elseif count <= 0 then
|
elseif count < 1 then
|
||||||
skywars.print_error(sender, skywars.T("Count has to be greater than 0!"))
|
skywars.print_error(sender, skywars.T("Count has to be greater than 0!"))
|
||||||
return
|
return
|
||||||
elseif rarity <= 0 then
|
elseif rarity < 1 or rarity > 10 then
|
||||||
skywars.print_error(sender, skywars.T("Rarity has to be greater than 0!"))
|
skywars.print_error(sender, skywars.T("Rarity has to be between 1 and 10!"))
|
||||||
return
|
|
||||||
elseif rarity > 10 then
|
|
||||||
skywars.print_error(sender, skywars.T("Rarity has to be smaller than 11!"))
|
|
||||||
return
|
return
|
||||||
elseif ItemStack(treasure_name):is_known() == false then
|
elseif ItemStack(treasure_name):is_known() == false then
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", treasure_name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", treasure_name))
|
||||||
|
@ -142,75 +135,70 @@ function(cmd)
|
||||||
|
|
||||||
local item_id = 1
|
local item_id = 1
|
||||||
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
||||||
table.insert(arena.treasures, {
|
local treasure = {
|
||||||
name = treasure_name,
|
name = treasure_name,
|
||||||
rarity = rarity,
|
rarity = rarity,
|
||||||
count = count,
|
count = count,
|
||||||
preciousness = preciousness,
|
preciousness = preciousness,
|
||||||
id = item_id
|
id = item_id
|
||||||
})
|
}
|
||||||
|
table.insert(arena.treasures, treasure)
|
||||||
|
|
||||||
arena_lib.change_arena_property(sender, "skywars", arena_name, "treasures", arena.treasures, false)
|
arena_lib.change_arena_property(sender, "skywars", arena_name, "treasures", arena.treasures, false)
|
||||||
skywars.print_msg(sender, skywars.T("x@1 @2 added to @3 with @4 rarity and @5 preciousness!",
|
skywars.print_msg(sender, "+ " .. from_treasure_to_string(treasure))
|
||||||
count, treasure_name, arena_name, rarity, preciousness
|
|
||||||
))
|
|
||||||
|
|
||||||
skywars.reorder_treasures(arena)
|
skywars.reorder_treasures(arena)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("addtreasure hand :arena :rarity:number :preciousness:int",
|
cmd:sub("addtreasure hand :arena :preciousness:int :rarity:number",
|
||||||
function(sender, arena_name, rarity, preciousness)
|
function(sender, arena_name, rarity, preciousness)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
local treasure = get_wielded_item(sender)
|
local treasure_itemstack = get_wielded_item(sender)
|
||||||
|
local treasure = {}
|
||||||
|
|
||||||
if not arena or not treasure then
|
if not arena or not treasure_itemstack then
|
||||||
return
|
return
|
||||||
end
|
elseif rarity < 1 or rarity > 10 then
|
||||||
if rarity <= 0 then
|
skywars.print_error(sender, skywars.T("Rarity has to be between 1 and 10!"))
|
||||||
skywars.print_error(sender, skywars.T("Rarity has to be greater than 0!"))
|
|
||||||
return
|
|
||||||
elseif rarity > 10 then
|
|
||||||
skywars.print_error(sender, skywars.T("Rarity has to be smaller than 11!"))
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local item_id = 1
|
local item_id = 1
|
||||||
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
||||||
table.insert(arena.treasures, {
|
treasure = {
|
||||||
name = treasure.name,
|
name = treasure_itemstack.name,
|
||||||
rarity = rarity,
|
rarity = rarity,
|
||||||
count = treasure.count,
|
count = treasure_itemstack.count,
|
||||||
preciousness = preciousness,
|
preciousness = preciousness,
|
||||||
id = item_id
|
id = item_id
|
||||||
})
|
}
|
||||||
|
table.insert(arena.treasures, treasure)
|
||||||
|
|
||||||
arena_lib.change_arena_property(sender, "skywars", arena_name, "treasures", arena.treasures, false)
|
arena_lib.change_arena_property(sender, "skywars", arena_name, "treasures", arena.treasures, false)
|
||||||
skywars.print_msg(sender, skywars.T("x@1 @2 added to @3 with @4 rarity and @5 preciousness!",
|
skywars.print_msg(sender, "+ " .. from_treasure_to_string(treasure))
|
||||||
treasure.count, treasure.name, arena_name, rarity, preciousness
|
|
||||||
))
|
|
||||||
|
|
||||||
skywars.reorder_treasures(arena)
|
skywars.reorder_treasures(arena)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("removetreasure hand :arena", function(sender, arena_name)
|
cmd:sub("removetreasure hand :arena",
|
||||||
|
function(sender, arena_name)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
local found = {true, false} -- the first is used to repeat the for until nothing is found
|
local found = {true, false} -- the first is used to repeat the for until nothing is found
|
||||||
local wielded_treasure = get_wielded_item(sender)
|
local wielded_itemstack = get_wielded_item(sender)
|
||||||
|
|
||||||
if not arena or not wielded_treasure then
|
if not arena or not wielded_itemstack then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
while found[1] do
|
while found[1] do
|
||||||
found[1] = false
|
found[1] = false
|
||||||
for i, treasure in pairs(arena.treasures) do
|
for i, treasure in pairs(arena.treasures) do
|
||||||
if treasure.name == wielded_treasure.name then
|
if treasure.name == wielded_itemstack.name then
|
||||||
table.remove(arena.treasures, i)
|
table.remove(arena.treasures, i)
|
||||||
i = i-1
|
|
||||||
found[1] = true
|
found[1] = true
|
||||||
found[2] = true
|
found[2] = true
|
||||||
end
|
end
|
||||||
|
@ -218,7 +206,7 @@ function(cmd)
|
||||||
end
|
end
|
||||||
arena_lib.change_arena_property(sender, "skywars", arena_name, "treasures", arena.treasures, false)
|
arena_lib.change_arena_property(sender, "skywars", arena_name, "treasures", arena.treasures, false)
|
||||||
|
|
||||||
if found[2] then skywars.print_msg(sender, skywars.T("@1 removed from @2!", wielded_treasure.name, arena.name))
|
if found[2] then skywars.print_msg(sender, skywars.T("@1 removed from @2!", wielded_itemstack.name, arena.name))
|
||||||
else skywars.print_error(sender, skywars.T("Treasure not found!")) end
|
else skywars.print_error(sender, skywars.T("Treasure not found!")) end
|
||||||
|
|
||||||
skywars.reorder_treasures(arena)
|
skywars.reorder_treasures(arena)
|
||||||
|
@ -226,7 +214,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("removetreasure :arena :treasure", function(sender, arena_name, treasure_name)
|
cmd:sub("removetreasure :arena :treasure",
|
||||||
|
function(sender, arena_name, treasure_name)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
local found = {true, false} -- the first is used to repeat the for until nothing is found
|
local found = {true, false} -- the first is used to repeat the for until nothing is found
|
||||||
|
|
||||||
|
@ -255,7 +244,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("removetreasure id :arena :id:int", function(sender, arena_name, treasure_id)
|
cmd:sub("removetreasure id :arena :id:int",
|
||||||
|
function(sender, arena_name, treasure_id)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
local treasure_name = ""
|
local treasure_name = ""
|
||||||
|
|
||||||
|
@ -280,10 +270,10 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("copytreasures :fromarena :toarena", function(sender, from, to)
|
cmd:sub("copytreasures :fromarena :toarena",
|
||||||
|
function(sender, from, to)
|
||||||
local from_arena, from = get_valid_arena(from, sender)
|
local from_arena, from = get_valid_arena(from, sender)
|
||||||
local to_arena, to = get_valid_arena(to, sender, true)
|
local to_arena, to = get_valid_arena(to, sender, true)
|
||||||
local found = false
|
|
||||||
|
|
||||||
if not to_arena or not from_arena then
|
if not to_arena or not from_arena then
|
||||||
return
|
return
|
||||||
|
@ -300,22 +290,24 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("gettreasures :arena", function(sender, arena_name)
|
cmd:sub("gettreasures :arena",
|
||||||
|
function(sender, arena_name)
|
||||||
local arena = get_valid_arena(arena_name, sender)
|
local arena = get_valid_arena(arena_name, sender)
|
||||||
local found = false
|
|
||||||
|
|
||||||
if not arena then
|
if not arena then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("Treasures list:"))
|
skywars.print_msg(sender, skywars.T("Treasures list:"))
|
||||||
for i=1, #arena.treasures do
|
for i=1, #arena.treasures do
|
||||||
print_treasure(arena.treasures[i], sender)
|
skywars.print_msg(sender, from_treasure_to_string(arena.treasures[i]) .. "\n\n")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("searchtreasure :arena :treasure", function(sender, arena_name, treasure_name)
|
cmd:sub("searchtreasure :arena :treasure",
|
||||||
|
function(sender, arena_name, treasure_name)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
|
|
||||||
if not arena then
|
if not arena then
|
||||||
|
@ -326,12 +318,7 @@ function(cmd)
|
||||||
for i=1, #arena.treasures do
|
for i=1, #arena.treasures do
|
||||||
local treasure = arena.treasures[i]
|
local treasure = arena.treasures[i]
|
||||||
if treasure.name:match(treasure_name) then
|
if treasure.name:match(treasure_name) then
|
||||||
skywars.print_msg(sender, "ID: " .. arena.treasures[i].id .. ".\n" ..
|
skywars.print_msg(sender, from_treasure_to_string(treasure) .. "\n\n")
|
||||||
skywars.T(
|
|
||||||
"name: @1 @nrarity: @2 @npreciousness: @3 @ncount: @4",
|
|
||||||
treasure.name, treasure.rarity, treasure.preciousness, treasure.count
|
|
||||||
) .. "\n\n"
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -365,28 +352,28 @@ function(cmd)
|
||||||
skywars.print_error(sender, skywars.T("The minimum or maximum amount of treasures has to be greater than 0!"))
|
skywars.print_error(sender, skywars.T("The minimum or maximum amount of treasures has to be greater than 0!"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, #arena.chests do
|
for i=1, #arena.chests do
|
||||||
if vector.equals(arena.chests[i].pos, pos) then
|
if vector.equals(arena.chests[i].pos, pos) then
|
||||||
exists = true
|
exists = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if exists then
|
if exists then
|
||||||
skywars.print_error(sender, skywars.T("The chest already exists!"))
|
skywars.print_error(sender, skywars.T("The chest already exists!"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
skywars.print_msg(sender, "+ " .. from_chest_to_string(chest))
|
||||||
|
|
||||||
skywars.print_msg(sender,
|
|
||||||
skywars.T("Chest added with @1-@2 preciousness and @3-@4 treasures amount!",
|
|
||||||
min_preciousness, max_preciousness, min_treasures, max_treasures)
|
|
||||||
)
|
|
||||||
table.insert(arena.chests, chest)
|
table.insert(arena.chests, chest)
|
||||||
arena_lib.change_arena_property(sender, "skywars", arena_name, "chests", arena.chests, false)
|
arena_lib.change_arena_property(sender, "skywars", arena_name, "chests", arena.chests, false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("getchests :arena", function(sender, arena_name)
|
cmd:sub("getchests :arena",
|
||||||
|
function(sender, arena_name)
|
||||||
local arena = get_valid_arena(arena_name, sender)
|
local arena = get_valid_arena(arena_name, sender)
|
||||||
|
|
||||||
if not arena then
|
if not arena then
|
||||||
|
@ -395,13 +382,14 @@ function(cmd)
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("Chest list:"))
|
skywars.print_msg(sender, skywars.T("Chest list:"))
|
||||||
for i=1, #arena.chests do
|
for i=1, #arena.chests do
|
||||||
print_chest(chest, arena.chests[i])
|
skywars.print_msg(sender, from_chest_to_string(arena.chests[i]) .. "\n\n")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("removechest", function(sender)
|
cmd:sub("removechest",
|
||||||
|
function(sender)
|
||||||
local arena, arena_name = get_valid_arena("@", sender, true)
|
local arena, arena_name = get_valid_arena("@", sender, true)
|
||||||
local found = false
|
local found = false
|
||||||
local pos = get_looking_node_pos(sender)
|
local pos = get_looking_node_pos(sender)
|
||||||
|
@ -430,7 +418,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("inspect", function(sender)
|
cmd:sub("inspect",
|
||||||
|
function(sender)
|
||||||
local arena, arena_name = get_valid_arena("@", sender)
|
local arena, arena_name = get_valid_arena("@", sender)
|
||||||
local found = false
|
local found = false
|
||||||
local pos = get_looking_node_pos(sender)
|
local pos = get_looking_node_pos(sender)
|
||||||
|
@ -444,7 +433,7 @@ function(cmd)
|
||||||
for i=1, #arena.chests do
|
for i=1, #arena.chests do
|
||||||
local chest = arena.chests[i]
|
local chest = arena.chests[i]
|
||||||
if vector.equals(chest.pos, pos) then
|
if vector.equals(chest.pos, pos) then
|
||||||
print_chest(chest, sender)
|
skywars.print_msg(sender, from_chest_to_string(chest) .. "\n\n")
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -457,7 +446,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("removechest id :arena :id:int", function(sender, arena_name, chest_id)
|
cmd:sub("removechest id :arena :id:int",
|
||||||
|
function(sender, arena_name, chest_id)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
local found = false
|
local found = false
|
||||||
|
|
||||||
|
@ -489,15 +479,15 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("createkit :name :texture",
|
cmd:sub("createkit :name :texture",
|
||||||
function(sender, kit_name, texture)
|
function(sender, kit_name, texture)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
|
|
||||||
if kits[kit_name] ~= nil then
|
if kits[kit_name] then
|
||||||
skywars.print_error(sender, skywars.T("@1 already exists!", kit_name))
|
skywars.print_error(sender, skywars.T("@1 already exists!", kit_name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
kits[kit_name] = {texture = texture, items={}}
|
kits[kit_name] = {texture = texture, items={}}
|
||||||
skywars.overwrite_kits(kits)
|
skywars.overwrite_table("kits", kits)
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("Kit @1 created!", kit_name))
|
skywars.print_msg(sender, skywars.T("Kit @1 created!", kit_name))
|
||||||
end)
|
end)
|
||||||
|
@ -506,7 +496,7 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("additem :kit :item :count:int",
|
cmd:sub("additem :kit :item :count:int",
|
||||||
function(sender, kit_name, item_name, item_count)
|
function(sender, kit_name, item_name, item_count)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
local itemstack = {}
|
local itemstack = {}
|
||||||
|
|
||||||
if ItemStack(item_name):is_known() == false then
|
if ItemStack(item_name):is_known() == false then
|
||||||
|
@ -524,7 +514,7 @@ function(cmd)
|
||||||
itemstack.count = item_count
|
itemstack.count = item_count
|
||||||
|
|
||||||
table.insert(kits[kit_name].items, itemstack)
|
table.insert(kits[kit_name].items, itemstack)
|
||||||
skywars.overwrite_kits(kits)
|
skywars.overwrite_table("kits", kits)
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("@1 added to @2!", item_name, kit_name))
|
skywars.print_msg(sender, skywars.T("@1 added to @2!", item_name, kit_name))
|
||||||
end)
|
end)
|
||||||
|
@ -533,37 +523,35 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("additem hand :kit",
|
cmd:sub("additem hand :kit",
|
||||||
function(sender, kit_name)
|
function(sender, kit_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
local itemstack = get_wielded_item(sender)
|
local wielded_itemstack = get_wielded_item(sender)
|
||||||
|
|
||||||
if not itemstack then
|
if not wielded_itemstack then
|
||||||
return
|
return
|
||||||
elseif kits[kit_name] == nil then
|
elseif kits[kit_name] == nil then
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(kits[kit_name].items, itemstack)
|
table.insert(kits[kit_name].items, wielded_itemstack)
|
||||||
skywars.overwrite_kits(kits)
|
skywars.overwrite_table("kits", kits)
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("x@1 @2 added to @3!", itemstack.count, itemstack.name, kit_name))
|
skywars.print_msg(sender, skywars.T("x@1 @2 added to @3!", wielded_itemstack.count, wielded_itemstack.name, kit_name))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("deletekit :kit",
|
cmd:sub("deletekit :kit",
|
||||||
function(sender, kit_name)
|
function(sender, kit_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
|
|
||||||
if not itemstack then
|
if kits[kit_name] == nil then
|
||||||
return
|
|
||||||
elseif kits[kit_name] == nil then
|
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
kits[kit_name] = nil
|
kits[kit_name] = nil
|
||||||
skywars.overwrite_kits(kits)
|
skywars.overwrite_table("kits", kits)
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("Kit @1 deleted!", kit_name))
|
skywars.print_msg(sender, skywars.T("Kit @1 deleted!", kit_name))
|
||||||
end)
|
end)
|
||||||
|
@ -572,30 +560,30 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("removeitem hand :kit",
|
cmd:sub("removeitem hand :kit",
|
||||||
function(sender, kit_name)
|
function(sender, kit_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
local itemstack = get_wielded_item(sender)
|
local wielded_itemstack = get_wielded_item(sender)
|
||||||
local found = false
|
local found = false
|
||||||
|
|
||||||
if not itemstack then
|
if not wielded_itemstack then
|
||||||
return
|
return
|
||||||
elseif kits[kit_name] == nil then
|
elseif kits[kit_name] == nil then
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", itemstack.name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", wielded_itemstack.name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, #kits[kit_name].items do
|
for i=1, #kits[kit_name].items do
|
||||||
if kits[kit_name].items[i].name == itemstack.name then
|
if kits[kit_name].items[i].name == wielded_itemstack.name then
|
||||||
table.remove(kits[kit_name].items, i)
|
table.remove(kits[kit_name].items, i)
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
skywars.overwrite_kits(kits)
|
skywars.overwrite_table("kits", kits)
|
||||||
|
|
||||||
if found then
|
if found then
|
||||||
skywars.print_msg(sender, skywars.T("@1 removed from @2!", itemstack.name, kit_name))
|
skywars.print_msg(sender, skywars.T("@1 removed from @2!", wielded_itemstack.name, kit_name))
|
||||||
else
|
else
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", itemstack.name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", wielded_itemstack.name))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -603,7 +591,7 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("removeitem :kit :item",
|
cmd:sub("removeitem :kit :item",
|
||||||
function(sender, kit_name, item_name)
|
function(sender, kit_name, item_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
local itemstack = {}
|
local itemstack = {}
|
||||||
local found = false
|
local found = false
|
||||||
|
|
||||||
|
@ -622,7 +610,7 @@ function(cmd)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
skywars.overwrite_kits(kits)
|
skywars.overwrite_table("kits", kits)
|
||||||
|
|
||||||
if found then
|
if found then
|
||||||
skywars.print_msg(sender, skywars.T("@1 removed from @2!", item_name, kit_name))
|
skywars.print_msg(sender, skywars.T("@1 removed from @2!", item_name, kit_name))
|
||||||
|
@ -635,7 +623,7 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("resetkit :kit",
|
cmd:sub("resetkit :kit",
|
||||||
function(sender, kit_name)
|
function(sender, kit_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
|
|
||||||
if kits[kit_name] == nil then
|
if kits[kit_name] == nil then
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||||
|
@ -643,7 +631,7 @@ function(cmd)
|
||||||
end
|
end
|
||||||
|
|
||||||
kits[kit_name].items = {}
|
kits[kit_name].items = {}
|
||||||
skywars.overwrite_kits(kits)
|
skywars.overwrite_table("kits", kits)
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("@1 reset!", kit_name))
|
skywars.print_msg(sender, skywars.T("@1 reset!", kit_name))
|
||||||
end)
|
end)
|
||||||
|
@ -652,7 +640,7 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("getkits",
|
cmd:sub("getkits",
|
||||||
function(sender)
|
function(sender)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
|
|
||||||
skywars.print_msg(sender, skywars.T("Kits list:"))
|
skywars.print_msg(sender, skywars.T("Kits list:"))
|
||||||
for name in pairs(kits) do
|
for name in pairs(kits) do
|
||||||
|
@ -664,7 +652,7 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("getitems :kit",
|
cmd:sub("getitems :kit",
|
||||||
function(sender, kit_name)
|
function(sender, kit_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
|
|
||||||
if kits[kit_name] == nil then
|
if kits[kit_name] == nil then
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||||
|
@ -681,13 +669,12 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("arenakit add :arena :kit",
|
cmd:sub("arenakit add :arena :kit",
|
||||||
function(sender, arena_name, kit_name)
|
function(sender, arena_name, kit_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
|
|
||||||
if not arena then
|
if not arena then
|
||||||
return
|
return
|
||||||
end
|
elseif kits[kit_name] == nil then
|
||||||
if kits[kit_name] == nil then
|
|
||||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -702,7 +689,7 @@ function(cmd)
|
||||||
|
|
||||||
cmd:sub("arenakit remove :arena :kit",
|
cmd:sub("arenakit remove :arena :kit",
|
||||||
function(sender, arena_name, kit_name)
|
function(sender, arena_name, kit_name)
|
||||||
local kits = skywars.load_kits()
|
local kits = skywars.load_table("kits")
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
local found = false
|
local found = false
|
||||||
|
|
||||||
|
@ -728,7 +715,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("copykits :fromarena :toarena", function(sender, from, to)
|
cmd:sub("copykits :fromarena :toarena",
|
||||||
|
function(sender, from, to)
|
||||||
local from_arena, from = get_valid_arena(from, sender)
|
local from_arena, from = get_valid_arena(from, sender)
|
||||||
local to_arena, to = get_valid_arena(to, sender, true)
|
local to_arena, to = get_valid_arena(to, sender, true)
|
||||||
|
|
||||||
|
@ -751,7 +739,8 @@ function(cmd)
|
||||||
-- ! MAP CMDS ! --
|
-- ! MAP CMDS ! --
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
cmd:sub("pos1 :arena", function(sender, arena_name)
|
cmd:sub("pos1 :arena",
|
||||||
|
function(sender, arena_name)
|
||||||
local player = minetest.get_player_by_name(sender)
|
local player = minetest.get_player_by_name(sender)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
|
|
||||||
|
@ -767,7 +756,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("pos2 :arena", function(sender, arena_name)
|
cmd:sub("pos2 :arena",
|
||||||
|
function(sender, arena_name)
|
||||||
local player = minetest.get_player_by_name(sender)
|
local player = minetest.get_player_by_name(sender)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||||
|
|
||||||
|
@ -783,7 +773,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("getpos", function(sender)
|
cmd:sub("getpos",
|
||||||
|
function(sender)
|
||||||
local pos = minetest.get_player_by_name(sender):get_pos()
|
local pos = minetest.get_player_by_name(sender):get_pos()
|
||||||
local readable_pos = "[X Y Z] " .. minetest.pos_to_string(pos, 1)
|
local readable_pos = "[X Y Z] " .. minetest.pos_to_string(pos, 1)
|
||||||
|
|
||||||
|
@ -792,7 +783,8 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("reset :arena", function(sender, arena_name)
|
cmd:sub("reset :arena",
|
||||||
|
function(sender, arena_name)
|
||||||
local player = minetest.get_player_by_name(sender)
|
local player = minetest.get_player_by_name(sender)
|
||||||
local arena, arena_name = get_valid_arena(arena_name, sender)
|
local arena, arena_name = get_valid_arena(arena_name, sender)
|
||||||
|
|
||||||
|
@ -810,8 +802,9 @@ function(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd:sub("clearmapstable", function(sender)
|
cmd:sub("clearmapstable",
|
||||||
skywars.overwrite_maps({})
|
function(sender)
|
||||||
|
skywars.overwrite_table("maps", {})
|
||||||
skywars.print_msg(sender, skywars.T("Maps table reset!"))
|
skywars.print_msg(sender, skywars.T("Maps table reset!"))
|
||||||
end)
|
end)
|
||||||
end, {
|
end, {
|
||||||
|
@ -834,13 +827,13 @@ end, {
|
||||||
- tutorial
|
- tutorial
|
||||||
- pos1 <arena name>
|
- pos1 <arena name>
|
||||||
- pos2 <arena name>
|
- pos2 <arena name>
|
||||||
- addtreasure <arena name> <item> <count> <rarity (min 1.0, max 10.0)>
|
- addtreasure <arena name> <item> <count> <preciousness>
|
||||||
<preciousness>
|
<rarity (min 1.0, max 10.0)>
|
||||||
- addtreasure hand <arena name> <rarity (min 1.0, max 10.0)>
|
- addtreasure hand <arena name> <preciousness>
|
||||||
<preciousness>
|
<rarity (min 1.0, max 10.0)>
|
||||||
- gettreasures <arena name>
|
- gettreasures <arena name>
|
||||||
- searchtreasure <arena name> <treasure name>: shows all the treasures with that name
|
- searchtreasure <arena name> <treasure name>: shows all the treasures with that name
|
||||||
- removetreasure <arena name> <treasure name>: remove all treasures with than name
|
- removetreasure <arena name> <treasure name>: remove all treasures with that name
|
||||||
- removetreasure hand <arena name>
|
- removetreasure hand <arena name>
|
||||||
- removetreasure id <arena name> <treasure id>
|
- removetreasure id <arena name> <treasure id>
|
||||||
- copytreasures <(from) arena name> <(to) arena name>
|
- copytreasures <(from) arena name> <(to) arena name>
|
||||||
|
@ -933,25 +926,21 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function print_chest(chest, sender)
|
function from_chest_to_string(chest)
|
||||||
local chest_pos = minetest.pos_to_string(chest.pos, 0)
|
local chest_pos = minetest.pos_to_string(chest.pos, 0)
|
||||||
skywars.print_msg(sender,
|
return skywars.T(
|
||||||
skywars.T(
|
"ID: @1, position: @2, preciousness: @3-@4, treasures amount: @5-@6",
|
||||||
"ID: @1 @nposition: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6",
|
|
||||||
chest.id, chest_pos, chest.min_preciousness, chest.max_preciousness,
|
chest.id, chest_pos, chest.min_preciousness, chest.max_preciousness,
|
||||||
chest.min_treasures, chest.max_treasures
|
chest.min_treasures, chest.max_treasures
|
||||||
) .. "\n\n"
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function print_treasure(treasure, sender)
|
function from_treasure_to_string(treasure)
|
||||||
skywars.print_msg(sender,
|
return skywars.T(
|
||||||
skywars.T(
|
"ID: @1, name: @2, rarity: @3, preciousness: @4, count: @5",
|
||||||
"ID: @1 @nname: @2 @nrarity: @3 @npreciousness: @4 @ncount: @5",
|
|
||||||
treasure.id, treasure.name, treasure.rarity, treasure.preciousness, treasure.count
|
treasure.id, treasure.name, treasure.rarity, treasure.preciousness, treasure.count
|
||||||
) .. "\n\n"
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
8
init.lua
8
init.lua
|
@ -1,10 +1,9 @@
|
||||||
dofile(minetest.get_modpath("skywars") .. "/SETTINGS.lua")
|
dofile(minetest.get_modpath("skywars") .. "/SETTINGS.lua")
|
||||||
|
|
||||||
skywars = {}
|
skywars = {}
|
||||||
skywars.T = minetest.get_translator("skywars")
|
skywars.T = minetest.get_translator("skywars")
|
||||||
|
|
||||||
|
|
||||||
local disabled_damage_types_ = {}
|
local disabled_damage_types_ = {}
|
||||||
|
|
||||||
|
|
||||||
if skywars_settings.fall_damage_disabled then
|
if skywars_settings.fall_damage_disabled then
|
||||||
disabled_damage_types_ = {"fall"}
|
disabled_damage_types_ = {"fall"}
|
||||||
end
|
end
|
||||||
|
@ -18,8 +17,7 @@ arena_lib.register_minigame("skywars", {
|
||||||
queue_waiting_time = skywars_settings.queue_waiting_time,
|
queue_waiting_time = skywars_settings.queue_waiting_time,
|
||||||
temp_properties = {
|
temp_properties = {
|
||||||
HUDs = {},
|
HUDs = {},
|
||||||
-- the original amount of players in the arena
|
players_original_amount = 0,
|
||||||
match_players = 0,
|
|
||||||
},
|
},
|
||||||
properties = {
|
properties = {
|
||||||
chests = {},
|
chests = {},
|
||||||
|
|
|
@ -6,36 +6,30 @@
|
||||||
# @<number> (@1, @2, ecc) is a value that the mod will pass at runtime
|
# @<number> (@1, @2, ecc) is a value that the mod will pass at runtime
|
||||||
|
|
||||||
Count has to be greater than 0!=La quantità deve essere maggiore di 0
|
Count has to be greater than 0!=La quantità deve essere maggiore di 0
|
||||||
Rarity has to be greater than 0!=La rarità deve essere maggiore di 0!
|
Rarity has to be between 1 and 10!=La rarità deve essere compresa tra 1 e 10!
|
||||||
Rarity has to be smaller than 11!=La rarità deve essere minore di 11!
|
|
||||||
@1 doesn't exist!=@1 non esiste!
|
@1 doesn't exist!=@1 non esiste!
|
||||||
Your hand is empty!=La tua mano è vuota!
|
Your hand is empty!=La tua mano è vuota!
|
||||||
Treasure not found!=Tesoro non trovato!
|
Treasure not found!=Tesoro non trovato!
|
||||||
The minimum or maximum amount of treasures has to be greater than 0!=Il numero minimo o massimo di tesori deve essere maggiore di 0!
|
The minimum or maximum amount of treasures has to be greater than 0!=Il numero minimo o massimo di tesori deve essere maggiore di 0!
|
||||||
Treasures list:=Lista dei tesori:
|
Treasures list:=Lista dei tesori:
|
||||||
First arena not found!=Prima arena non trovata/o!
|
|
||||||
Second arena not found!=Seconda arena non trovata/p!
|
|
||||||
@1 treasures have been copied to @2!=I tesori di @1 sono stati copiati in @2!
|
@1 treasures have been copied to @2!=I tesori di @1 sono stati copiati in @2!
|
||||||
The arenas must be different!=Le arene devono essere diverse!
|
The arenas must be different!=Le arene devono essere diverse!
|
||||||
ID: @1 @nname: @2 @nrarity: @3 @npreciousness: @4 @ncount: @5=ID: @1 @nnome: @2 @nrarità: @3 @npreziosità: @4 @nquantità: @5
|
ID: @1, name: @2, rarity: @3, preciousness: @4, count: @5=ID: @1, nome: @2, rarità: @3, preziosità: @4, quantità: @5
|
||||||
Chest added with @1-@2 preciousness and @3-@4 treasures amount!=Cassa aggiunta con @1-@2 di preziosità e @3-@4 quantità di tesori
|
|
||||||
Chest removed!=Cassa rimossa!
|
Chest removed!=Cassa rimossa!
|
||||||
Chest not found!=Cassa non trovata!
|
Chest not found!=Cassa non trovata!
|
||||||
The chest already exists!=La cassa già esiste!
|
The chest already exists!=La cassa già esiste!
|
||||||
Chest list:=Lista delle casse:
|
Chest list:=Lista delle casse:
|
||||||
You're not looking at anything!=Non stai guardando nulla!
|
You're not looking at anything!=Non stai guardando nulla!
|
||||||
ID: @1 @nposition: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6=ID: @1 @nposizione: @2 @npreziosità: @3-@4 @nquantità dei tesori: @5-@6
|
ID: @1, position: @2, preciousness: @3-@4, treasures amount: @5-@6=ID: @1, posizione: @2, preziosità: @3-@4, numero di tesori: @5-@6
|
||||||
Position saved!=Posizione salvata
|
Position saved!=Posizione salvata
|
||||||
You didn't set the treasures!=Non hai impostato i tesori!
|
You didn't set the treasures!=Non hai impostato i tesori!
|
||||||
You didn't set the chests!=Non hai impostato le chest!
|
You didn't set the chests!=Non hai impostato le chest!
|
||||||
You didn't set the map corners!=Non hai impostato gli angoli della mappa!
|
You didn't set the map corners!=Non hai impostato gli angoli della mappa!
|
||||||
@1 must be disabled!=@1 deve essere disabilitata!
|
@1 must be disabled!=@1 deve essere disabilitata!
|
||||||
@1 must be enabled!=@1 deve essere abilitata!
|
@1 must be enabled!=@1 deve essere abilitata!
|
||||||
Pos1 or pos2 are not set!=Pos1 o pos2 non sono impostate!
|
|
||||||
@1 was killed by @2=@1 è stato ucciso da @2
|
@1 was killed by @2=@1 è stato ucciso da @2
|
||||||
@1 already exists!=@1 esiste già!
|
@1 already exists!=@1 esiste già!
|
||||||
@1 added to @2!=@1 aggiunto a @2
|
@1 added to @2!=@1 aggiunto a @2
|
||||||
x@1 @2 added to @3 with @4 rarity and @5 preciousness!=x@1 @2 aggiunto a @3 con rarità @4 e preziosità @5
|
|
||||||
@1 removed from @2!=@1 rimosso da @2!
|
@1 removed from @2!=@1 rimosso da @2!
|
||||||
Kit @1 created!=Kit @1 creato!
|
Kit @1 created!=Kit @1 creato!
|
||||||
Kit @1 deleted!=Kit @1 eliminato!
|
Kit @1 deleted!=Kit @1 eliminato!
|
||||||
|
|
|
@ -6,38 +6,30 @@
|
||||||
# @<number> (@1, @2, ecc) is a value that the mod will pass at runtime
|
# @<number> (@1, @2, ecc) is a value that the mod will pass at runtime
|
||||||
|
|
||||||
Count has to be greater than 0!=
|
Count has to be greater than 0!=
|
||||||
Rarity has to be greater than 0!=
|
Rarity has to be between 1 and 10!=
|
||||||
Rarity has to be smaller than 11!=
|
|
||||||
@1 doesn't exist!=
|
@1 doesn't exist!=
|
||||||
Your hand is empty!=
|
Your hand is empty!=
|
||||||
Treasure added!=
|
|
||||||
Treasure removed!=
|
|
||||||
Treasure not found!=
|
Treasure not found!=
|
||||||
Treasures list:=
|
Treasures list:=
|
||||||
You're not looking at anything!=
|
You're not looking at anything!=
|
||||||
The minimum or maximum amount of treasures has to be greater than 0!=
|
The minimum or maximum amount of treasures has to be greater than 0!=
|
||||||
First arena not found!=
|
|
||||||
Second arena not found!=
|
|
||||||
@1 treasures have been copied to @2!=
|
@1 treasures have been copied to @2!=
|
||||||
The arenas must be different!=
|
The arenas must be different!=
|
||||||
ID: @1 @nname: @2 @nrarity: @3 @npreciousness: @4 @ncount: @5=
|
ID: @1, name: @2, rarity: @3, preciousness: @4, count: @5=
|
||||||
Chest added with @1-@2 preciousness and @3-@4 treasures amount!=
|
|
||||||
Chest removed!=
|
Chest removed!=
|
||||||
Chest not found!=
|
Chest not found!=
|
||||||
Chest list:=
|
Chest list:=
|
||||||
The chest already exists!=
|
The chest already exists!=
|
||||||
ID: @1 @nposition: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6=
|
ID: @1, position: @2, preciousness: @3-@4, treasures amount: @5-@6=
|
||||||
Position saved!=
|
Position saved!=
|
||||||
You didn't set the treasures!=
|
You didn't set the treasures!=
|
||||||
You didn't set the chests!=
|
You didn't set the chests!=
|
||||||
You didn't set the map corners!=
|
You didn't set the map corners!=
|
||||||
@1 must be disabled!=
|
@1 must be disabled!=
|
||||||
@1 must be enabled!=
|
@1 must be enabled!=
|
||||||
Pos1 or pos2 are not set!=
|
|
||||||
@1 was killed by @2=
|
@1 was killed by @2=
|
||||||
@1 already exists!=
|
@1 already exists!=
|
||||||
@1 added to @2!=
|
@1 added to @2!=
|
||||||
x@1 @2 added to @3 with @4 rarity and @5 preciousness!=
|
|
||||||
@1 removed from @2!=
|
@1 removed from @2!=
|
||||||
Kit @1 created!=
|
Kit @1 created!=
|
||||||
Kit @1 deleted!=
|
Kit @1 deleted!=
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 442 B |
Binary file not shown.
Before Width: | Height: | Size: 414 B After Width: | Height: | Size: 411 B |
|
@ -12,9 +12,7 @@ end
|
||||||
|
|
||||||
function skywars.get_arena_by_pos(pos)
|
function skywars.get_arena_by_pos(pos)
|
||||||
for i, arena in pairs(arena_lib.mods["skywars"].arenas) do
|
for i, arena in pairs(arena_lib.mods["skywars"].arenas) do
|
||||||
if arena.pos1.x == nil or arena.pos2.x == nil then
|
if arena.pos1.x == nil or arena.pos2.x == nil then goto continue end
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
|
|
||||||
reorder_positions(arena.pos1, arena.pos2)
|
reorder_positions(arena.pos1, arena.pos2)
|
||||||
local map_area = VoxelArea:new{MinEdge = arena.pos1, MaxEdge = arena.pos2}
|
local map_area = VoxelArea:new{MinEdge = arena.pos1, MaxEdge = arena.pos2}
|
||||||
|
|
Loading…
Reference in New Issue