Translating Outputs With Tables

In my Debug-style hud for displaying weapon info, I had the feature to display the GetPrimaryAmmoType(). This works fine but it draws the ID of the ammo type, and I want to translate that ID to the names I have in a table I will share below, this table has the corresponding number and name for the ammo types I care to display properly…

AmmoTable = {
	[1] = "item_ammo_ar2 / AR2",
	[2] = "item_ammo_ar2_altfire / AR2AltFire",
	[3] = "item_ammo_pistol / Pistol",
	[4] = "item_ammo_smg1 / SMG",
	[5] = "item_ammo_357 / 357",
	[6] = "item_ammo_crossbow / Bow",
	[7] = "item_box_buckshot / Shotgun",
	[8] = "item_rpg_round / RPG",
	[9] = "item_ammo_smg1_grenade / SGMAltFire",
	[10] = "weapon_frag / Grenade",
	[11] = "weapon_slam / Slam",
	[12] = "weapon_alyxgun_ammo / Alyxgun",

How do I use this table to display names instead of IDs? Thanks for any help!
Rest of the code if needed:

There’s this:

But if you must use your table, it’s as simple as

print( AmmoTable[ WhateverYouVariableForTheAmmoIDiS ] )

for example

AmmoTable( 2 )

This sounds good, but how can I use this in real time along with the existing code to translate the ID into the name on the hud?

game.GetAmmoName( LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType() )

[editline]8th December 2016[/editline]

Make sure to check if LocalPlayer and the weapon are valid

draw.DrawText("Ammo Type: " .. game.GetAmmoName( weapon:GetPrimaryAmmoType () ), "BudgetLabel", 900, ScrH() - 70, Color(255, 255, 255, 255), 0)

[ULib] external:39: attempt to concatenate a nil value

  1. fn - external:39
  2. unknown - lua/ulib/shared/hook.lua:110

This error is because of holding a weapon that doesnt have an ammo type (Melee, Grav/Physgun, ect.)
Also, it turns out my table idea was actually better, since I forgot I wanted to be able to see the actual entity name for the ammo (Which I included in that table myself)
So uh… how can I use the table again? Because

doesnt make sense in a hud… I cant just print the table I need it to translate in the hud, live with the gun you are holding

Just check if the AmmoName is valid before concatenating it. You really shouldn’t be using a preset table since it doesn’t account for custom ammo types.

Alright, I’ll have to settle with the names of the ammo then, which is better than just a number. Thanks!
What is the best way to check if its valid, I’m sure I could figure it out but I’m no coder so it will look like a mess, and would probably take an hour

local sName = game.GetAmmoName( weapon:GetPrimaryAmmoType () )

if ( sName ) then
   -- Draw

Thank you for all the help man, much appreciated!