home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / mappy / luascr / Export Flash actionscript.lua < prev    next >
Encoding:
Text File  |  2004-10-22  |  1009 b   |  44 lines

  1. -- fill entire map with tile
  2.  
  3.  
  4. function main ()
  5.  local w = mappy.getValue(mappy.MAPWIDTH)
  6.  local h = mappy.getValue(mappy.MAPHEIGHT)
  7.  
  8.  if (w == 0) then
  9.   mappy.msgBox ("Fill Map", "Please load or create a map first", mappy.MMB_OK, mappy.MMB_ICONINFO)
  10.  else
  11.  
  12.     if (w > 10)
  13.         mappy.msgBox("Error","Too Big!", mappy.MMB_OK, mappy.MMB_ICONINFO)
  14.     end
  15.  
  16.     local blk = mappy.getValue (mappy.CURANIM)
  17.     if (blk == -1) then
  18.      blk = mappy.getValue (mappy.CURBLOCK)
  19.     else
  20. -- setBlock need anims in the format below (ie: anim 1 should be a value of -2)
  21.      blk = -(blk+1)
  22.     end
  23.  
  24.     mappy.copyLayer(mappy.getValue(mappy.CURLAYER),mappy.MPY_UNDO)
  25.  
  26.   local y = ry
  27.   while y < h do
  28.     local x = rx
  29.     while x < w do
  30.       mappy.setBlock (x, y, blk)
  31.       x = x + 1
  32.     end
  33.     y = y + 1
  34.   end
  35.  
  36.   mappy.updateScreen()
  37.  
  38. end
  39.  
  40. test, errormsg = pcall( main )
  41. if not test then
  42.     mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
  43. end
  44.