Edited wiki page LuaDrawing through web user interface.
authorkyberneticist@gmail.com
Fri, 19 Oct 2012 21:00:58 +0000
changeset 255 18e1a94e1591
parent 254 a21261c77793
child 256 0b93b3ec3ebf
Edited wiki page LuaDrawing through web user interface.
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 @@
 
 <code lang="lua">
 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
 </code>
 The first set of AddPoints draws a large X and erases the centre.