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