This code is not working when calling “drawlight“. Why?
on collect do
if uiok>0 then
ask "Remove?" then
option "Yes" then
call "erasebulb"
end
option "No" then
done
end
end
end
end
on datainit do
blbx = event.px
blby = event.py
blbtmr = 4
blblf = 1
blbuf = 1
blbrf = 1
blbdf = 1
blblx = blbx
blbuy = blby
blbrx = blbx
blbdy = blby
end
on drawlight do
log "{blbx},{blby}"
call "datainit"
while blbtmr>0 do
blbtmr = blblf
blbtmr += blbuf
blbtmr += blbrf
blbtmr += blbdf
if blbtmr==0 then
uiok = 1
log "uiok = 1"
done
end
wait 1 then
if blblf>0 then
blblx -= 1
ishole = name blblx,blby
if ishole=="black" then
blblf = 0
else
dcx = blblx
dcy = blby
call "drawlightlr"
end
end
if blbuf>0 then
blbuy -= 1
ishole = name blbx,blbuy
if ishole=="black" then
blbuf = 0
else
dcx = blbx
dcy = blbuy
call "drawlightud"
end
end
if blbrf>0 then
blbrx += 1
ishole = name blbrx,blby
if ishole=="black" then
blbrf = 0
else
dcx = blbrx
dcy = blby
call "drawlightlr"
end
end
if blbdf>0 then
blbdy += 1
ishole = name blbx,blbdy
if ishole=="black" then
blbdf = 0
else
dcx = blbx
dcy = blbdy
call "drawlightud"
end
end
end
end
end
on drawlightud do
if ishole=="Linelr" then
tell dcx,dcy to
swap "Linex"
end
elseif ishole=="Blank" then
tell dcx,dcy to
swap "Lineud"
end
elseif ishole=="white" then
tell dcx,dcy to
swap "Lineud"
end
end
end
on drawlightlr do
if ishole=="Lineud" then
tell dcx,dcy to
swap "Linex"
end
elseif ishole=="Blank" then
tell dcx,dcy to
swap "Lineud"
end
elseif ishole=="white" then
tell dcx,dcy to
swap "Linelr"
end
end
end
on erasebulb do
swap white
call "eraselight"
end
on eraselight do
log "{blbx},{blby}"
call "datainit"
while blbtmr>0 do
blbtmr = blblf
blbtmr += blbuf
blbtmr += blbrf
blbtmr += blbdf
if blbtmr==0 then
uiok = 1
log "uiok = 1"
done
end
wait 1 then
log "wait"
if blblf>0 then
blblx -= 1
ishole = name blblx,blby
if ishole=="black" then
blblf = 0
else
dcx = blblx
dcy = blby
call "eraselightlr"
end
end
if blbuf>0 then
blbuy -= 1
ishole = name blbx,blbuy
if ishole=="black" then
blbuf = 0
else
dcx = blbx
dcy = blbuy
call "eraselightud"
end
end
if blbrf>0 then
blbrx += 1
ishole = name blbrx,blby
if ishole=="black" then
blbrf = 0
else
dcx = blbrx
dcy = blby
call "eraselightlr"
end
end
if blbdf>0 then
blbdy += 1
ishole = name blbx,blbdy
if ishole=="black" then
blbdf = 0
else
dcx = blbx
dcy = blbdy
call "eraselightud"
end
end
end
end
end
on eraselightlr do
if ishole=="Linelr" then
tell dcx,dcy to
swap "white"
end
elseif ishole=="Linex" then
tell dcx,dcy to
swap "Lineud"
end
end
end
on eraselightud do
if ishole=="Lineud" then
tell dcx,dcy to
swap "white"
end
elseif ishole=="Linex" then
tell dcx,dcy to
swap "Linelr"
end
end
end