Program that tells a basic robot to build a brick tower in Minetest

local function init(progname)
  if (stat==nil) then
   say(progname)
   i=0  stat="ok" w=0
 
   s1="default:brick"

   move.forward()
   move.forward()
   turn.right()
  end
 end
 
 local function work()
   w=w+1
   move.forward()
   place.down(s1)
 end
 
 init("Build-a-thing")

if (w % 4 == 0) then
 turn.left()
end

if (w %  16 == 0) then
 move.up()
end

 if w>=6400 then
   stat="Done."  say(stat)  self.remove()
 else
   work() 
 end