+ inspect cmd (to inspect a chest)
+ kit background width/height properties - tutorial from the cmds now /tutorial tells the user to look at the file + moved local functions at the end of the source files + now addchest and removechest cmds don't require the player to specify the arena anymore - addchest pos cmd + tutorial fixes + code cleaningmaster
parent
a479580ace
commit
430708d5ac
14
SETTINGS.lua
14
SETTINGS.lua
|
@ -52,16 +52,22 @@ skywars_settings.build_permission = "build"
|
|||
-- The texture background for the kit menu.
|
||||
skywars_settings.hud__kit_background = "Kits.png"
|
||||
|
||||
-- The background width in real coordinates
|
||||
skywars_settings.background_width = 11
|
||||
|
||||
-- The background height in real coordinates
|
||||
skywars_settings.background_height = 11
|
||||
|
||||
-- The x position offset from the background border of the first buttons row
|
||||
-- in real coordinates, the bigger it is the righter the row will be placed.
|
||||
skywars_settings.starting_x = 1.7
|
||||
|
||||
-- The y position offset from the background border of the first buttons row
|
||||
-- in real coordinates, the bigger it is the lower the row will be placed.
|
||||
skywars_settings.starting_y = 6.9
|
||||
skywars_settings.starting_y = 6.6
|
||||
|
||||
-- The horizontal distance between buttons in real coordinates.
|
||||
skywars_settings.distance_x = 3.4
|
||||
skywars_settings.distance_x = 3.1
|
||||
|
||||
-- The vertical distance between buttons in real coordinates.
|
||||
skywars_settings.distance_y = 3
|
||||
|
@ -70,10 +76,10 @@ skywars_settings.distance_y = 3
|
|||
skywars_settings.buttons_per_row = 3
|
||||
|
||||
-- The buttons width in real coordinates.
|
||||
skywars_settings.buttons_width = 2
|
||||
skywars_settings.buttons_width = 1.8
|
||||
|
||||
-- The buttons height in real coordinates.
|
||||
skywars_settings.buttons_height = 1.8
|
||||
skywars_settings.buttons_height = 1.6
|
||||
|
||||
|
||||
|
||||
|
|
56
TUTORIAL.txt
56
TUTORIAL.txt
|
@ -10,27 +10,37 @@ the arena start, and max players to the maximum amount of players that
|
|||
an arena can have.
|
||||
|
||||
|
||||
2) Editing the arena using:
|
||||
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
|
||||
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
|
||||
enter the arena: the spawn points are where the players will spawn when
|
||||
they enter the arena, the timer's a value starting from whatever you set
|
||||
it to decrementing until it reaches 0, and the sign is just the way to
|
||||
enter the arena (by clicking it).
|
||||
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).
|
||||
|
||||
|
||||
3) Setting the arena treasures (the items that can spawn in the
|
||||
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>
|
||||
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
|
||||
a preciousness range 2-4 can just spawn items with a preciousness
|
||||
between 2 and 4
|
||||
count: the item amount
|
||||
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
|
||||
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)>
|
||||
|
@ -38,30 +48,13 @@ You can also use:
|
|||
this will get the item name and count from the one in your hand.
|
||||
|
||||
|
||||
4) Setting the chests in the arena using:
|
||||
5) Setting the chests in the arena using:
|
||||
|
||||
/skywars addchest <arena name> <min_preciousness> <max_preciousness>
|
||||
/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
|
||||
starts, this will set the position to the node you're looking at (not over it).
|
||||
|
||||
You can also use:
|
||||
|
||||
/skywars addchest pos <arena name> <min_preciousness> <max_preciousness>
|
||||
<min_treasures_amount (min. 1)> <max_treasures_amount>
|
||||
this will set the position over the node you're standing on.
|
||||
|
||||
|
||||
5) 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 save the changes
|
||||
made to the arena you have to define a map area; to do so, simply specify its
|
||||
corners by using: /skywars pos1 and /skywars pos2.
|
||||
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.
|
||||
|
||||
! WARNING !
|
||||
To modify a map you must use use /skywars reset <arena name> and then disable
|
||||
the arena, otherwise your changes may get lost.
|
||||
|
@ -77,7 +70,7 @@ you'll have to reset it until the map is clear).
|
|||
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>: with this you can add items to it.
|
||||
or
|
||||
/skywars additem hand <kit name>
|
||||
|
||||
|
@ -90,7 +83,6 @@ 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
|
||||
|
|
|
@ -1,76 +1,6 @@
|
|||
local function add_privs(pl_name)
|
||||
local privs = minetest.get_player_privs(pl_name)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
-- preventing players with noclip to fall when placing blocks
|
||||
if privs.noclip then
|
||||
player:get_meta():set_string("noclip", "true")
|
||||
privs.noclip = nil
|
||||
else
|
||||
player:get_meta():set_string("noclip", "false")
|
||||
end
|
||||
|
||||
if skywars_settings.build_permission ~= "" then
|
||||
if privs[skywars_settings.build_permission] then
|
||||
player:get_meta():set_string("build", "true")
|
||||
else
|
||||
player:get_meta():set_string("build", "false")
|
||||
end
|
||||
privs[skywars_settings.build_permission] = true
|
||||
end
|
||||
|
||||
minetest.set_player_privs(pl_name, privs)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function remove_privs(pl_name)
|
||||
local privs = minetest.get_player_privs(pl_name)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
if player:get_meta():get_string("noclip") == "true" then
|
||||
privs.noclip = true
|
||||
end
|
||||
if player:get_meta():get_string("build") == "false" then
|
||||
privs[skywars_settings.build_permission] = nil
|
||||
end
|
||||
|
||||
minetest.set_player_privs(pl_name, privs)
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function set_glass(player, relative_pos)
|
||||
local node_pos = vector.round(vector.add(player:get_pos(), relative_pos))
|
||||
if minetest.get_node(node_pos).name == "air" then
|
||||
minetest.add_node(node_pos, {name="default:glass"})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function create_glass_cage(player)
|
||||
minetest.after(0.1, function()
|
||||
local pl_pos = player:get_pos()
|
||||
|
||||
player:set_physics_override({gravity=0, jump=0})
|
||||
player:add_player_velocity(vector.multiply(player:get_player_velocity(), -1))
|
||||
|
||||
set_glass(player, {x = 0,y = -1,z = 0})
|
||||
set_glass(player, {x = 0,y = -2,z = 0})
|
||||
set_glass(player, {x = 1,y = 1,z = 0})
|
||||
set_glass(player, {x = -1,y = 1,z = 0})
|
||||
set_glass(player, {x = 0,y = 1,z = 1})
|
||||
set_glass(player, {x = 0,y = 1,z = -1})
|
||||
set_glass(player, {x = 0,y = 2,z = 0})
|
||||
|
||||
-- teleports the player back in the glass
|
||||
minetest.after(1, function()
|
||||
player:set_pos(pl_pos)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
local function add_privs() end
|
||||
local function remove_privs() end
|
||||
local function create_glass_cage()end
|
||||
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
|
@ -106,7 +36,6 @@ arena_lib.on_start("skywars", function(arena)
|
|||
|
||||
skywars.generate_HUD(arena, pl_name)
|
||||
|
||||
arena.players[pl_name].original_speed = player:get_physics_override().speed
|
||||
player:set_physics_override({speed = skywars_settings.player_speed, gravity=1, jump=1})
|
||||
|
||||
skywars.activate_enderpearl(player, arena)
|
||||
|
@ -133,7 +62,6 @@ arena_lib.on_end("skywars", function(arena, players)
|
|||
|
||||
remove_privs(pl_name)
|
||||
skywars.remove_armor(player)
|
||||
player:set_physics_override({speed=arena.players[pl_name].original_speed})
|
||||
skywars.block_enderpearl(player, arena)
|
||||
end
|
||||
end)
|
||||
|
@ -167,7 +95,6 @@ arena_lib.on_quit("skywars", function(arena, pl_name)
|
|||
|
||||
remove_privs(pl_name)
|
||||
|
||||
player:set_physics_override({speed=arena.players[pl_name].original_speed})
|
||||
skywars.update_players_counter(arena, false)
|
||||
skywars.remove_HUD(arena, pl_name)
|
||||
skywars.remove_armor(player)
|
||||
|
@ -225,4 +152,78 @@ arena_lib.on_timeout("skywars", function(arena)
|
|||
arena_lib.load_celebration("skywars", arena, skywars.T("Nobody"))
|
||||
|
||||
arena_lib.send_message_players_in_arena(arena, skywars_settings.prefix .. skywars.T("Time is out, the match is over!"))
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
function add_privs(pl_name)
|
||||
local privs = minetest.get_player_privs(pl_name)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
-- preventing players with noclip to fall when placing blocks
|
||||
if privs.noclip then
|
||||
player:get_meta():set_string("noclip", "true")
|
||||
privs.noclip = nil
|
||||
else
|
||||
player:get_meta():set_string("noclip", "false")
|
||||
end
|
||||
|
||||
if skywars_settings.build_permission ~= "" then
|
||||
if privs[skywars_settings.build_permission] then
|
||||
player:get_meta():set_string("build", "true")
|
||||
else
|
||||
player:get_meta():set_string("build", "false")
|
||||
end
|
||||
privs[skywars_settings.build_permission] = true
|
||||
end
|
||||
|
||||
minetest.set_player_privs(pl_name, privs)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function remove_privs(pl_name)
|
||||
local privs = minetest.get_player_privs(pl_name)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
|
||||
if player:get_meta():get_string("noclip") == "true" then
|
||||
privs.noclip = true
|
||||
end
|
||||
if player:get_meta():get_string("build") == "false" then
|
||||
privs[skywars_settings.build_permission] = nil
|
||||
end
|
||||
|
||||
minetest.set_player_privs(pl_name, privs)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function create_glass_cage(player)
|
||||
minetest.after(0.1, function()
|
||||
local pl_pos = player:get_pos()
|
||||
local glass_blocks = {
|
||||
{x = 0,y = -1,z = 0},
|
||||
{x = 0,y = -2,z = 0},
|
||||
{x = 1,y = 1,z = 0},
|
||||
{x = -1,y = 1,z = 0},
|
||||
{x = 0,y = 1,z = 1},
|
||||
{x = 0,y = 1,z = -1},
|
||||
{x = 0,y = 2,z = 0}
|
||||
}
|
||||
|
||||
player:set_physics_override({gravity=0, jump=0})
|
||||
player:add_player_velocity(vector.multiply(player:get_player_velocity(), -1))
|
||||
|
||||
for _, relative_pos in pairs(glass_blocks) do
|
||||
local node_pos = vector.round(vector.add(pl_pos, relative_pos))
|
||||
if minetest.get_node(node_pos).name == "air" then
|
||||
minetest.add_node(node_pos, {name="default:glass"})
|
||||
end
|
||||
end
|
||||
|
||||
-- teleports the player back in the glass
|
||||
minetest.after(1, function()
|
||||
player:set_pos(pl_pos)
|
||||
end)
|
||||
end)
|
||||
end
|
|
@ -1,26 +1,6 @@
|
|||
-- This sets the map chests
|
||||
local mod = "skywars"
|
||||
|
||||
|
||||
local function fill_chest_inv(chest, arena)
|
||||
|
||||
local t_min = chest.min_treasures
|
||||
local t_max = chest.max_treasures
|
||||
local treasure_amount = math.ceil(math.random(t_min, t_max))
|
||||
local minp = chest.min_preciousness
|
||||
local maxp = chest.max_preciousness
|
||||
-- returns an itemstacks table that contains the chosen treasures
|
||||
local treasures = skywars.select_random_treasures(treasure_amount, minp, maxp, arena)
|
||||
local meta = minetest.get_meta(chest.pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
inv:set_list("main", {})
|
||||
for i=1, #treasures do
|
||||
inv:set_stack("main", i, treasures[i])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function fill_chest_inv() end
|
||||
|
||||
|
||||
function skywars.fill_chests(arena)
|
||||
|
@ -36,3 +16,22 @@ function skywars.place_chests(arena)
|
|||
minetest.add_node(arena.chests[i].pos, {name="default:chest"})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function fill_chest_inv(chest, arena)
|
||||
local t_min = chest.min_treasures
|
||||
local t_max = chest.max_treasures
|
||||
local treasure_amount = math.ceil(math.random(t_min, t_max))
|
||||
local minp = chest.min_preciousness
|
||||
local maxp = chest.max_preciousness
|
||||
-- returns an itemstacks table that contains the chosen treasures
|
||||
local treasures = skywars.select_random_treasures(treasure_amount, minp, maxp, arena)
|
||||
local meta = minetest.get_meta(chest.pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
inv:set_list("main", {})
|
||||
for i=1, #treasures do
|
||||
inv:set_stack("main", i, treasures[i])
|
||||
end
|
||||
end
|
|
@ -1,5 +1,6 @@
|
|||
-- Select the treasures to put in the chests inventory
|
||||
local mod = "skywars"
|
||||
local function treasure_to_itemstack() end
|
||||
|
||||
|
||||
function skywars.reorder_treasures(arena)
|
||||
|
@ -17,20 +18,6 @@ end
|
|||
|
||||
|
||||
|
||||
local function treasure_to_itemstack(treasure)
|
||||
local itemstack = {}
|
||||
itemstack.name = treasure.name
|
||||
itemstack.count = treasure.count
|
||||
|
||||
if ItemStack(itemstack):is_known() == false then
|
||||
minetest.log("error","[Skywars Treasures] I was asked to put "..treasure.name.." inside a chest, but it doesn't exist.")
|
||||
return nil
|
||||
end
|
||||
return ItemStack(itemstack)
|
||||
end
|
||||
|
||||
|
||||
|
||||
function skywars.select_random_treasures(treasure_amount, min_preciousness, max_preciousness, arena)
|
||||
local preciousness_filtered_treasures = {}
|
||||
local generated_treasures = {}
|
||||
|
@ -60,3 +47,17 @@ function skywars.select_random_treasures(treasure_amount, min_preciousness, max_
|
|||
|
||||
return generated_treasures
|
||||
end
|
||||
|
||||
|
||||
|
||||
function treasure_to_itemstack(treasure)
|
||||
local itemstack = {}
|
||||
itemstack.name = treasure.name
|
||||
itemstack.count = treasure.count
|
||||
|
||||
if ItemStack(itemstack):is_known() == false then
|
||||
minetest.log("error","[Skywars Treasures] I was asked to put "..treasure.name.." inside a chest, but it doesn't exist.")
|
||||
return nil
|
||||
end
|
||||
return ItemStack(itemstack)
|
||||
end
|
|
@ -1,4 +1,36 @@
|
|||
local function select_kit(pl_name, kit_items)
|
||||
local function select_kit() end
|
||||
local function create_formspec() end
|
||||
|
||||
|
||||
function skywars.show_kit_selector(pl_name, arena)
|
||||
if #arena.kits == 0 then return end
|
||||
minetest.show_formspec(pl_name, "skywars:kit_selector", create_formspec(arena))
|
||||
end
|
||||
|
||||
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "skywars:kit_selector" then
|
||||
return
|
||||
end
|
||||
|
||||
local pl_name = player:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
local kits = skywars.load_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
|
||||
local kit_name = arena.kits[i]
|
||||
if fields[kit_name] then
|
||||
select_kit(pl_name, kits[kit_name].items)
|
||||
minetest.close_formspec(pl_name, "skywars:kit_selector")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
function select_kit(pl_name, kit_items)
|
||||
local player_inv = minetest.get_player_by_name(pl_name):get_inventory()
|
||||
|
||||
for i=1, #kit_items do
|
||||
|
@ -9,10 +41,10 @@ end
|
|||
|
||||
|
||||
|
||||
local function create_formspec(arena)
|
||||
function create_formspec(arena)
|
||||
local formspec = {
|
||||
"formspec_version[3]",
|
||||
"size[12,12]",
|
||||
"size["..skywars_settings.background_width..","..skywars_settings.background_height.."]",
|
||||
"position[0.5, 0.5]",
|
||||
"anchor[0.5,0.5]",
|
||||
"no_prepend[]",
|
||||
|
@ -68,32 +100,4 @@ local function create_formspec(arena)
|
|||
end
|
||||
|
||||
return table.concat(formspec, "")
|
||||
end
|
||||
|
||||
|
||||
|
||||
function skywars.show_kit_selector(pl_name, arena)
|
||||
if #arena.kits == 0 then return end
|
||||
minetest.show_formspec(pl_name, "skywars:kit_selector", create_formspec(arena))
|
||||
end
|
||||
|
||||
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "skywars:kit_selector" then
|
||||
return
|
||||
end
|
||||
|
||||
local pl_name = player:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(pl_name)
|
||||
local kits = skywars.load_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
|
||||
local name = arena.kits[i]
|
||||
if fields[name] then
|
||||
select_kit(pl_name, kits[name].items)
|
||||
minetest.close_formspec(pl_name, "skywars:kit_selector")
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
|
@ -1,29 +1,6 @@
|
|||
-- reordering the corners positions so that pos1 is smaller than pos2
|
||||
local function reorder_positions(pos1, pos2)
|
||||
local temp
|
||||
|
||||
if pos1.z > pos2.z then
|
||||
temp = pos1.z
|
||||
pos1.z = pos2.z
|
||||
pos2.z = temp
|
||||
end
|
||||
|
||||
if pos1.y > pos2.y then
|
||||
temp = pos1.y
|
||||
pos1.y = pos2.y
|
||||
pos2.y = temp
|
||||
end
|
||||
|
||||
if pos1.x > pos2.x then
|
||||
temp = pos1.x
|
||||
pos1.x = pos2.x
|
||||
pos2.x = temp
|
||||
end
|
||||
|
||||
return pos1, pos2
|
||||
|
||||
end
|
||||
|
||||
local function reorder_positions() end
|
||||
local function save_block() end
|
||||
|
||||
|
||||
function skywars.get_arena_by_pos(pos)
|
||||
|
@ -42,24 +19,6 @@ end
|
|||
|
||||
|
||||
|
||||
local function save_block(arena, pos, node)
|
||||
local maps = skywars.load_maps()
|
||||
local serialized_pos = minetest.serialize(pos)
|
||||
|
||||
if not arena then return end
|
||||
if not maps then maps = {} end
|
||||
if not maps[arena.name] then maps[arena.name] = {} end
|
||||
if not maps[arena.name].blocks then maps[arena.name].blocks = {} end
|
||||
|
||||
-- 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)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function skywars.load_map_mapblocks(arena)
|
||||
minetest.load_area(arena.pos1, arena.pos2)
|
||||
minetest.emerge_area(arena.pos1, arena.pos2)
|
||||
|
@ -150,11 +109,56 @@ function minetest.set_node(pos, node)
|
|||
|
||||
return set_node(pos, node)
|
||||
end
|
||||
|
||||
|
||||
function minetest.add_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
end
|
||||
function minetest.remove_node(pos)
|
||||
minetest.set_node(pos, {name="air"})
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- reordering the corners positions so that pos1 is smaller than pos2
|
||||
function reorder_positions(pos1, pos2)
|
||||
local temp
|
||||
|
||||
if pos1.z > pos2.z then
|
||||
temp = pos1.z
|
||||
pos1.z = pos2.z
|
||||
pos2.z = temp
|
||||
end
|
||||
|
||||
if pos1.y > pos2.y then
|
||||
temp = pos1.y
|
||||
pos1.y = pos2.y
|
||||
pos2.y = temp
|
||||
end
|
||||
|
||||
if pos1.x > pos2.x then
|
||||
temp = pos1.x
|
||||
pos1.x = pos2.x
|
||||
pos2.x = temp
|
||||
end
|
||||
|
||||
return pos1, pos2
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function save_block(arena, pos, node)
|
||||
local maps = skywars.load_maps()
|
||||
local serialized_pos = minetest.serialize(pos)
|
||||
|
||||
if not arena then return end
|
||||
if not maps then maps = {} end
|
||||
if not maps[arena.name] then maps[arena.name] = {} end
|
||||
if not maps[arena.name].blocks then maps[arena.name].blocks = {} end
|
||||
|
||||
-- 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)
|
||||
end
|
||||
end
|
353
commands.lua
353
commands.lua
|
@ -1,46 +1,7 @@
|
|||
local function get_valid_arena(arena_name, sender, property_is_changing)
|
||||
local arena = nil
|
||||
|
||||
if string.match(arena_name, "@") then
|
||||
local player_pos = minetest.get_player_by_name(sender):get_pos()
|
||||
arena = skywars.get_arena_by_pos(player_pos)
|
||||
if arena then arena_name = arena.name end
|
||||
else
|
||||
local id, arena_ = arena_lib.get_arena_by_name("skywars", arena_name)
|
||||
arena = arena_
|
||||
end
|
||||
|
||||
if not arena then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", arena_name))
|
||||
return nil
|
||||
elseif arena_lib.is_arena_in_edit_mode(arena_name) and property_is_changing then
|
||||
skywars.print_error(sender, skywars.T("Nobody must be in the editor!"))
|
||||
return nil
|
||||
elseif arena.enabled and property_is_changing then
|
||||
arena_lib.disable_arena(sender, "skywars", arena_name)
|
||||
if arena.enabled then
|
||||
skywars.print_error(sender, skywars.T("@1 must be disabled!", arena_name))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
return arena, arena_name
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function get_looking_node(pl_name)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
local look_dir = player:get_look_dir()
|
||||
local pos_head = vector.add(player:get_pos(), {x=0, y=1.5, z=0})
|
||||
local result, pos = minetest.line_of_sight(
|
||||
vector.add(pos_head, vector.divide(look_dir, 4)),
|
||||
vector.add(pos_head, vector.multiply(look_dir, 10))
|
||||
)
|
||||
|
||||
return result, pos
|
||||
end
|
||||
|
||||
local function get_valid_arena() end
|
||||
local function get_looking_node() end
|
||||
local function print_chest() end
|
||||
local function print_treasure() end
|
||||
|
||||
|
||||
ChatCmdBuilder.new("skywars",
|
||||
|
@ -48,106 +9,7 @@ function(cmd)
|
|||
cmd:sub("tutorial",
|
||||
function(sender)
|
||||
skywars.print_msg(sender, [[
|
||||
|
||||
(If you find it uncomfortable to read the tutorial from the chat
|
||||
you can read it from a file in the mod folder called TUTORIAL.txt)
|
||||
|
||||
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
|
||||
the arena start, and max players to the maximum amount of players that
|
||||
an arena can have.
|
||||
|
||||
|
||||
2) Editing the arena using:
|
||||
|
||||
/skywars edit <arena name>
|
||||
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 starting from whatever you set
|
||||
it to decrementing until it reaches 0, and the sign is just the way to
|
||||
enter the arena (by clicking it).
|
||||
|
||||
|
||||
3) 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>
|
||||
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
|
||||
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.
|
||||
|
||||
|
||||
4) Setting the chests in the arena using:
|
||||
|
||||
/skywars addchest <arena name> <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
|
||||
starts, this will set the position to the node you're looking at (not over it).
|
||||
|
||||
You can also use:
|
||||
|
||||
/skywars addchest pos <arena name> <min_preciousness> <max_preciousness>
|
||||
<min_treasures_amount (min. 1)> <max_treasures_amount>
|
||||
this will set the position over the node you're standing on.
|
||||
|
||||
|
||||
5) 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 save the changes
|
||||
made to the arena you have to define a map area; to do so, simply specify its
|
||||
corners by using: /skywars pos1 and /skywars pos2.
|
||||
Once you've done this you can put "@" instead of the arena name in a command
|
||||
to automatically get the one you're standing in.
|
||||
|
||||
! WARNING !
|
||||
To modify a map you must use use /skywars reset <arena name> and then disable
|
||||
the arena, otherwise your changes may get lost.
|
||||
Everything you change when the arena's disabled won't be saved, so make
|
||||
sure to properly reset your map before doing so (e.g. if when you reset the arena
|
||||
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,
|
||||
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
|
||||
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
|
||||
|
||||
|
||||
7) Enabling the arena using
|
||||
|
||||
/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
|
||||
hub spawn point) you can edit the "<SKYWARD MOD FOLDER>/SETTINGS.lua" file.
|
||||
You can read it from TUTORIAL.txt in the mod folder called .
|
||||
]])
|
||||
end)
|
||||
|
||||
|
@ -458,13 +320,7 @@ function(cmd)
|
|||
end
|
||||
skywars.print_msg(sender, skywars.T("Treasures list:"))
|
||||
for i=1, #arena.treasures do
|
||||
local treasure = arena.treasures[i]
|
||||
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"
|
||||
)
|
||||
print_treasure(arena.treasures[i], sender)
|
||||
end
|
||||
end)
|
||||
|
||||
|
@ -493,59 +349,12 @@ function(cmd)
|
|||
|
||||
|
||||
|
||||
cmd:sub("addchest pos :arena :minpreciousness:int :maxpreciousness:int :tmin:int :tmax:int",
|
||||
function(sender, arena_name, min_preciousness, max_preciousness, t_min, t_max)
|
||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||
local pos = vector.round(minetest.get_player_by_name(sender):get_pos())
|
||||
local exists = false
|
||||
local chest_id = 1
|
||||
cmd:sub("addchest :minpreciousness:int :maxpreciousness:int :tmin:int :tmax:int",
|
||||
function(sender, min_preciousness, max_preciousness, t_min, t_max)
|
||||
local arena, arena_name = get_valid_arena("@", sender, true)
|
||||
local pos = get_looking_node(sender)
|
||||
|
||||
if arena.chests[#arena.chests] then chest_id = arena.chests[#arena.chests].id+1 end
|
||||
local chest =
|
||||
{
|
||||
pos = pos,
|
||||
min_preciousness = min_preciousness,
|
||||
max_preciousness = max_preciousness,
|
||||
min_treasures = t_min,
|
||||
max_treasures = t_max,
|
||||
id = chest_id
|
||||
}
|
||||
|
||||
if not arena then
|
||||
return
|
||||
end
|
||||
if t_min <= 0 or t_max <= 0 then
|
||||
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,
|
||||
skywars.T("Chest added with @1-@2 preciousness and @3-@4 treasures amount!",
|
||||
min_preciousness, max_preciousness, min_treasures_amount, max_treasures_amount)
|
||||
)
|
||||
table.insert(arena.chests, chest)
|
||||
arena_lib.change_arena_property(sender, "skywars", arena_name, "chests", arena.chests, false)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
cmd:sub("addchest :arena :minpreciousness:int :maxpreciousness:int :tmin:int :tmax:int",
|
||||
function(sender, arena_name, min_preciousness, max_preciousness, t_min, t_max)
|
||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||
local result, pos = get_looking_node(sender)
|
||||
|
||||
if result then
|
||||
skywars.print_error(sender, skywars.T("You're not looking at anything!"))
|
||||
if not pos then
|
||||
return
|
||||
elseif not arena then
|
||||
return
|
||||
|
@ -593,7 +402,6 @@ function(cmd)
|
|||
|
||||
cmd:sub("getchests :arena", function(sender, arena_name)
|
||||
local arena = get_valid_arena(arena_name, sender)
|
||||
local found = false
|
||||
|
||||
if not arena then
|
||||
return
|
||||
|
@ -601,28 +409,18 @@ function(cmd)
|
|||
|
||||
skywars.print_msg(sender, skywars.T("Chest list:"))
|
||||
for i=1, #arena.chests do
|
||||
local chest = arena.chests[i]
|
||||
local chest_pos = minetest.pos_to_string(chest.pos, 0)
|
||||
|
||||
skywars.print_msg(sender,
|
||||
skywars.T(
|
||||
"ID: @1 - Position: @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"
|
||||
)
|
||||
print_chest(chest, arena.chests[i])
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
cmd:sub("removechest :arena", function(sender, arena_name)
|
||||
local arena, arena_name = get_valid_arena(arena_name, sender, true)
|
||||
cmd:sub("removechest", function(sender)
|
||||
local arena, arena_name = get_valid_arena("@", sender, true)
|
||||
local found = false
|
||||
local result, pos = get_looking_node(sender)
|
||||
local pos = get_looking_node(sender)
|
||||
|
||||
if result then
|
||||
skywars.print_error(sender, skywars.T("You're not looking at anything!"))
|
||||
if not pos then
|
||||
return
|
||||
elseif not arena then
|
||||
return
|
||||
|
@ -646,6 +444,33 @@ function(cmd)
|
|||
|
||||
|
||||
|
||||
cmd:sub("inspect", function(sender)
|
||||
local arena, arena_name = get_valid_arena("@", sender, true)
|
||||
local found = false
|
||||
local pos = get_looking_node(sender)
|
||||
|
||||
if not pos then
|
||||
return
|
||||
elseif not arena then
|
||||
return
|
||||
end
|
||||
|
||||
for i=1, #arena.chests do
|
||||
local chest = arena.chests[i]
|
||||
if vector.equals(chest.pos, pos) then
|
||||
print_chest(chest, sender)
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not found then
|
||||
skywars.print_error(sender, skywars.T("Chest not found!"))
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
@ -1038,6 +863,8 @@ end, {
|
|||
Skywars:
|
||||
|
||||
- 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)>
|
||||
|
@ -1048,15 +875,12 @@ end, {
|
|||
- removetreasure hand <arena name>
|
||||
- removetreasure id <arena name> <treasure id>
|
||||
- copytreasures <(from) arena name> <(to) arena name>
|
||||
- addchest <arena name> <min_preciousness> <max_preciousness>
|
||||
<min_treasures_amount (min. 1)> <max_treasures_amount>
|
||||
- addchest pos <arena name> <min_preciousness> <max_preciousness>
|
||||
<min_treasures_amount (min. 1)> <max_treasures_amount>
|
||||
- addchest <min_preciousness> <max_preciousness> <min_treasures_amount (min. 1)>
|
||||
<max_treasures_amount>
|
||||
- getchests <arena name>
|
||||
- removechest <arena name>: removes the chest you're looking at
|
||||
- removechest id <id>
|
||||
- pos1 <arena name>
|
||||
- pos2 <arena name>
|
||||
- inspect: gives you information about the chest you're looking at
|
||||
- removechest
|
||||
- removechest id <arena name> <id>
|
||||
- reset <arena name>
|
||||
- createkit <kit name> <texture name>
|
||||
- deletekit <kit name>
|
||||
|
@ -1085,4 +909,77 @@ end, {
|
|||
minetest.register_privilege("skywars_admin", {
|
||||
description = "With this you can use /skywars"
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
function get_valid_arena(arena_name, sender, property_is_changing)
|
||||
local arena = nil
|
||||
|
||||
if arena_name == "@" then
|
||||
local player_pos = minetest.get_player_by_name(sender):get_pos()
|
||||
arena = skywars.get_arena_by_pos(player_pos)
|
||||
if arena then arena_name = arena.name end
|
||||
else
|
||||
local id, arena_ = arena_lib.get_arena_by_name("skywars", arena_name)
|
||||
arena = arena_
|
||||
end
|
||||
|
||||
if not arena then
|
||||
skywars.print_error(sender, skywars.T("@1 doesn't exist!", arena_name))
|
||||
return nil
|
||||
elseif arena_lib.is_arena_in_edit_mode(arena_name) and property_is_changing then
|
||||
skywars.print_error(sender, skywars.T("Nobody must be in the editor!"))
|
||||
return nil
|
||||
elseif arena.enabled and property_is_changing then
|
||||
arena_lib.disable_arena(sender, "skywars", arena_name)
|
||||
if arena.enabled then
|
||||
skywars.print_error(sender, skywars.T("@1 must be disabled!", arena_name))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
return arena, arena_name
|
||||
end
|
||||
|
||||
|
||||
|
||||
function get_looking_node(pl_name)
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
local look_dir = player:get_look_dir()
|
||||
local pos_head = vector.add(player:get_pos(), {x=0, y=1.5, z=0})
|
||||
local result, pos = minetest.line_of_sight(
|
||||
vector.add(pos_head, vector.divide(look_dir, 4)),
|
||||
vector.add(pos_head, vector.multiply(look_dir, 10))
|
||||
)
|
||||
|
||||
if result then
|
||||
skywars.print_error(sender, skywars.T("You're not looking at anything!"))
|
||||
return nil
|
||||
end
|
||||
|
||||
return pos
|
||||
end
|
||||
|
||||
|
||||
|
||||
function print_chest(chest, sender)
|
||||
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"
|
||||
)
|
||||
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"
|
||||
)
|
||||
end
|
3
init.lua
3
init.lua
|
@ -28,9 +28,6 @@ arena_lib.register_minigame("skywars", {
|
|||
pos2 = {},
|
||||
kits = {}
|
||||
},
|
||||
player_properties = {
|
||||
original_speed = 1
|
||||
},
|
||||
time_mode = 2,
|
||||
disabled_damage_types = disabled_damage_types_
|
||||
})
|
||||
|
|
|
@ -17,14 +17,14 @@ 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!
|
||||
name: @1 @nrarity: @2 @npreciousness: @3 @ncount: @4=nome: @1 @nrarità: @2 @npreziosità: @3 @nquantità: @4
|
||||
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
|
||||
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 - Position: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6=ID: @1 - Posizione: @2 @npreziosità: @3-@4 @nquantità dei tesori: @5-@6
|
||||
ID: @1 @nposition: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6=ID: @1 @nposizione: @2 @npreziosità: @3-@4 @nquantità dei 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!
|
||||
|
|
|
@ -20,13 +20,13 @@ First arena not found!=
|
|||
Second arena not found!=
|
||||
@1 treasures have been copied to @2!=
|
||||
The arenas must be different!=
|
||||
name: @1 @nrarity: @2 @npreciousness: @3 @ncount: @4=
|
||||
ID: @1 @nname: @2 @nrarity: @3 @npreciousness: @4 @ncount: @5=
|
||||
Chest added with @1-@2 preciousness and @3-@4 treasures amount!=
|
||||
Chest removed!=
|
||||
Chest not found!=
|
||||
Chest list:=
|
||||
The chest already exists!=
|
||||
ID: @1 - Position: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6=
|
||||
ID: @1 @nposition: @2 @npreciousness: @3-@4 @ntreasures amount: @5-@6=
|
||||
Position saved!=
|
||||
You didn't set the treasures!=
|
||||
You didn't set the chests!=
|
||||
|
|
Loading…
Reference in New Issue