This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-01-16 21:18:13

FCbarcal0na
New Scratcher
Registered: 2012-01-16
Posts: 2

Question about stopping scripts

I am doing a project for school, and I have a problem. I have lasers that appear and vanish every few seconds, and the player must navigate them. I am using a simple system of:
       -Forever
       | SHOW
       |WAIT 1 SEC
       | HIDE
       | WAIT 2 SEC
       ____________

To control when the lasers pop up.

This works fine, but then, once the player makes contact with an object called SER (Smooth Endoplasmic Reticulum) , SER broadcasts "Card Show." Card show causes a card to pop up on the screen which displays information on SER. I have the scripts set so that when key "F" is pressed, the SER card will hide.

Now I want the lasers to hide, and I have it set so that when "F" is pressed, not only will the card hide, but the lasers will too. What is happening is that the forever loop shown above causes the order to hide issued from the "F" key to happen, but then it just goes right back to the hiding and showing of the lasers!

I was wondering if any of you guys know how to stop the script in the forever loop (but not ALL the scripts) when f is pressed so that there won't be random lasers popping up every few seconds throughout the rest of my game

If you need any more clarification on the problem, just ask me in a post.

Thanks so much- FCbarcal0na  smile

Offline

 

#2 2012-01-16 21:35:14

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Question about stopping scripts

Hm... well, if the lasers won't need to show once again after being hidden with the 'f' key, you can just replace the forever block with "repeat until <key f pressed>". The entire script will then stop. You shouldn't need a separate script to make sure that it's hidden either, because the loop will finish the block of script it's currently running first.


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2012-01-16 21:41:28

CatPerson
Scratcher
Registered: 2011-12-17
Posts: 1000+

Re: Question about stopping scripts

I dont think that is possible... but if you find out a way please tell me  smile

/\_/\
I ' . ' I  CatPerson


http://nyopoliticker.files.wordpress.com/2012/02/in_dog_we_trust_rusty.jpghttps://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSrxH2RAmte9adghivuoOhgklIlUcZUFuCAA0wFufFq-NWyZWg5http://www.buttonsonline.com/2012/obama/BO-rallysign-104.gif

Offline

 

#4 2012-01-17 07:57:28

FCbarcal0na
New Scratcher
Registered: 2012-01-16
Posts: 2

Re: Question about stopping scripts

Thank you SO much Harakou! Your solution worked perfectly andn ow I can continue with my project!

Thanks!- FCbarcal0na

Offline

 

#5 2012-01-17 08:11:09

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Question about stopping scripts

Glad to help!  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#6 2012-01-17 12:13:27

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Question about stopping scripts

use a veriable that sets to 1 then ise

when variable =1
stop script


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

Board footer