Draw in while loop

Currently, while skips the process and only the result remains. This causes the glitch in gimmick of landing or moving or pushing on the ice and creates inconvenience.

code:

on iceslip do
	ignore
	dcx = event.px
	dcy = event.py
	while ishole=="ice" do
		dcx += event.dx
		dcy += event.dy
		ishole = name dcx,dcy
		issolid = solid dcx,dcy
		wait 0.5 then
			if issolid==1 then
				listen
				done
			else
				goto dcx,dcy
			end
		end
	end
	listen
end

I had this problem when I first started with Pulp. I use recursion to do loops that contain a wait since a while loop ignores it.

on iceslip do
	ignore
	dcx = event.px
	dcy = event.py
	call "iceloop"
end

on iceloop do
	if ishole=="ice" then
		dcx += event.dx
		dcy += event.dy
		ishole = name dcx,dcy
		issolid = solid dcx,dcy
		wait 0.5 then
			if issolid==1 then
				listen
				ishole == "ice" //this replaces the 'done' statement
			else
				goto dcx,dcy
				call "iceloop" //this is where the loop repeats
			end
		end
	else //this function will be called regardless of the tile
		listen
	end
end

How about sprites?

on interact do
	dcx = event.tx
	dcy = event.ty
	call "push"
end

on push do
	dcx += event.dx
	dcy += event.dy
	ishole = name dcx,dcy
	if ishole=="hole" then
		sound "decoypush"
		swap "white"
		tell dcx,dcy to
			swap "white"
		end
	elseif ishole=="white" then
		sound "decoypush"
		swap "white"
		tell dcx,dcy to
			swap "decoy"
		end
	elseif ishole=="ice" then
		sound "decoypush"
		swap "white"
		tell dcx,dcy to
			swap "decoyice"
			call "iceslip"
		end
	end
end

on iceslip do
	ignore
	while ishole=="ice" do
		icex = dcx
		icey = dcy
		wait 5 then
			dcx += event.dx
			dcy += event.dy
			ishole = name dcx,dcy
			if ishole=="hole" then
				tell icex,icey to
					swap "ice"
				end
				tell dcx,dcy to
					swap "white"
				end
			elseif ishole=="white" then
				tell icex,icey to
					swap "ice"
				end
				tell dcx,dcy to
					swap "decoy"
				end
			elseif ishole=="ice" then
				tell icex,icey to
					swap "ice"
				end
				tell dcx,dcy to
					swap "decoyice"
				end
			elseif ishole=="decoyice" then
				tell icex,icey to
					swap "ice"
				end
			end
		end
	end
	listen
end

edit: nvm recursion worked to sprites too

Sprite part with recursion if someone faced similar issue:

on push do
	dcx += event.dx
	dcy += event.dy
	ishole = name dcx,dcy
	if ishole=="hole" then
		sound "decoypush"
		swap "white"
		tell dcx,dcy to
			swap "white"
		end
	elseif ishole=="white" then
		sound "decoypush"
		swap "white"
		tell dcx,dcy to
			swap "decoy"
		end
	elseif ishole=="ice" then
		sound "decoypush"
		swap "white"
		ignore
			tell dcx,dcy to
				swap "decoyice"
		wait 0.5 then
				call "iceslip"
			end
		end
	end
end

on iceslip do
		icex = dcx
		icey = dcy
		dcx += event.dx
		dcy += event.dy
		ishole = name dcx,dcy
		//say "!" at dcx,dcy then
			 wait 0.5 then
			tell icex,icey to
				swap "ice"
			end
			if ishole=="ice" then
				tell dcx,dcy to
					swap "decoyice"
call "iceslip"
				end
			elseif ishole=="decoyice" then
				tell icex,icey to
					swap "decoyice"
				end
				sound "decoypush"
				ishole = "ice"
				dcx += event.dx
				dcy += event.dy
			tell dcx,dcy to
				call "iceslip"
			end
			else
				if ishole=="hole" then
					tell dcx,dcy to
						swap "white"
					end
				elseif ishole=="white" then
					tell dcx,dcy to
						swap "decoy"
					end
				end
				listen
			end
		end
end

This way just a small lag and no freeze.

Commented say command was there to measure (overwrapped UI is also a glitch, be careful)