+ BIG code refactoring, fixing and cleaning (part 1)
parent
197c69a907
commit
680d9780a1
54
TUTORIAL.txt
54
TUTORIAL.txt
|
@ -2,39 +2,47 @@ These are the steps to follow in order to create and configure an
|
|||
arena:
|
||||
|
||||
|
||||
|
||||
1) Creating the arena using:
|
||||
|
||||
/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
|
||||
an arena can have.
|
||||
|
||||
|
||||
|
||||
2) Saving the map area using:
|
||||
|
||||
/skywars pos1 <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
|
||||
corners by using the two commands above.
|
||||
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.
|
||||
|
||||
|
||||
|
||||
3) Editing the arena using:
|
||||
|
||||
/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
|
||||
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).
|
||||
|
||||
|
||||
|
||||
4) Setting the arena treasures (the items that can spawn in the
|
||||
chests):
|
||||
|
||||
/skywars addtreasure <arena name> <item> <count> <rarity (min 1.0, max
|
||||
10.0)> <preciousness>
|
||||
/skywars addtreasure <arena name> <item> <count> <preciousness>
|
||||
<rarity (min 1.0, max 10.0)>
|
||||
|
||||
item: the item name;
|
||||
rarity: how often it will spawn in chests;
|
||||
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;
|
||||
count: the item amount.
|
||||
|
||||
You can also use:
|
||||
/skywars addtreasure hand <arena name> <rarity (min 1.0, max 10.0)>
|
||||
<preciousness>
|
||||
this will get the item name and count from the one in your hand.
|
||||
|
||||
You can also use:
|
||||
|
||||
/skywars addtreasure hand <arena name> <preciousness>
|
||||
<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:
|
||||
|
||||
/skywars addchest <min_preciousness> <max_preciousness>
|
||||
<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).
|
||||
|
||||
|
||||
! WARNING !
|
||||
To modify a map you must use use /skywars reset <arena name> and then disable
|
||||
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).
|
||||
|
||||
|
||||
|
||||
6) (Optional) Creating and setting the kits using:
|
||||
|
||||
/skywars createkit <kit name> <texture name>: texture name is the texture
|
||||
that the kit button will have in the selector menu at the start of the match,
|
||||
/skywars createkit <kit name> <texture name>
|
||||
|
||||
<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.
|
||||
|
||||
/skywars additem <kit name> <item> <count>: with this you can add items to it.
|
||||
|
||||
/skywars additem <kit name> <item> <count>
|
||||
or
|
||||
/skywars additem hand <kit name>
|
||||
|
||||
/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.
|
||||
With this you can add items 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
|
||||
|
@ -83,6 +105,8 @@ that contains the choosable kits, with this command you add one to it.
|
|||
/skywars enable <arena name>
|
||||
|
||||
|
||||
|
||||
|
||||
Once you've done this you can click the sign and start playing :).
|
||||
You should use /help skywars to read all the commands.
|
||||
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.match_players = arena.players_amount
|
||||
arena.players_original_amount = arena.players_amount
|
||||
|
||||
skywars.reset_map(arena)
|
||||
skywars.place_chests(arena)
|
||||
|
|
|
@ -20,7 +20,6 @@ function skywars.generate_HUD(arena, pl_name)
|
|||
number = 0xFFFFFF,
|
||||
})
|
||||
|
||||
|
||||
background_kill_counter_ = player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
position = {x = x_pos, y = y_pos},
|
||||
|
@ -31,33 +30,29 @@ function skywars.generate_HUD(arena, pl_name)
|
|||
number = 0xFFFFFF,
|
||||
})
|
||||
|
||||
-- The number of players in the game
|
||||
players_count_ = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
position = {x = x_pos, y = y_pos},
|
||||
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},
|
||||
scale = {x = 100, y = 100},
|
||||
number = 0xdff6f5,
|
||||
})
|
||||
|
||||
-- The number of players killed
|
||||
players_killed_ = player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
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,
|
||||
alignment = {x = 0},
|
||||
scale = {x = 100, y = 100},
|
||||
number = 0xdff6f5,
|
||||
})
|
||||
|
||||
-- Save the huds of each player
|
||||
arena.HUDs[pl_name] = {
|
||||
background_players_counter = background_players_counter_,
|
||||
players_count = players_count_,
|
||||
-- HUD ID, amount of players killed
|
||||
players_killed = {id = players_killed_, amount = 0},
|
||||
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
|
||||
|
||||
-- if arena.players_amount hasn't been updated yet
|
||||
if players_updated == false then
|
||||
if not players_amount_updated then
|
||||
pl_amount = pl_amount-1
|
||||
end
|
||||
|
||||
-- updating the players counter HUD
|
||||
for pl_name in pairs(arena.players) do
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
if arena.match_players == nil then return end
|
||||
|
||||
player:hud_change(arena.HUDs[pl_name].players_count, "text", tostring(arena.players_amount) .. "/" .. tostring(arena.match_players))
|
||||
if arena.players_original_amount == nil then return end
|
||||
|
||||
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
|
|
@ -16,7 +16,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
|
||||
local pl_name = player:get_player_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
|
||||
for i=1, #arena.kits do
|
||||
|
@ -57,7 +57,7 @@ function create_formspec(arena)
|
|||
local distance_y = skywars_settings.distance_y
|
||||
local offset_x = 0
|
||||
local offset_y = 0
|
||||
local kits = skywars.load_kits()
|
||||
local kits = skywars.load_table("kits")
|
||||
|
||||
-- generates the formspec buttons
|
||||
for i=1, #arena.kits do
|
||||
|
|
|
@ -9,7 +9,7 @@ end
|
|||
|
||||
|
||||
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 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}
|
||||
|
@ -34,7 +34,7 @@ function skywars.reset_map(arena)
|
|||
minetest.add_node(pos, node)
|
||||
end
|
||||
maps[arena.name].blocks = {}
|
||||
skywars.overwrite_maps(maps)
|
||||
skywars.overwrite_table("maps", maps)
|
||||
end
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ end
|
|||
|
||||
|
||||
function save_block(arena, pos, node)
|
||||
local maps = skywars.load_maps()
|
||||
local maps = skywars.load_table("maps")
|
||||
local serialized_pos = minetest.serialize(pos)
|
||||
|
||||
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 maps[arena.name].blocks[serialized_pos] == nil then
|
||||
maps[arena.name].blocks[serialized_pos] = node
|
||||
skywars.overwrite_maps(maps)
|
||||
skywars.overwrite_table("maps", maps)
|
||||
end
|
||||
end
|
|
@ -1,36 +1,18 @@
|
|||
local storage = minetest.get_mod_storage()
|
||||
|
||||
|
||||
function skywars.load_kits()
|
||||
local kits = minetest.deserialize(storage:get_string("kits"))
|
||||
function skywars.load_table(metadata_name)
|
||||
local metadata = minetest.deserialize(storage:get_string(metadata_name))
|
||||
|
||||
if kits == "" or kits == nil then
|
||||
kits = {}
|
||||
if metadata == "" or metadata == nil then
|
||||
metadata = {}
|
||||
end
|
||||
|
||||
return kits
|
||||
return metadata
|
||||
end
|
||||
|
||||
|
||||
|
||||
function skywars.overwrite_kits(kits_table)
|
||||
storage:set_string("kits", minetest.serialize(kits_table))
|
||||
function skywars.overwrite_table(metadata_name, 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
|
239
commands.lua
239
commands.lua
|
@ -1,17 +1,13 @@
|
|||
local function get_valid_arena() end
|
||||
local function get_looking_node_pos() end
|
||||
local function print_chest() end
|
||||
local function print_treasure() end
|
||||
local function from_chest_to_string() end
|
||||
local function from_treasure_to_string() end
|
||||
local function get_wielded_item() end
|
||||
|
||||
|
||||
ChatCmdBuilder.new("skywars",
|
||||
function(cmd)
|
||||
cmd:sub("tutorial",
|
||||
function(sender)
|
||||
skywars.print_msg(sender, [[
|
||||
You can read it from TUTORIAL.txt in the mod folder.
|
||||
]])
|
||||
ChatCmdBuilder.new("skywars", function(cmd)
|
||||
cmd:sub("tutorial", function(sender)
|
||||
skywars.print_msg(sender, "You can read it from TUTORIAL.txt in the mod folder.")
|
||||
end)
|
||||
|
||||
|
||||
|
@ -126,14 +122,11 @@ function(cmd)
|
|||
|
||||
if not arena then
|
||||
return
|
||||
elseif count <= 0 then
|
||||
elseif count < 1 then
|
||||
skywars.print_error(sender, skywars.T("Count has to be greater than 0!"))
|
||||
return
|
||||
elseif rarity <= 0 then
|
||||
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!"))
|
||||
elseif rarity < 1 or rarity > 10 then
|
||||
skywars.print_error(sender, skywars.T("Rarity has to be between 1 and 10!"))
|
||||
return
|
||||
elseif ItemStack(treasure_name):is_known() == false then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", treasure_name))
|
||||
|
@ -142,75 +135,70 @@ function(cmd)
|
|||
|
||||
local item_id = 1
|
||||
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
||||
table.insert(arena.treasures, {
|
||||
local treasure = {
|
||||
name = treasure_name,
|
||||
rarity = rarity,
|
||||
count = count,
|
||||
preciousness = preciousness,
|
||||
id = item_id
|
||||
})
|
||||
}
|
||||
table.insert(arena.treasures, treasure)
|
||||
|
||||
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!",
|
||||
count, treasure_name, arena_name, rarity, preciousness
|
||||
))
|
||||
skywars.print_msg(sender, "+ " .. from_treasure_to_string(treasure))
|
||||
|
||||
skywars.reorder_treasures(arena)
|
||||
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)
|
||||
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
|
||||
end
|
||||
if rarity <= 0 then
|
||||
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!"))
|
||||
elseif rarity < 1 or rarity > 10 then
|
||||
skywars.print_error(sender, skywars.T("Rarity has to be between 1 and 10!"))
|
||||
return
|
||||
end
|
||||
|
||||
local item_id = 1
|
||||
if arena.treasures[#arena.treasures] then item_id = arena.treasures[#arena.treasures].id+1 end
|
||||
table.insert(arena.treasures, {
|
||||
name = treasure.name,
|
||||
treasure = {
|
||||
name = treasure_itemstack.name,
|
||||
rarity = rarity,
|
||||
count = treasure.count,
|
||||
count = treasure_itemstack.count,
|
||||
preciousness = preciousness,
|
||||
id = item_id
|
||||
})
|
||||
}
|
||||
table.insert(arena.treasures, treasure)
|
||||
|
||||
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!",
|
||||
treasure.count, treasure.name, arena_name, rarity, preciousness
|
||||
))
|
||||
skywars.print_msg(sender, "+ " .. from_treasure_to_string(treasure))
|
||||
|
||||
skywars.reorder_treasures(arena)
|
||||
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 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
|
||||
end
|
||||
|
||||
while found[1] do
|
||||
found[1] = false
|
||||
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)
|
||||
i = i-1
|
||||
found[1] = true
|
||||
found[2] = true
|
||||
end
|
||||
|
@ -218,7 +206,7 @@ function(cmd)
|
|||
end
|
||||
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
|
||||
|
||||
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 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 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 to_arena, to = get_valid_arena(to, sender, true)
|
||||
local found = false
|
||||
|
||||
if not to_arena or not from_arena then
|
||||
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 found = false
|
||||
|
||||
if not arena then
|
||||
return
|
||||
end
|
||||
|
||||
skywars.print_msg(sender, skywars.T("Treasures list:"))
|
||||
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)
|
||||
|
||||
|
||||
|
||||
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)
|
||||
|
||||
if not arena then
|
||||
|
@ -326,12 +318,7 @@ function(cmd)
|
|||
for i=1, #arena.treasures do
|
||||
local treasure = arena.treasures[i]
|
||||
if treasure.name:match(treasure_name) then
|
||||
skywars.print_msg(sender, "ID: " .. arena.treasures[i].id .. ".\n" ..
|
||||
skywars.T(
|
||||
"name: @1 @nrarity: @2 @npreciousness: @3 @ncount: @4",
|
||||
treasure.name, treasure.rarity, treasure.preciousness, treasure.count
|
||||
) .. "\n\n"
|
||||
)
|
||||
skywars.print_msg(sender, from_treasure_to_string(treasure) .. "\n\n")
|
||||
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!"))
|
||||
return
|
||||
end
|
||||
|
||||
for i=1, #arena.chests do
|
||||
if vector.equals(arena.chests[i].pos, pos) then
|
||||
exists = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if exists then
|
||||
skywars.print_error(sender, skywars.T("The chest already exists!"))
|
||||
return
|
||||
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)
|
||||
arena_lib.change_arena_property(sender, "skywars", arena_name, "chests", arena.chests, false)
|
||||
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)
|
||||
|
||||
if not arena then
|
||||
|
@ -395,13 +382,14 @@ function(cmd)
|
|||
|
||||
skywars.print_msg(sender, skywars.T("Chest list:"))
|
||||
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)
|
||||
|
||||
|
||||
|
||||
cmd:sub("removechest", function(sender)
|
||||
cmd:sub("removechest",
|
||||
function(sender)
|
||||
local arena, arena_name = get_valid_arena("@", sender, true)
|
||||
local found = false
|
||||
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 found = false
|
||||
local pos = get_looking_node_pos(sender)
|
||||
|
@ -444,7 +433,7 @@ function(cmd)
|
|||
for i=1, #arena.chests do
|
||||
local chest = arena.chests[i]
|
||||
if vector.equals(chest.pos, pos) then
|
||||
print_chest(chest, sender)
|
||||
skywars.print_msg(sender, from_chest_to_string(chest) .. "\n\n")
|
||||
found = true
|
||||
break
|
||||
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 found = false
|
||||
|
||||
|
@ -489,15 +479,15 @@ function(cmd)
|
|||
|
||||
cmd:sub("createkit :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))
|
||||
return
|
||||
end
|
||||
|
||||
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))
|
||||
end)
|
||||
|
@ -506,7 +496,7 @@ function(cmd)
|
|||
|
||||
cmd:sub("additem :kit :item :count:int",
|
||||
function(sender, kit_name, item_name, item_count)
|
||||
local kits = skywars.load_kits()
|
||||
local kits = skywars.load_table("kits")
|
||||
local itemstack = {}
|
||||
|
||||
if ItemStack(item_name):is_known() == false then
|
||||
|
@ -524,7 +514,7 @@ function(cmd)
|
|||
itemstack.count = item_count
|
||||
|
||||
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))
|
||||
end)
|
||||
|
@ -533,37 +523,35 @@ function(cmd)
|
|||
|
||||
cmd:sub("additem hand :kit",
|
||||
function(sender, kit_name)
|
||||
local kits = skywars.load_kits()
|
||||
local itemstack = get_wielded_item(sender)
|
||||
local kits = skywars.load_table("kits")
|
||||
local wielded_itemstack = get_wielded_item(sender)
|
||||
|
||||
if not itemstack then
|
||||
if not wielded_itemstack then
|
||||
return
|
||||
elseif kits[kit_name] == nil then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||
return
|
||||
end
|
||||
|
||||
table.insert(kits[kit_name].items, itemstack)
|
||||
skywars.overwrite_kits(kits)
|
||||
table.insert(kits[kit_name].items, wielded_itemstack)
|
||||
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)
|
||||
|
||||
|
||||
|
||||
cmd:sub("deletekit :kit",
|
||||
function(sender, kit_name)
|
||||
local kits = skywars.load_kits()
|
||||
local kits = skywars.load_table("kits")
|
||||
|
||||
if not itemstack then
|
||||
return
|
||||
elseif kits[kit_name] == nil then
|
||||
if kits[kit_name] == nil then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||
return
|
||||
end
|
||||
|
||||
kits[kit_name] = nil
|
||||
skywars.overwrite_kits(kits)
|
||||
skywars.overwrite_table("kits", kits)
|
||||
|
||||
skywars.print_msg(sender, skywars.T("Kit @1 deleted!", kit_name))
|
||||
end)
|
||||
|
@ -572,30 +560,30 @@ function(cmd)
|
|||
|
||||
cmd:sub("removeitem hand :kit",
|
||||
function(sender, kit_name)
|
||||
local kits = skywars.load_kits()
|
||||
local itemstack = get_wielded_item(sender)
|
||||
local kits = skywars.load_table("kits")
|
||||
local wielded_itemstack = get_wielded_item(sender)
|
||||
local found = false
|
||||
|
||||
if not itemstack then
|
||||
if not wielded_itemstack then
|
||||
return
|
||||
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
|
||||
end
|
||||
|
||||
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)
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
skywars.overwrite_kits(kits)
|
||||
skywars.overwrite_table("kits", kits)
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
|
@ -603,7 +591,7 @@ function(cmd)
|
|||
|
||||
cmd:sub("removeitem :kit :item",
|
||||
function(sender, kit_name, item_name)
|
||||
local kits = skywars.load_kits()
|
||||
local kits = skywars.load_table("kits")
|
||||
local itemstack = {}
|
||||
local found = false
|
||||
|
||||
|
@ -622,7 +610,7 @@ function(cmd)
|
|||
break
|
||||
end
|
||||
end
|
||||
skywars.overwrite_kits(kits)
|
||||
skywars.overwrite_table("kits", kits)
|
||||
|
||||
if found then
|
||||
skywars.print_msg(sender, skywars.T("@1 removed from @2!", item_name, kit_name))
|
||||
|
@ -635,7 +623,7 @@ function(cmd)
|
|||
|
||||
cmd:sub("resetkit :kit",
|
||||
function(sender, kit_name)
|
||||
local kits = skywars.load_kits()
|
||||
local kits = skywars.load_table("kits")
|
||||
|
||||
if kits[kit_name] == nil then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||
|
@ -643,7 +631,7 @@ function(cmd)
|
|||
end
|
||||
|
||||
kits[kit_name].items = {}
|
||||
skywars.overwrite_kits(kits)
|
||||
skywars.overwrite_table("kits", kits)
|
||||
|
||||
skywars.print_msg(sender, skywars.T("@1 reset!", kit_name))
|
||||
end)
|
||||
|
@ -652,7 +640,7 @@ function(cmd)
|
|||
|
||||
cmd:sub("getkits",
|
||||
function(sender)
|
||||
local kits = skywars.load_kits()
|
||||
local kits = skywars.load_table("kits")
|
||||
|
||||
skywars.print_msg(sender, skywars.T("Kits list:"))
|
||||
for name in pairs(kits) do
|
||||
|
@ -664,7 +652,7 @@ function(cmd)
|
|||
|
||||
cmd:sub("getitems :kit",
|
||||
function(sender, kit_name)
|
||||
local kits = skywars.load_kits()
|
||||
local kits = skywars.load_table("kits")
|
||||
|
||||
if kits[kit_name] == nil then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||
|
@ -681,13 +669,12 @@ function(cmd)
|
|||
|
||||
cmd:sub("arenakit add :arena :kit",
|
||||
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)
|
||||
|
||||
if not arena then
|
||||
return
|
||||
end
|
||||
if kits[kit_name] == nil then
|
||||
elseif kits[kit_name] == nil then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", kit_name))
|
||||
return
|
||||
end
|
||||
|
@ -702,7 +689,7 @@ function(cmd)
|
|||
|
||||
cmd:sub("arenakit remove :arena :kit",
|
||||
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 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 to_arena, to = get_valid_arena(to, sender, true)
|
||||
|
||||
|
@ -751,7 +739,8 @@ function(cmd)
|
|||
-- ! 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 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 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 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 arena, arena_name = get_valid_arena(arena_name, sender)
|
||||
|
||||
|
@ -810,8 +802,9 @@ function(cmd)
|
|||
|
||||
|
||||
|
||||
cmd:sub("clearmapstable", function(sender)
|
||||
skywars.overwrite_maps({})
|
||||
cmd:sub("clearmapstable",
|
||||
function(sender)
|
||||
skywars.overwrite_table("maps", {})
|
||||
skywars.print_msg(sender, skywars.T("Maps table reset!"))
|
||||
end)
|
||||
end, {
|
||||
|
@ -834,13 +827,13 @@ end, {
|
|||
- tutorial
|
||||
- pos1 <arena name>
|
||||
- pos2 <arena name>
|
||||
- addtreasure <arena name> <item> <count> <rarity (min 1.0, max 10.0)>
|
||||
<preciousness>
|
||||
- addtreasure hand <arena name> <rarity (min 1.0, max 10.0)>
|
||||
<preciousness>
|
||||
- addtreasure <arena name> <item> <count> <preciousness>
|
||||
<rarity (min 1.0, max 10.0)>
|
||||
- addtreasure hand <arena name> <preciousness>
|
||||
<rarity (min 1.0, max 10.0)>
|
||||
- gettreasures <arena 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 id <arena name> <treasure id>
|
||||
- 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)
|
||||
skywars.print_msg(sender,
|
||||
skywars.T(
|
||||
"ID: @1 @nposition: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6",
|
||||
chest.id, chest_pos, chest.min_preciousness, chest.max_preciousness,
|
||||
chest.min_treasures, chest.max_treasures
|
||||
) .. "\n\n"
|
||||
return skywars.T(
|
||||
"ID: @1, position: @2, preciousness: @3-@4, treasures amount: @5-@6",
|
||||
chest.id, chest_pos, chest.min_preciousness, chest.max_preciousness,
|
||||
chest.min_treasures, chest.max_treasures
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function print_treasure(treasure, sender)
|
||||
skywars.print_msg(sender,
|
||||
skywars.T(
|
||||
"ID: @1 @nname: @2 @nrarity: @3 @npreciousness: @4 @ncount: @5",
|
||||
treasure.id, treasure.name, treasure.rarity, treasure.preciousness, treasure.count
|
||||
) .. "\n\n"
|
||||
function from_treasure_to_string(treasure)
|
||||
return skywars.T(
|
||||
"ID: @1, name: @2, rarity: @3, preciousness: @4, count: @5",
|
||||
treasure.id, treasure.name, treasure.rarity, treasure.preciousness, treasure.count
|
||||
)
|
||||
end
|
||||
|
||||
|
|
8
init.lua
8
init.lua
|
@ -1,10 +1,9 @@
|
|||
dofile(minetest.get_modpath("skywars") .. "/SETTINGS.lua")
|
||||
|
||||
skywars = {}
|
||||
skywars.T = minetest.get_translator("skywars")
|
||||
|
||||
|
||||
local disabled_damage_types_ = {}
|
||||
|
||||
|
||||
if skywars_settings.fall_damage_disabled then
|
||||
disabled_damage_types_ = {"fall"}
|
||||
end
|
||||
|
@ -18,8 +17,7 @@ arena_lib.register_minigame("skywars", {
|
|||
queue_waiting_time = skywars_settings.queue_waiting_time,
|
||||
temp_properties = {
|
||||
HUDs = {},
|
||||
-- the original amount of players in the arena
|
||||
match_players = 0,
|
||||
players_original_amount = 0,
|
||||
},
|
||||
properties = {
|
||||
chests = {},
|
||||
|
|
|
@ -6,36 +6,30 @@
|
|||
# @<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
|
||||
Rarity has to be greater than 0!=La rarità deve essere maggiore di 0!
|
||||
Rarity has to be smaller than 11!=La rarità deve essere minore di 11!
|
||||
Rarity has to be between 1 and 10!=La rarità deve essere compresa tra 1 e 10!
|
||||
@1 doesn't exist!=@1 non esiste!
|
||||
Your hand is empty!=La tua mano è vuota!
|
||||
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!
|
||||
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!
|
||||
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
|
||||
Chest added with @1-@2 preciousness and @3-@4 treasures amount!=Cassa aggiunta con @1-@2 di preziosità e @3-@4 quantità di tesori
|
||||
ID: @1, name: @2, rarity: @3, preciousness: @4, count: @5=ID: @1, nome: @2, rarità: @3, preziosità: @4, quantità: @5
|
||||
Chest removed!=Cassa rimossa!
|
||||
Chest not found!=Cassa non trovata!
|
||||
The chest already exists!=La cassa già esiste!
|
||||
Chest list:=Lista delle casse:
|
||||
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
|
||||
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 map corners!=Non hai impostato gli angoli della mappa!
|
||||
@1 must be disabled!=@1 deve essere disabilitata!
|
||||
@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 already exists!=@1 esiste già!
|
||||
@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!
|
||||
Kit @1 created!=Kit @1 creato!
|
||||
Kit @1 deleted!=Kit @1 eliminato!
|
||||
|
|
|
@ -6,38 +6,30 @@
|
|||
# @<number> (@1, @2, ecc) is a value that the mod will pass at runtime
|
||||
|
||||
Count has to be greater than 0!=
|
||||
Rarity has to be greater than 0!=
|
||||
Rarity has to be smaller than 11!=
|
||||
Rarity has to be between 1 and 10!=
|
||||
@1 doesn't exist!=
|
||||
Your hand is empty!=
|
||||
Treasure added!=
|
||||
Treasure removed!=
|
||||
Treasure not found!=
|
||||
Treasures list:=
|
||||
You're not looking at anything!=
|
||||
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!=
|
||||
The arenas must be different!=
|
||||
ID: @1 @nname: @2 @nrarity: @3 @npreciousness: @4 @ncount: @5=
|
||||
Chest added with @1-@2 preciousness and @3-@4 treasures amount!=
|
||||
ID: @1, name: @2, rarity: @3, preciousness: @4, count: @5=
|
||||
Chest removed!=
|
||||
Chest not found!=
|
||||
Chest list:=
|
||||
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!=
|
||||
You didn't set the treasures!=
|
||||
You didn't set the chests!=
|
||||
You didn't set the map corners!=
|
||||
@1 must be disabled!=
|
||||
@1 must be enabled!=
|
||||
Pos1 or pos2 are not set!=
|
||||
@1 was killed by @2=
|
||||
@1 already exists!=
|
||||
@1 added to @2!=
|
||||
x@1 @2 added to @3 with @4 rarity and @5 preciousness!=
|
||||
@1 removed from @2!=
|
||||
Kit @1 created!=
|
||||
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,15 +12,13 @@ end
|
|||
|
||||
function skywars.get_arena_by_pos(pos)
|
||||
for i, arena in pairs(arena_lib.mods["skywars"].arenas) do
|
||||
if arena.pos1.x == nil or arena.pos2.x == nil then
|
||||
goto continue
|
||||
end
|
||||
if arena.pos1.x == nil or arena.pos2.x == nil then goto continue end
|
||||
|
||||
reorder_positions(arena.pos1, arena.pos2)
|
||||
local map_area = VoxelArea:new{MinEdge = arena.pos1, MaxEdge = arena.pos2}
|
||||
|
||||
if map_area:contains(pos.x, pos.y, pos.z) then
|
||||
return arena
|
||||
return arena
|
||||
end
|
||||
|
||||
::continue::
|
||||
|
|
Loading…
Reference in New Issue