Discuss Scratch

Quiet_Child
Scratcher
5 posts

Code is not running

I am making a classic dungeon crawling game. However, new code I have been adding has ceased to run. At first I thought it was a bug, (maybe it is,) after a certain point, code I've added has simply ceased to run. Is there a block limit?

My game is here here. If you do choose to help, thank you!
sonicfan12p
Scratcher
1000+ posts

Code is not running

Can you tell us which scripts are working, and which are not? I can tell you for certain that there isn't a block limit though.

Inactive account. Please direct all questions to my secretary.
DaEnderBoss
Scratcher
46 posts

Code is not running

I looked into your game and on the ‘or’ sprite, for the moment, you have two forever loops. This won't work. You can only have one forever loop otherwise everything else in the first loop won't run.
when green flag clicked
forever
if <> then
this 'if' won't run and nether everything in it.
end
forever
if <key [ right key] pressed?> then
move () steps
end
if <key [ left key] pressed?> then
move () steps
end
if <key [ up key] pressed?> then
move () steps
end
if <key [ down key] pressed?> then
move () steps
end
end
end
Quiet_Child
Scratcher
5 posts

Code is not running

Ok. The code that isn't working is stored in the beetle sprite. It is supposed to execute a series of attacks. The other code that won't run is when the message “trap” is activated. The code for 'trap is stored in the chest sprite. When it activates, a health bar is supposed to appear. Though other code reacts, the code in the health bar, titled, “boss-health-pixilart” does not run. Thank you for the advice with the forever loops. I will try to find a way to remove one in such a way that the code still runs.
Quiet_Child
Scratcher
5 posts

Code is not running

Also, the beetle sprite isn't taking damage when it touches the waterball and fireball sprites.Realized my code was a total mess, so I organized it and added comments!
leicestertiger
Scratcher
24 posts

Code is not running

I agree.
when green flag clicked
forever
do stuff
end
is right.
when green flag clicked
forever
forever
do stuff
end
end
is wrong.

Last edited by leicestertiger (March 8, 2018 18:37:44)


when I visit this website :: events hat
repeat until <tired :: sensing>
scratch :: events
end
sleep :: sensing cap
deck26
Scratcher
1000+ posts

Code is not running

leicestertiger wrote:

I agree.
when green flag clicked
forever
do stuff
end
is right.
when green flag clicked
forever
forever
do stuff
end
end
is wrong.
Your example doesn't affect anything though, whereas doing this

forever
do A
forever
do B
end
end
means doA can only happen once and the outer forever loop is redundant. Yes, one forever loop should still be removed in your example.

That's not to say it's never valid to do this as long as there's an if block or something controlling access to the inner forever loop.
mstone326
Scratcher
1000+ posts

Code is not running

Is this what you are looking for. You should use broadcast and wait with the custom block attached to that so they can run until completion. I made the beetle speak so we know each block is being executed in its entirety. It is merely for proof the code is in running order. If you look at your code you'll notice thatattack1 has a forever loop on it so it never stops and doesn' allows to get to attack2, without attack1 still running.

ALso, with attack3. You have the beetle changing Y by 50 first, which will move him up, then -50. Should be reversed, to move down towards teh player and then back up. However, putting them back to back blocks you don't see the lunge. I added a wait block inbetween those moves.

See if this helps.

https://scratch.mit.edu/projects/208718894/

Edit:

Also, your boss health bar was below the stage at Y -192 or something. It was way down and behind your border. I put a show and go to front on the broadcast and it seem sto work. I moved it to the lower right corner. Also, show doesn't need to be in the forever loop. Just tell it to show once, same with go to front.

Last edited by mstone326 (March 8, 2018 19:40:34)


Technology Director / Teacher Grades K-8
Head High School Baseball Coach

Halloween Boss Battle - Taking Back our Woods
https://scratch.mit.edu/projects/257155118/
Most Recent - Meltman
https://scratch.mit.edu/projects/144049407/
Studio - My Best Projects
https://scratch.mit.edu/studios/4125978/
Quiet_Child
Scratcher
5 posts

Code is not running

mstone326 wrote:

Is this what you are looking for. You should use broadcast and wait with the custom block attached to that so they can run until completion. I made the beetle speak so we know each block is being executed in its entirety. It is merely for proof the code is in running order. If you look at your code you'll notice thatattack1 has a forever loop on it so it never stops and doesn' allows to get to attack2, without attack1 still running.

ALso, with attack3. You have the beetle changing Y by 50 first, which will move him up, then -50. Should be reversed, to move down towards teh player and then back up. However, putting them back to back blocks you don't see the lunge. I added a wait block inbetween those moves.

See if this helps.

https://scratch.mit.edu/projects/208718894/

Edit:

Also, your boss health bar was below the stage at Y -192 or something. It was way down and behind your border. I put a show and go to front on the broadcast and it seem sto work. I moved it to the lower right corner. Also, show doesn't need to be in the forever loop. Just tell it to show once, same with go to front.
You ma'am, have saved my school career. I think I'm going to cry, and I can't thank you enough. Thank you!

Last edited by Quiet_Child (March 12, 2018 20:11:53)

Quiet_Child
Scratcher
5 posts

Code is not running

I'm putting this forum in the notes and credits for the game, because this has been so helpful. Thank you guys!

Powered by DjangoBB

Standard | Mobile