?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. -- Example Area script
  2. -- called when the mouse moves and a button pressed that is set to Area.lua
  3.  
  4. function main ()
  5.  local x1 = mappy.getValue (mappy.MOUSEBLOCKX)
  6.  local y1 = mappy.getValue (mappy.MOUSEBLOCKY)
  7.  local x2 = mappy.getValue (mappy.MOUSEBLOCKX2)
  8.  local y2 = mappy.getValue (mappy.MOUSEBLOCKY2)
  9.  
  10.  local blk = mappy.getValue (mappy.CURANIM)
  11.  if (blk == -1) then
  12.   blk = mappy.getValue (mappy.CURBLOCK)
  13.    if (blk == -1) then return end
  14.  else
  15. -- setBlock need anims in the format below (ie: anim 1 should be a value of -2)
  16.   blk = -(blk+1)
  17.  end
  18.  
  19.  mappy.copyLayer(mappy.getValue(mappy.CURLAYER),mappy.MPY_UNDO)
  20.  
  21.  if x2 < x1 then
  22.   xtmp = x1
  23.   x1 = x2
  24.   x2 = xtmp
  25.  end
  26.  
  27.  if y2 < y1 then
  28.   ytmp = y1
  29.   y1 = y2
  30.   y2 = ytmp
  31.  end
  32.  
  33.  local y = y1
  34.  while y <= y2 do
  35.   local x = x1
  36.   while x <= x2 do
  37.    mappy.setBlock (x, y, blk)
  38.    x = x + 1
  39.   end
  40.   y = y + 1
  41.  end
  42.  
  43.  mappy.updateScreen()
  44.  
  45. end
  46.  
  47. test, errormsg = pcall( main )
  48. if not test then
  49.     mappy.msgBox("Error ...", errormsg, mappy.MMB_OK, mappy.MMB_ICONEXCLAMATION)
  50. end
  51.  
  52.