Class selector item
This commit is contained in:
parent
b9e8304f15
commit
01e683ff69
@ -36,6 +36,7 @@ arena_lib.on_load("fantasy_brawl", function(arena)
|
||||
for pl_name in pairs(arena.players) do
|
||||
local player = minetest.get_player_by_name(pl_name)
|
||||
fbrawl.show_class_selector(pl_name)
|
||||
fbrawl.replace_slot_item(player, 1, "fantasy_brawl:class_selector")
|
||||
player:set_physics_override({speed = 0.01})
|
||||
end
|
||||
|
||||
|
@ -92,17 +92,23 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
return
|
||||
end
|
||||
|
||||
if fields.quit or fields.key_enter then
|
||||
if arena and arena.classes and not arena.classes[pl_name] then
|
||||
minetest.after(0.1, function() fbrawl.show_class_selector(pl_name) end)
|
||||
end
|
||||
end
|
||||
|
||||
fbrawl.show_class_selector(pl_name)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
minetest.register_craftitem("fantasy_brawl:class_selector", {
|
||||
inventory_image = "fbrawl_class_selector_item.png",
|
||||
stack_max = 1,
|
||||
on_drop = function() return end,
|
||||
on_use =
|
||||
function(itemstack, player)
|
||||
fbrawl.show_class_selector(player:get_player_name())
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
function get_classes_btns(pl_data)
|
||||
local btns = ""
|
||||
local selected_class_name = pl_data.selected_class_name or "Warrior"
|
||||
|
@ -60,7 +60,7 @@ function fbrawl.apply_class(pl_name, class)
|
||||
for i, item in pairs(class.items) do
|
||||
local item_name = item.name or item
|
||||
|
||||
player_inv:add_item("main", ItemStack(item_name))
|
||||
fbrawl.replace_slot_item(player, i, item_name)
|
||||
end
|
||||
|
||||
pl_name:unlock_skill("fbrawl:hp_regen")
|
||||
|
@ -72,11 +72,7 @@ minetest.register_craftitem("fantasy_brawl:cry_of_gaia", {
|
||||
return
|
||||
end
|
||||
|
||||
if not fbrawl.area_raycast_up(pl_pos, 6, 25, false) then
|
||||
fbrawl.cast_ultimate(pl_name, "fbrawl:cry_of_gaia")
|
||||
else
|
||||
skillz.error(pl_name, T("There's not enough space here!"))
|
||||
end
|
||||
fbrawl.cast_ultimate(pl_name, "fbrawl:cry_of_gaia")
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -131,10 +131,6 @@ minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch,
|
||||
end
|
||||
|
||||
if wielded_item == "fantasy_brawl:hero_fury" then
|
||||
if not fbrawl.area_raycast_up(player:get_pos(), 2, 25, false) then
|
||||
fbrawl.cast_ultimate(pl_name, "fbrawl:hero_fury", player:get_player_name())
|
||||
else
|
||||
skillz.error(pl_name, T("There's not enough space here!"))
|
||||
end
|
||||
fbrawl.cast_ultimate(pl_name, "fbrawl:hero_fury", player:get_player_name())
|
||||
end
|
||||
end)
|
@ -7,10 +7,10 @@ local T = fbrawl.T
|
||||
|
||||
|
||||
|
||||
function fbrawl.replace_slot_item(player, slot, item)
|
||||
function fbrawl.replace_slot_item(player, slot, itemname)
|
||||
local inv = player:get_inventory()
|
||||
local list = inv:get_list("main")
|
||||
list[slot] = ItemStack(item)
|
||||
list[slot] = ItemStack(itemname)
|
||||
|
||||
inv:set_list("main", list)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user