Hendrik Langer
5 years ago
7 changed files with 168 additions and 24 deletions
@ -0,0 +1,62 @@ |
|||
minetest.register_privilege("arena", { |
|||
description = "Player is involved in an arena battle.", |
|||
give_to_singleplayer= false, |
|||
}) |
|||
|
|||
local drop = function(pos, itemstack) |
|||
local obj = minetest.add_item(pos, itemstack:take_item(itemstack:get_count())) |
|||
if obj then |
|||
obj:set_velocity({ |
|||
x = math.random(-10, 10) / 9, |
|||
y = 5, |
|||
z = math.random(-10, 10) / 9, |
|||
}) |
|||
end |
|||
end |
|||
|
|||
function creative_regions.drop_everything(player, drop_bones) |
|||
local player_inventory_lists = { "main", "craft" } |
|||
local player_inv = player:get_inventory() |
|||
local pos = player:get_pos() |
|||
|
|||
for _, list_name in ipairs(player_inventory_lists) do |
|||
for i = 1, player_inv:get_size(list_name) do |
|||
drop(pos, player_inv:get_stack(list_name, i)) |
|||
end |
|||
player_inv:set_list(list_name, {}) |
|||
end |
|||
if drop_bones then |
|||
drop(pos, ItemStack("bones:bones")) |
|||
-- minetest.item_drop(itemstack, player, pos) |
|||
end |
|||
end |
|||
|
|||
minetest.register_on_dieplayer(function(player) |
|||
local player_name = player:get_player_name() |
|||
if minetest.check_player_privs(player_name, {arena=true}) then |
|||
creative_regions.drop_everything(player, true) |
|||
local privs = minetest.get_player_privs(player_name) |
|||
privs["arena"] = nil |
|||
minetest.set_player_privs(player_name, privs) |
|||
end |
|||
end) |
|||
|
|||
if minetest.get_modpath("areas") then |
|||
|
|||
minetest.register_node("creative_regions:protector_arena", { |
|||
description = "Arena protector", |
|||
tiles = {"creative_regions_protector_arena.png"}, |
|||
tiles = {"default_cobble.png^default_tool_diamondsword.png"}, |
|||
is_ground_content = true, |
|||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=1}, |
|||
light_source = 1, |
|||
after_place_node = function(pos, placer, itemstack, pointed_thing) |
|||
return creative_regions.protector_set_area_privs(pos, placer, itemstack, pointed_thing, "-creative -fast, -fly, +arena", "Arena Protector") |
|||
end, |
|||
can_dig = creative_regions.protector_can_dig, |
|||
after_dig_node = function(pos, oldnode, oldmetadata, digger) |
|||
return creative_regions.protector_remove_area_privs(pos, oldnode, oldmetadata, digger, "Arena protector") |
|||
end |
|||
}) |
|||
|
|||
end |
After Width: | Height: | Size: 618 B |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 619 B |
Loading…
Reference in new issue