-- DB16 Palette (pfunc)
-- by Richard 'DawnBringer' Fhager

-- Usage: 
-- Set palette: dofile("pfunc_pal_DB16.lua")(true)
--  Also returns a PalList {{r,g,b,i},..} (in case it's needed for something, f.ex # of colors set)

-- Get palette: 
-- pallist = dofile("pfunc_pal_DB16.lua")()
-- Returns a PalList {{r,g,b,i},..}


return function(set_flag)
 
 local n,pal,pallist

pal = {
  { 20, 12, 28
},{ 68, 36, 52
},{ 48, 52, 109
},{ 78, 74, 78
},{ 133, 76, 48
},{ 52, 101, 36
},{ 208, 70, 72
},{ 117, 113, 97
},{ 89, 125, 206
},{ 210, 125, 44
},{ 133, 149, 161
},{ 109, 170, 44
},{ 210, 170, 153
},{ 109, 194, 202
},{ 218, 212, 94
},{ 222, 238, 214 
}}


 -- Convert [r,g,b] --> [r,g,b,i] (Add index to position 4)
 function convert_rgb_2_pallist(pal)
  local n
  for n = 1, #pal, 1 do
   pal[n][4] = n - 1
  end
  return pal
 end
 --

 pallist = convert_rgb_2_pallist(pal)

 if set_flag then
  for n = 1, #pal, 1 do
   setcolor(pal[n][4], pal[n][1],pal[n][2],pal[n][3])
  end
 end

 return pallist

end