puzzle game migrate from actionscript

hi All,

I just migrate my actionscript code to lua.

I don’t know why this searchBlock doesn’t work.

It only do one of the condition inside this function. What I’m don’t wrong.

I try to find the solution in this web. I find a similar “match 3 gems” share code. But it use a “Self” instead of my parameter to searchBlock function.

Please kindly help! my code is here:

local function searchBlock(b_x,b_y,b_c)

colourNum = colourNum + 1

tempPos = tostring(b_x…b_y)
temp[tempPos] = 0
right =(b_x+1)…b_y
left =(b_x-1)…b_y
down =b_x…(b_y+1)
up =b_x…(b_y-1)
downCeling =b_x…downCel
upCeling =b_x…upCel
tr = temp[right]
tl = temp[left]
tu = temp[up]
td = temp[down]

if tr == b_c then
print(“1>”…b_c)

print (“right”)

b_tx=b_x+1
b_ty=b_y
b_tc=b_c

print(“this is right btx …”)
print(b_tx)
print(b_ty)
print(b_tc)
d = tile[right]
searchBlock(b_tx,b_ty,b_tc)

end

if tl == b_c then
print(“2>”…b_c)

print (“left”)

b_tx=b_x-1
b_ty=b_y
b_tc=b_c
print(“this is left btx …”)
print(b_tx)
print(b_ty)
print(b_tc)
d = tile[left]
searchBlock(b_tx,b_ty,b_tc)

end

if tu == b_c then
print(“3>”…b_c)

print (“up”)

b_tx=b_x
b_ty=b_y-1
b_tc=b_c
print(“this is up btx …”)
print(b_tx)
print(b_ty)
print(b_tc)
d = tile[up]
searchBlock(b_tx,b_ty,b_tc)

end

if td == b_c then
print(“4>”…b_c)

print (“down”)

b_tx=b_x
b_ty=b_y+1
b_tc=b_c
print(“this is down btx …”)
print(b_tx)
print(b_ty)
print(b_tc)
d = tile[down]

searchBlock(b_tx,b_ty,b_tc)

end
end

end
[import]uid: 94613 topic_id: 33070 reply_id: 333070[/import]