Try this one.
Click the mouse to change the matrix tile's color to red:
sync on
sync rate 0
matrixsizex=20
matrixsizey=20
matrixtilesx=20
matrixtilesy=20
matrixtilesizex=matrixsizex/matrixtilesx
matrixtilesizey=matrixsizey/matrixtilesy
`Matrix texture image
ink rgb(0,255,0),0
box 1,1,10,10
ink rgb(255,0,0),0
box 11,1,20,10
get image 1,0,0,20,10,1
`Matrix
make matrix 1,matrixsizex,matrixsizey,matrixtilesx,matrixtilesy
prepare matrix texture 1,1,2,1
fill matrix 1,0,1
update matrix 1
`Plane object (is necessary for pick object to work correctly)
make object plane 1,matrixsizex,matrixsizey
position object 1,matrixsizex/2,-0.5,matrixsizey/2
xrotate object 1,90
fix object pivot 1
`Camera
position camera 0,20,0
point camera 10,0,10
do
if mouseclick()=1 and clicked=0
clicked=1
`Find the location of the mouse in 3D space on the matrix's level
null=pick object(mousex(),mousey(),1,2)
`Get those coordinates
tempx=get pick vector x()+camera position x()
tempz=get pick vector z()+camera position z()
tempx=(tempx)/matrixtilesizex
tempz=(tempz)/matrixtilesizey
if tempx<matrixtilesx and tempz<matrixtilesy and tempx>0 and tempz>0
set matrix tile 1,tempx,tempz,2
update matrix 1
endif
endif
if mouseclick()=0 then clicked=0
sync
loop