Skip to content

Commit

Permalink
prevent setting player level out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
cornernote committed Aug 7, 2015
1 parent 230c89f commit 90546b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions skyblock_levels/register_command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ minetest.register_chatcommand('level', {
minetest.chat_send_player(name, player_name..' is on level '..skyblock.feats.get_level(player_name))
return
end
skyblock.feats.set_level(player_name, level)
minetest.chat_send_player(name, player_name..' has been set to level '..level)
if skyblock.feats.set_level(player_name, level) then
minetest.chat_send_player(name, player_name..' has been set to level '..level)
else
minetest.chat_send_player(name, 'cannot change '..player_name..' to level '..level)
end
end,
})

Expand Down
7 changes: 5 additions & 2 deletions skyblock_levels/skyblock.feats.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ end

-- set players current level
function skyblock.feats.set_level(player_name, level)
skyblock.feats.set(0, player_name, 'level', level)
skyblock.levels[level].init(player_name)
if skyblock.levels[level] then
skyblock.feats.set(0, player_name, 'level', level)
skyblock.levels[level].init(player_name)
return true
end
end

-- reset feats
Expand Down

0 comments on commit 90546b2

Please sign in to comment.