local letters = {
   {'A', 'a'},
   {'B', 'b'},
   {'C', 'c'},
   {'D', 'd'},
   {'E', 'e'},
   {'F', 'f'},
   {'G', 'g'},
   {'H', 'h'},
   {'I', 'i'},
   {'J', 'j'},
   {'K', 'k'},
   {'L', 'l'},
   {'M', 'm'},
   {'N', 'n'},
   {'O', 'o'},
   {'P', 'p'},
   {'Q', 'q'},
   {'R', 'r'},
   {'S', 's'},
   {'T', 't'},
   {'U', 'u'},
   {'V', 'v'},
   {'W', 'w'},
   {'X', 'x'},
   {'Y', 'y'},
   {'Z', 'z'}
}

local numbers = {
   {'0', '0'},
   {'1', '1'},
   {'2', '2'},
   {'3', '3'},
   {'4', '4'},
   {'5', '5'},
   {'6', '6'},
   {'7', '7'},
   {'8', '8'},
   {'9', '9'}
}

for i in ipairs(letters) do
   local desc = letters[i][1]
   local name = letters[i][2]

   minetest.register_node('decals:'..name, {
      description = 'Letter '..desc,
      drawtype = 'mesh',
      mesh = 'decals_mesh.obj',
      tiles = {'decals_'..name..'.png'},
      inventory_image = 'decals_'..name..'.png',
      wield_image = 'decals_'..name..'.png',
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'decals_color_palette.png',
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      walkable = false,
      selection_box = {
         type = 'fixed',
         fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
      },
      collision_box = {
         type = 'fixed',
         fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
      },
      groups = {breakable=1},
      on_place = minetest.rotate_and_place,
      on_rightclick = decals.on_rightclick,
      on_punch = decals.on_punch,
   })
end

for i in ipairs(numbers) do
   local desc = numbers[i][1]
   local name = numbers[i][2]

   minetest.register_node('decals:'..name, {
      description = 'Number '..desc,
      drawtype = 'mesh',
      mesh = 'decals_mesh.obj',
      tiles = {'decals_'..name..'.png'},
      inventory_image = 'decals_'..name..'.png',
      wield_image = 'decals_'..name..'.png',
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'decals_color_palette.png',
      sunlight_propagates = true,
      use_texture_alpha = 'clip',
      walkable = false,
      selection_box = {
         type = 'fixed',
         fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
      },
      collision_box = {
         type = 'fixed',
         fixed = {-1/2, -1/2, -1/2, 1/2, -1/2+1/16, 1/2},
      },
      groups = {breakable=1},
      on_place = minetest.rotate_and_place,
      on_rightclick = decals.on_rightclick,
      on_punch = decals.on_punch,
   })
end
