Discuss Scratch

Quiet_Child
Scratcher
6 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.

Comeback time? Maybe?
DaEnderBoss
Scratcher
73 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
6 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
6 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
36 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)

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)


High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
Quiet_Child
Scratcher
6 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
6 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!
Ninipoke
Scratcher
45 posts

Code is not running

when green flag clicked
repeat ( [My blocks don´t work...] for (2) secs
move (BARELY ANY CODE??) steps
ask [why?] and wait
)






when [HELP v] key pressed
play sound [WHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY v] until done
It is just forever move ten steps? why such a big deal?

Last edited by Ninipoke (Feb. 28, 2020 00:05:09)

codeman1044
Scratcher
1000+ posts

Code is not running

Please avoid necroposting and (block)spamming. If you would like help with an issue, please make your own topic.

This is my signature, which shows up every time I post and is automatic. To make a signature of your own, locate the “Change your signature” option in the bottom left of the Discussion Home.
I am nothing if not consistently inconsistent.
Snap! is a website that offers block coding like Scratch, but also offers the creation of your own blocks and writing JavaScript functions. The adventurous should consider checking it out!
Potentially useful tutorials and topic coverage
If you want to see a new tutorial added to this, feel free to leave a suggestion on my profile.

Powered by DjangoBB