http://www.cr31.co.uk/stagecast/wang/blob.html

I use the 8x6 shape here. The only tricky part is to consider that a side covers two corners, so their bits should be set to zero if the side is present.

I check the corners first, then the sides, then with the the bitmask I do a search into the the array I've set up at the beginning.

Code: Select all

```
plotscript, auto tile, par
variable(base, zone, layer, x, y, z, bm)
base = 256
write global (base + 0, 0)
write global (base + 1, 4)
write global (base + 2, 92)
write global (base + 3, 112)
write global (base + 4, 28)
write global (base + 5, 124)
write global (base + 6, 116)
write global (base + 7, 64)
write global (base + 8, 20)
write global (base + 9, 84)
write global (base + 10, 87)
write global (base + 11, 221)
write global (base + 12, 127)
write global (base + 13, 255)
write global (base + 14, 245)
write global (base + 15, 80)
write global (base + 16, 29)
write global (base + 17, 117)
write global (base + 18, 85)
write global (base + 19, 95)
write global (base + 20, 247)
write global (base + 21, 215)
write global (base + 22, 209)
write global (base + 23, 1)
write global (base + 24, 23)
write global (base + 25, 213)
write global (base + 26, 81)
write global (base + 27, 31)
write global (base + 28, 253)
write global (base + 29, 125)
write global (base + 30, 113)
write global (base + 31, 16)
write global (base + 32, 21)
write global (base + 33, 69)
write global (base + 34, 93)
write global (base + 35, 119)
write global (base + 36, 223)
write global (base + 37, 255)
write global (base + 38, 241)
write global (base + 39, 17)
write global (base + 40, 5)
write global (base + 41, 68)
write global (base + 42, 71)
write global (base + 43, 193)
write global (base + 44, 7)
write global (base + 45, 199)
write global (base + 46, 197)
write global (base + 47, 65)
zone = 10
layer = 3
for (y, 1, map height () - 2) do (
for (x, 1, map width () - 2) do (
bm = 0
if (not(read zone (zone, x, y))) then (
continue
)
if (read zone (zone, x + 1, y - 1)) then (
bm = bm | 0b00000010
)
if (read zone (zone, x + 1, y + 1)) then (
bm = bm | 0b00001000
)
if (read zone (zone, x - 1, y + 1)) then (
bm = bm | 0b00100000
)
if (read zone (zone, x - 1, y - 1)) then (
bm = bm | 0b10000000
)
if (read zone (zone, x + 0, y - 1)) then (
bm = bm | 0b00000001
) else (
bm = bm & 0b01111101
)
if (read zone (zone, x + 1, y + 0)) then (
bm = bm | 0b00000100
) else (
bm = bm & 0b11110101
)
if (read zone (zone, x + 0, y + 1)) then (
bm = bm | 0b00010000
) else (
bm = bm & 0b11010111
)
if (read zone (zone, x - 1, y + 0)) then (
bm = bm | 0b01000000
) else (
bm = bm & 0b01011111
)
for (z, 0, 47) do (
if (read global(base + z) == bm) then (
break
)
)
write map block (x, y, (z / 8 + 4) * 16 + z % 8, layer)
)
)
end
```