# HG changeset patch # User kyberneticist@gmail.com # Date 1350680458 0 # Node ID 18e1a94e15916dfb7665196e970ed6b0952ed77a # Parent a21261c77793ed361dfe38b277ff8ae69e5a8d7e Edited wiki page LuaDrawing through web user interface. diff -r a21261c77793 -r 18e1a94e1591 LuaDrawing.wiki --- a/LuaDrawing.wiki Fri Oct 19 20:58:54 2012 +0000 +++ b/LuaDrawing.wiki Fri Oct 19 21:00:58 2012 +0000 @@ -3,7 +3,7 @@ = Drawing Maps With Lua = Starting in 0.9.18 it is possible to reliably use drawn map mode to draw maps with scripts. -A simple example is given below +A simple example is given below. Note that Drawn maps use an area of 4096x2048 = Details = @@ -13,22 +13,22 @@ function AddPoint(x, y, new, size, erase) PointsBuffer = PointsBuffer .. string.char(band(x,0xff00) / 256 , band(x,0xff) , band(y,0xff00) / 256 , band(y,0xff)) if new then - size = bor(size,0x80) + size = bor(size,0x80) if erase then - size = bor(size,0x40) - end - PointsBuffer = PointsBuffer .. string.char(size) - else - PointsBuffer = PointsBuffer .. string.char(0) + size = bor(size,0x40) + end + PointsBuffer = PointsBuffer .. string.char(size) + else + PointsBuffer = PointsBuffer .. string.char(0) end if #PointsBuffer > 245 then - ParseCommand('draw '..PointsBuffer) + ParseCommand('draw '..PointsBuffer) PointsBuffer = '' - end + end end function FlushPoints() if #PointsBuffer > 0 then - ParseCommand('draw '..PointsBuffer) + ParseCommand('draw '..PointsBuffer) PointsBuffer = '' end end @@ -40,31 +40,31 @@ function onGameInit() - MapGen = 2 - TemplateFilter = 0 + MapGen = 2 + TemplateFilter = 0 - AddPoint(100,100,true,10) - AddPoint(2000,2000) - AddPoint(2000,100,true,10) - AddPoint(100,2000) - AddPoint(1000,1000,true,63,true) + AddPoint(100,100,true,10) + AddPoint(2000,2000) + AddPoint(2000,100,true,10) + AddPoint(100,2000) + AddPoint(1000,1000,true,63,true) for i = 63,2,-4 do - AddPoint(2000,1000,true,i) - AddPoint(2000,1000,true,i-2,true) + AddPoint(2000,1000,true,i) + AddPoint(2000,1000,true,i-2,true) end for i = 1,2000,50 do - AddPoint(i+2000,2000,true,1) - AddPoint(4000,2000-i) + AddPoint(i+2000,2000,true,1) + AddPoint(4000,2000-i) end AddPoint(2000,2000,true,1) - AddPoint(4000,2000) + AddPoint(4000,2000) AddPoint(4000,0,true,1) - AddPoint(4000,2000) + AddPoint(4000,2000) - FlushPoints() + FlushPoints() end The first set of AddPoints draws a large X and erases the centre.