Lingo if boolean problem
KenSevens20 Feb 1, 2008 5:09 AMI've got a simple director problem that should be very easy
to solve.
I've got a program that allows the user to place 2 sprites on to 2 targets. The 2 sprites are barrels, and the 2 targets are podiums. Everything works fine, apart from one thing. I have a property called podium1full, and i want to check whether the value of this property is true or false. This will tell the program whether a barrel is already placed on the podium or not when the user tries to put a 2nd barrel on a podium that already has a barrel.
The full script is in this e-mail below. I have included the director file as an attachment. I would be very grateful if you could please help me out with this.
Basically, if I try to put sprite(5) on to podium1 when sprite(4) is already on it, the program puts sprite(5) on podium1, despite the fact that I've got an if boolean statement to stop that happening.
Thanks.
Thor Putnis (MSc Creative Tech)
property podium1full -- is podium one full or empty?
property podium2full -- is podium two full or empty?
on mouseDown me
if sprite(4).loc = point (141,550) then
if sprite(5).loc = point (641,550) then
set podium1full = FALSE
set podium2full = FALSE
end if
end if
-- This section of the script checks whether both barrels have been reset recently.
-- If they have, make sure that the program knows that both podiums are empty when the mouse is pressed down on a barrel
end mouseDown
on mouseUp me
if sprite(4).moveableSprite = TRUE then -- this line checks that the barrel has not been put on a podium
if sprite(4).locV<(340) then
if sprite(4).locV>(45) then
if sprite(4).locH<(265) then
if sprite(4).locH>(0) then -- these for lines check if the left hand barrel is anywhere near the left podium
if podium1full = FALSE then -- this line is supposed to check whether the podium is full, but it does not work. Why?
sprite(4).loc = point (141,171) -- After all the checks have been done, this line places the barrel into place on the podium
set podium1full = TRUE -- Once the podium is full, set the property value to full
sprite(4).moveableSprite = FALSE -- This line locks the barrel into place
else
sprite(4).loc = point (141,550) -- If the podium is full, this line places the barrel back into its start position
end if
end if
end if
end if
end if
end if
-- the next section of code is exactly the same as above, except this is for the right barrel on the left podium.
if sprite(5).moveableSprite = TRUE then
if sprite(5).locV<(340) then
if sprite(5).locV>(45) then
if sprite(5).locH<(265) then
if sprite(5).locH>(0) then
if podium1full = FALSE then
sprite(5).loc = point (141,171)
set podium1full = TRUE
sprite(5).moveableSprite = FALSE
else
sprite(5).loc = point (641,550)
end if
end if
end if
end if
end if
end if
-- this is the script for the left barrel on the right podium
if sprite(4).moveableSprite = TRUE then
if sprite(4).locV<(291) then
if sprite(4).locV>(55) then
if sprite(4).locH<(766) then
if sprite(4).locH>(516) then
if podium2full = FALSE then
sprite(4).loc = point (641,171)
set podium2full = TRUE
sprite(4).moveableSprite = FALSE
else
sprite(4).loc = point (141, 550)
end if
end if
end if
end if
end if
end if
-- this is the script for the right barrel on the right podium
if sprite(5).moveableSprite = TRUE then
if sprite(5).locV<(291) then
if sprite(5).locV>(55) then
if sprite(5).locH<(766) then
if sprite(5).locH>(516) then
if podium2full = FALSE then
sprite(5).loc = point (641,171)
set podium2full = TRUE
sprite(5).moveableSprite = FALSE
else
sprite(5).loc = point (641,550)
end if
end if
end if
end if
end if
end if
end
I've got a program that allows the user to place 2 sprites on to 2 targets. The 2 sprites are barrels, and the 2 targets are podiums. Everything works fine, apart from one thing. I have a property called podium1full, and i want to check whether the value of this property is true or false. This will tell the program whether a barrel is already placed on the podium or not when the user tries to put a 2nd barrel on a podium that already has a barrel.
The full script is in this e-mail below. I have included the director file as an attachment. I would be very grateful if you could please help me out with this.
Basically, if I try to put sprite(5) on to podium1 when sprite(4) is already on it, the program puts sprite(5) on podium1, despite the fact that I've got an if boolean statement to stop that happening.
Thanks.
Thor Putnis (MSc Creative Tech)
property podium1full -- is podium one full or empty?
property podium2full -- is podium two full or empty?
on mouseDown me
if sprite(4).loc = point (141,550) then
if sprite(5).loc = point (641,550) then
set podium1full = FALSE
set podium2full = FALSE
end if
end if
-- This section of the script checks whether both barrels have been reset recently.
-- If they have, make sure that the program knows that both podiums are empty when the mouse is pressed down on a barrel
end mouseDown
on mouseUp me
if sprite(4).moveableSprite = TRUE then -- this line checks that the barrel has not been put on a podium
if sprite(4).locV<(340) then
if sprite(4).locV>(45) then
if sprite(4).locH<(265) then
if sprite(4).locH>(0) then -- these for lines check if the left hand barrel is anywhere near the left podium
if podium1full = FALSE then -- this line is supposed to check whether the podium is full, but it does not work. Why?
sprite(4).loc = point (141,171) -- After all the checks have been done, this line places the barrel into place on the podium
set podium1full = TRUE -- Once the podium is full, set the property value to full
sprite(4).moveableSprite = FALSE -- This line locks the barrel into place
else
sprite(4).loc = point (141,550) -- If the podium is full, this line places the barrel back into its start position
end if
end if
end if
end if
end if
end if
-- the next section of code is exactly the same as above, except this is for the right barrel on the left podium.
if sprite(5).moveableSprite = TRUE then
if sprite(5).locV<(340) then
if sprite(5).locV>(45) then
if sprite(5).locH<(265) then
if sprite(5).locH>(0) then
if podium1full = FALSE then
sprite(5).loc = point (141,171)
set podium1full = TRUE
sprite(5).moveableSprite = FALSE
else
sprite(5).loc = point (641,550)
end if
end if
end if
end if
end if
end if
-- this is the script for the left barrel on the right podium
if sprite(4).moveableSprite = TRUE then
if sprite(4).locV<(291) then
if sprite(4).locV>(55) then
if sprite(4).locH<(766) then
if sprite(4).locH>(516) then
if podium2full = FALSE then
sprite(4).loc = point (641,171)
set podium2full = TRUE
sprite(4).moveableSprite = FALSE
else
sprite(4).loc = point (141, 550)
end if
end if
end if
end if
end if
end if
-- this is the script for the right barrel on the right podium
if sprite(5).moveableSprite = TRUE then
if sprite(5).locV<(291) then
if sprite(5).locV>(55) then
if sprite(5).locH<(766) then
if sprite(5).locH>(516) then
if podium2full = FALSE then
sprite(5).loc = point (641,171)
set podium2full = TRUE
sprite(5).moveableSprite = FALSE
else
sprite(5).loc = point (641,550)
end if
end if
end if
end if
end if
end if
end


