Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Clone Coding Problem [SOLVED]
- Bjuice
-
Scratcher
21 posts
Clone Coding Problem [SOLVED]
First of all, thanks for the attention.
I`m facing two glitches that i absolutely don`t know how to fix:
In order for the HP bar to appear within the next monsters to be born, there must always be a living monster in the field, in other words,
if I annihilate all the living monsters in the scenario, and there is none alive until the next one appears, now the hp bar will no longer appear.
To remain without this error, I must wait for another monster to be born, so that I can kill the one before. I come to appeal then, here in the forum because I do not know what else to do.
The other one, is that the slimes don`t move!
To test the game, please click “Start” then “Hunt” and kill the slime before another one spawns.
https://scratch.mit.edu/projects/37479888/
I`m facing two glitches that i absolutely don`t know how to fix:
In order for the HP bar to appear within the next monsters to be born, there must always be a living monster in the field, in other words,
if I annihilate all the living monsters in the scenario, and there is none alive until the next one appears, now the hp bar will no longer appear.
To remain without this error, I must wait for another monster to be born, so that I can kill the one before. I come to appeal then, here in the forum because I do not know what else to do.
The other one, is that the slimes don`t move!
To test the game, please click “Start” then “Hunt” and kill the slime before another one spawns.
https://scratch.mit.edu/projects/37479888/
Last edited by Bjuice (April 9, 2018 20:38:22)
- crisostimo
-
Scratcher
500+ posts
Clone Coding Problem [SOLVED]
Have you tried using broadcast and wait on MonsterSpawn before broadcasting Create Hp Bar?
- Bjuice
-
Scratcher
21 posts
Clone Coding Problem [SOLVED]
Unfortunately, the issue remains.
Is that the right block you recommended me to edit?
To be honest, The problem is not exactly in this block. I think it`s actually something with the var (Clone#P) and the beginning of clone scripts, but I don`t clearly see why it`s not working.
Is that the right block you recommended me to edit?
define (SpawnMonsters)
change [Clone#P] by (1)
create clone of [this object]
if <([costume number] of [Button-Graphics]) = [2]> then
broadcast [MonsterSpawn] and wait
broadcast [Create Hp bar]
end
To be honest, The problem is not exactly in this block. I think it`s actually something with the var (Clone#P) and the beginning of clone scripts, but I don`t clearly see why it`s not working.
Last edited by Bjuice (April 7, 2018 23:15:49)
- crisostimo
-
Scratcher
500+ posts
Clone Coding Problem [SOLVED]
Yeah. I'm not sure exactly what the problem is, but here is something I do to track down problems.
I create a list called ‘Debug Messages’, then when there is a script that I think should be called, I add a temporary block that adds an item to that list. You can put things like variable values or just simple messages in there. That way you can see if the state you think it should be in matches what Scratch thinks the state is.
I create a list called ‘Debug Messages’, then when there is a script that I think should be called, I add a temporary block that adds an item to that list. You can put things like variable values or just simple messages in there. That way you can see if the state you think it should be in matches what Scratch thinks the state is.
- Bjuice
-
Scratcher
21 posts
Clone Coding Problem [SOLVED]
Thank you for the advice, that was great and simple. I see exactly where the problem is now, but I don`t see why it happens, pretty peculiar.
The “Movement and Positioning” script does not work between the “show” command and the next “if” condition…
This whole block does not work:
Everything below this block, seems to be working well.
sorry, I could n`t reproduce the exact same block here, as I am new to forum topics.
The “Movement and Positioning” script does not work between the “show” command and the next “if” condition…
This whole block does not work:
if <(costume #) = [5]> then
forever
replace item (Clone#P) of [Clone(x,0)] with [(x position)]
replace item (Clone#P) of [Clone(0,y)] with [(y position)]
point towards [PlayerHead]
if <(distance to [PlayerChest]) > [10]>
move (square of (square of ((mod of (item (Clone#P) of [CloneHP] :: list)/50)) steps
end
end
end
Everything below this block, seems to be working well.
sorry, I could n`t reproduce the exact same block here, as I am new to forum topics.
Last edited by Bjuice (April 7, 2018 23:45:13)
- crisostimo
-
Scratcher
500+ posts
Clone Coding Problem [SOLVED]
I'm not sure which Sprite this is in.
Realize that this code will only check if the costume number is 5 once. The forever loop inside will not cause the if check to happen.
Another problem that sometimes happens is that you may have typed ‘5 ’ or ‘ 5’ instead of just ‘5’.
You can always add the costume # to that debug list I talked about just before the if statement to see what it is checking.
Realize that this code will only check if the costume number is 5 once. The forever loop inside will not cause the if check to happen.
Another problem that sometimes happens is that you may have typed ‘5 ’ or ‘ 5’ instead of just ‘5’.
You can always add the costume # to that debug list I talked about just before the if statement to see what it is checking.
- RABBIT137000
-
Scratcher
15 posts
Clone Coding Problem [SOLVED]
I have an other question, how delete all clones of a sprite at same time, without variables ?
- deck26
-
Scratcher
1000+ posts
Clone Coding Problem [SOLVED]
I have an other question, how delete all clones of a sprite at same time, without variables ?Make a broadcast that the clones respond to by deleting themselves.
- RABBIT137000
-
Scratcher
15 posts
Clone Coding Problem [SOLVED]
yes but a broadcast is a start of a script, and the start of the script of a clone is
when I start as a clonenot
when I receive [ broadcast]
- deck26
-
Scratcher
1000+ posts
Clone Coding Problem [SOLVED]
yes but a broadcast is a start of a script, and the start of the script of a clone isDoesn't matter, clones respond to broadcasts!when I start as a clonenotwhen I receive [ broadcast]
- Bjuice
-
Scratcher
21 posts
Clone Coding Problem [SOLVED]
I'm not sure which Sprite this is in.
Realize that this code will only check if the costume number is 5 once. The forever loop inside will not cause the if check to happen.
Another problem that sometimes happens is that you may have typed ‘5 ’ or ‘ 5’ instead of just ‘5’.
You can always add the costume # to that debug list I talked about just before the if statement to see what it is checking.
Yes, it is mean`t to check the costume only once, then start to move as a slime (costume “5” refers to the “slime idle” costume). This block is located at the “MonsterSpawner” object.
The type of monsters to be created is defined by the costume selected before, so, if I change it`s costume to 5 and immediately then create a self clone, when started as a clone, the movement block will detect it once and start to move as a slime until this clone is deleted. So i figured exactly where the problem is by your debugging tip, as i showed before with that block in post #5.
I checked if there is any “space” next to the “5” number, and no, it is alone. The slime still won`t move.
Last edited by Bjuice (April 8, 2018 17:50:43)
- Bjuice
-
Scratcher
21 posts
Clone Coding Problem [SOLVED]
Good News, the slime can walk again!
The “Attack Block” and “Movement Block” were both conflicting, see why:
The first block is responsible by the walking animation too, so it changes the costume in a cycle like this:
this was changing the costume to “slime walk” just before the “Movement Block” could detect the costume was “slime idle” to start the movement script. So i wanted the Movement Block to detect the “slime idle” costume before the “Attack Block” start the animation, and the solution was simple:
I made it with all the if conditions, so i`m preventing any future glitch.
The HP bar still got the same problem.
The “Attack Block” and “Movement Block” were both conflicting, see why:
The first block is responsible by the walking animation too, so it changes the costume in a cycle like this:
switch costume to [slime walk](The lower the monster HP, the slower the animation gets.)
wait ((3) / (item (Clone#P) of [CloneHP] :: list)) secs
switch costume to [slime idle]
wait ((3) / (item (Clone#P) of [CloneHP] :: list)) secs
this was changing the costume to “slime walk” just before the “Movement Block” could detect the costume was “slime idle” to start the movement script. So i wanted the Movement Block to detect the “slime idle” costume before the “Attack Block” start the animation, and the solution was simple:
wait ((3) / (item (Clone#P) of [CloneHP] :: list)) secs
switch costume to [slime walk]
wait ((3) / (item (Clone#P) of [CloneHP] :: list)) secs
switch costume to [slime idle]
I made it with all the if conditions, so i`m preventing any future glitch.
The HP bar still got the same problem.
- -Strife-
-
Scratcher
100+ posts
Clone Coding Problem [SOLVED]
I have an other question, how delete all clones of a sprite at same time, without variables ?You simply do something like
when [ v] key pressed
delete this clone
- Bjuice
-
Scratcher
21 posts
Clone Coding Problem [SOLVED]
So I solved the main problem, finally!
Actually I don`t know how to explain what i did exactly, but this seems to work. (?)
Thank for dedicating time to it crisostimo.
Actually I don`t know how to explain what i did exactly, but this seems to work. (?)
Thank for dedicating time to it crisostimo.
- Discussion Forums
- » Help with Scripts
-
» Clone Coding Problem [SOLVED]
