?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. -- Swap palette indexes
  2.  
  3. function main ()
  4.  local w = mappy.getValue(mappy.MAPWIDTH)
  5.  local h = mappy.getValue(mappy.MAPHEIGHT)
  6.  
  7.  if (w == 0) then
  8.   mappy.msgBox ("Swap palette indexes", "You need to load or create a map first", mappy.MMB_OK, mappy.MMB_ICONINFO)
  9.  else
  10.  
  11.   local isok,index1,index2 = mappy.doDialogue ("Swap palette indexes", "Enter index1,index2", "0,0", mappy.MMB_DIALOGUE2)
  12.   if isok == mappy.MMB_OK then
  13.    local a1,r1,g1,b1 = mappy.getValue (mappy.PALETTEARGB+index1)
  14.    local a2,r2,g2,b2 = mappy.getValue (mappy.PALETTEARGB+index2)
  15.    mappy.setValue (mappy.PALETTEARGB+index1, a2, r2, g2, b2)
  16.    mappy.setValue (mappy.PALETTEARGB+index2, a1, r1, g1, b1)
  17.    mappy.msgBox ("Swap palette indexes", "index "..tostring(index1).." and "..tostring(index2).." swapped successfully", mappy.MMB_OK, mappy.MMB_ICONINFO)
  18.   end
  19.  end
  20. end
  21.  
  22. test, errormsg = pcall( main )
  23. if not test then
  24.     mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
  25. end
  26.