minetest.register_craftitem('sss_items:id_1', {
   description = 'Cadet\'s ID',
   inventory_image = 'sss_items_id_cadet.png',
   on_use = function(itemstack, user)
      local name = user:get_player_name()
      local player_meta = user:get_meta()
      local level = player_meta:get_int('security_level')
      if level < 1 then
         player_meta:set_int('security_level', 1)
         minetest.chat_send_player(name, 'Congratulations, you just gained security clearance level one')
      else
         minetest.chat_send_player(name, 'This would be a downgrade, unable to proceed')
      end
      itemstack:take_item(1); return itemstack
   end
})

minetest.register_craftitem('sss_items:id_2', {
   description = 'Mechanic\'s ID',
   inventory_image = 'sss_items_id_mechanic.png',
   on_use = function(itemstack, user)
      local name = user:get_player_name()
      local player_meta = user:get_meta()
      local level = player_meta:get_int('security_level')
      if level < 2 then
         player_meta:set_int('security_level', 2)
         minetest.chat_send_player(name, 'Congratulations, you just gained security clearance level two')
      else
         minetest.chat_send_player(name, 'This would be a downgrade, unable to proceed')
      end
      itemstack:take_item(1); return itemstack
   end
})

minetest.register_craftitem('sss_items:id_3', {
   description = 'Engineers\'s ID',
   inventory_image = 'sss_items_id_engineer.png',
   on_use = function(itemstack, user)
      local name = user:get_player_name()
      local player_meta = user:get_meta()
      local level = player_meta:get_int('security_level')
      if level < 3 then
         player_meta:set_int('security_level', 3)
         minetest.chat_send_player(name, 'Congratulations, you just gained security clearance level three')
      else
         minetest.chat_send_player(name, 'This would be a downgrade, unable to proceed')
      end
      itemstack:take_item(1); return itemstack
   end
})

minetest.register_craftitem('sss_items:id_4', {
   description = 'Third Officer\'s ID',
   inventory_image = 'sss_items_id_third_officer.png',
   on_use = function(itemstack, user)
      local name = user:get_player_name()
      local player_meta = user:get_meta()
      local level = player_meta:get_int('security_level')
      if level < 4 then
         player_meta:set_int('security_level', 4)
         minetest.chat_send_player(name, 'Congratulations, you just gained security clearance level four')
      else
         minetest.chat_send_player(name, 'This would be a downgrade, unable to proceed')
      end
      itemstack:take_item(1); return itemstack
   end
})

minetest.register_craftitem('sss_items:id_5', {
   description = 'Second Officer\'s ID',
   inventory_image = 'sss_items_id_second_officer.png',
   on_use = function(itemstack, user)
      local name = user:get_player_name()
      local player_meta = user:get_meta()
      local level = player_meta:get_int('security_level')
      if level < 5 then
         player_meta:set_int('security_level', 5)
         minetest.chat_send_player(name, 'Congratulations, you just gained security clearance level five')
      else
         minetest.chat_send_player(name, 'This would be a downgrade, unable to proceed')
      end
      itemstack:take_item(1); return itemstack
   end
})

minetest.register_craftitem('sss_items:id_6', {
   description = 'Captain\'s ID',
   inventory_image = 'sss_items_id_captain.png',
   on_use = function(itemstack, user)
      local name = user:get_player_name()
      local player_meta = user:get_meta()
      local level = player_meta:get_int('security_level')
      if level < 6 then
         player_meta:set_int('security_level', 6)
         minetest.chat_send_player(name, 'Congratulations, you just gained security clearance level six')
      else
         minetest.chat_send_player(name, 'This would be a downgrade, unable to proceed')
      end
      itemstack:take_item(1); return itemstack
   end
})

minetest.register_craftitem('sss_items:id_7', {
   description = 'Captain\'s ID',
   inventory_image = 'sss_items_id_captain.png',
   on_use = function(itemstack, user)
      local name = user:get_player_name()
      local player_meta = user:get_meta()
      local level = player_meta:get_int('security_level')
      if level < 6 then
         player_meta:set_int('security_level', 6)
         minetest.chat_send_player(name, 'Congratulations, you just gained security clearance level six')
      else
         minetest.chat_send_player(name, 'This would be a downgrade, unable to proceed')
      end
      itemstack:take_item(1); return itemstack
   end
})
