home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / mappy / luascr / Layer count.lua < prev    next >
Encoding:
Text File  |  2004-04-08  |  695 b   |  34 lines

  1. -- Layer Count
  2.  
  3. lnum = 0
  4.  
  5. function main ()
  6.  local w = mappy.getValue(mappy.MAPWIDTH)
  7.  local h = mappy.getValue(mappy.MAPHEIGHT)
  8.  
  9.  if (w == 0) then
  10.   mappy.msgBox ("Layer Count", "You need to load or create a map first", mappy.MMB_OK, mappy.MMB_ICONINFO)
  11.  else
  12.  
  13.   mappy.msgBox ("Layer Count", "Number of layers in map = "..lnum, mappy.MMB_OK, mappy.MMB_ICONINFO)
  14.  
  15.  end
  16. end
  17.  
  18. function countlayer ()
  19.  mappy.getBlock(0,0,lnum)
  20. end
  21.  
  22. while 1 do
  23.  lnum = lnum + 1
  24.  test, errormsg = pcall( countlayer )
  25.  if not test then
  26.   break
  27.  end
  28. end
  29.  
  30. test, errormsg = pcall( main )
  31. if not test then
  32.     mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
  33. end
  34.