?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. -- Set colourkey transparency
  2.  
  3. function main ()
  4.  mappy.msgBox ("Set colourkey transparency", "This will change the colourkeys to the current still block which has the transparent colour in the top left pixel of its BG graphic", mappy.MMB_OK, mappy.MMB_ICONINFO)
  5.  if (mappy.getValue(mappy.CURBLOCK) < 1) then
  6.   mappy.msgBox ("Set colourkey transparency", "You need to load or create a map first, then select a still block which has the transparent colour in the top left pixel of its BG graphic (not block 0, currently selected still block is: "..mappy.getValue(mappy.CURBLOCK)..")", mappy.MMB_OK, mappy.MMB_ICONINFO)
  7.  else
  8.   local tcoli, tcola, tcolr, tcolg, tcolb
  9.   if (mappy.getValue(mappy.BLOCKDEPTH) == 8) then
  10.    tcoli = mappy.getPixel(0, 0, mappy.getBlockValue (mappy.getValue(mappy.CURBLOCK), mappy.BLKBG))
  11.    tcola, tcolr, tcolg, tcolb = mappy.getValue (mappy.PALETTEARGB+tcoli)
  12.   else
  13.    tcoli = 0
  14.    tcola, tcolr, tcolg, tcolb = mappy.getPixel(0, 0, mappy.getBlockValue (mappy.getValue(mappy.CURBLOCK), mappy.BLKBG))
  15.   end
  16.   mappy.setValue(mappy.TRANS8, tcoli)
  17.   mappy.setValue(mappy.TRANSRED, tcolr)
  18.   mappy.setValue(mappy.TRANSGREEN, tcolg)
  19.   mappy.setValue(mappy.TRANSBLUE, tcolb)
  20.   mappy.msgBox ("Set colourkey transparency", "Colourkeys set:\n\n8bit now index "..tcoli.."\n24bit now RGB "..tcolr..", "..tcolg..", "..tcolb, mappy.MMB_OK, mappy.MMB_ICONINFO)
  21.  end
  22.  mappy.updateScreen()
  23. end
  24.  
  25. test, errormsg = pcall( main )
  26. if not test then
  27.     mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
  28. end
  29.