LuaDrawing.wiki
changeset 259 903c90df0e5d
parent 258 9c815950568d
child 260 800c3ae08944
equal deleted inserted replaced
258:9c815950568d 259:903c90df0e5d
    10 First, a couple of convenience functions for drawing to the map.
    10 First, a couple of convenience functions for drawing to the map.
    11 <code lang="lua">
    11 <code lang="lua">
    12 PointsBuffer = ''  -- A string to accumulate points in
    12 PointsBuffer = ''  -- A string to accumulate points in
    13 function AddPoint(x, y, width, erase)
    13 function AddPoint(x, y, width, erase)
    14     PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff))
    14     PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff))
    15     if size then
    15     if width then
    16         size = bor(size,0x80)
    16         width = bor(size,0x80)
    17         if erase then
    17         if erase then
    18             size = bor(size,0x40)
    18             width = bor(size,0x40)
    19         end
    19         end
    20         PointsBuffer = PointsBuffer .. string.char(size)
    20         PointsBuffer = PointsBuffer .. string.char(width)
    21     else
    21     else
    22         PointsBuffer = PointsBuffer .. string.char(0)
    22         PointsBuffer = PointsBuffer .. string.char(0)
    23     end
    23     end
    24     if #PointsBuffer > 245 then
    24     if #PointsBuffer > 245 then
    25         ParseCommand('draw '..PointsBuffer)
    25         ParseCommand('draw '..PointsBuffer)
    48     AddPoint(100,100,10)
    48     AddPoint(100,100,10)
    49     AddPoint(2000,2000)
    49     AddPoint(2000,2000)
    50     AddPoint(2000,100,10)
    50     AddPoint(2000,100,10)
    51     AddPoint(100,2000)
    51     AddPoint(100,2000)
    52     AddPoint(1000,1000,63,true)
    52     AddPoint(1000,1000,63,true)
       
    53     AddPoint(1000,1000,20)
    53 
    54 
    54     for i = 63,2,-4 do
    55     for i = 63,2,-4 do
    55         AddPoint(2000,1000,i)
    56         AddPoint(2000,1000,i)
    56         AddPoint(2000,1000,i-2,true)
    57         AddPoint(2000,1000,i-2,true)
    57     end
    58     end
    82     for i = 500,3500,1000 do
    83     for i = 500,3500,1000 do
    83         AddPoint(i,1000,63,true)
    84         AddPoint(i,1000,63,true)
    84     end
    85     end
    85     FlushPoints()
    86     FlushPoints()
    86 </code>
    87 </code>
    87 This one fills the map with solid land, and draws 3 circular erased points in it.
    88 This one fills the map with solid land, and draws 4 circular erased points in it.