Discuss Scratch

deck26
Scratcher
1000+ posts

Broadcasting Trouble

-Scotch- wrote:

deck26 wrote:

Can't make sense of your trailer which doesn't do much.

However broadcasting in a forever loop as you do is something to be wary of. If the player is touching the right line it will broadcast Right repeatedly until the player is moved. That means the receivers of that broadcast keep restarting and may not reach beyond the first block or two before they start again. You probably need a ‘wait until not touching player’ in the loop.
When the player touches the line, it gets teleported to the other side of the screen, not touching any lines.

If there's anything that I can do to make this more understandable, then by all means, fire away.
The trailer doesn't include anything called player and doesn't actually run much when you press the green flag. That's why I said it doesn't make much sense. So that also means we have no way of knowing how the player responds to a Right or Left broadcast. Even if they do as you say the order in which things are run is crucial and so is whether there's a loop meaning the same broadcast is made repeatedly meaning, perhaps, that the player doesn't actually get moved before their receiver is started again.

All of which is easier to help with if we can see a working (or failing) example rather than a sample of the code but missing other bits!

-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

deck26 wrote:

-Scotch- wrote:

deck26 wrote:

Can't make sense of your trailer which doesn't do much.

However broadcasting in a forever loop as you do is something to be wary of. If the player is touching the right line it will broadcast Right repeatedly until the player is moved. That means the receivers of that broadcast keep restarting and may not reach beyond the first block or two before they start again. You probably need a ‘wait until not touching player’ in the loop.
When the player touches the line, it gets teleported to the other side of the screen, not touching any lines.

If there's anything that I can do to make this more understandable, then by all means, fire away.
The trailer doesn't include anything called player and doesn't actually run much when you press the green flag. That's why I said it doesn't make much sense. So that also means we have no way of knowing how the player responds to a Right or Left broadcast. Even if they do as you say the order in which things are run is crucial and so is whether there's a loop meaning the same broadcast is made repeatedly meaning, perhaps, that the player doesn't actually get moved before their receiver is started again.

All of which is easier to help with if we can see a working (or failing) example rather than a sample of the code but missing other bits!

Alrighty, I'll release the project, but please tell me if you've finished looking at it so I can unshare it. Not that I have a big cult following that will see it immediately anyway, but still. A surprise is a surprise.
-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

-Scotch- wrote:

deck26 wrote:

-Scotch- wrote:

deck26 wrote:

Can't make sense of your trailer which doesn't do much.

However broadcasting in a forever loop as you do is something to be wary of. If the player is touching the right line it will broadcast Right repeatedly until the player is moved. That means the receivers of that broadcast keep restarting and may not reach beyond the first block or two before they start again. You probably need a ‘wait until not touching player’ in the loop.
When the player touches the line, it gets teleported to the other side of the screen, not touching any lines.

If there's anything that I can do to make this more understandable, then by all means, fire away.
The trailer doesn't include anything called player and doesn't actually run much when you press the green flag. That's why I said it doesn't make much sense. So that also means we have no way of knowing how the player responds to a Right or Left broadcast. Even if they do as you say the order in which things are run is crucial and so is whether there's a loop meaning the same broadcast is made repeatedly meaning, perhaps, that the player doesn't actually get moved before their receiver is started again.

All of which is easier to help with if we can see a working (or failing) example rather than a sample of the code but missing other bits!

Alrighty, I'll release the project, but please tell me if you've finished looking at it so I can unshare it. Not that I have a big cult following that will see it immediately anyway, but still. A surprise is a surprise.
Here it is! :D
-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

Bump ^_^
asivi
Scratcher
1000+ posts

Broadcasting Trouble

Hi, put a wait until not touching player in your right and left lines, in hunt you can remove the forever loops and the stop blocks.
asivi
Scratcher
1000+ posts

Broadcasting Trouble

However i don't understand why you aren't broadcasting “hnunting” directly from lines.
-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

asivi wrote:

However i don't understand why you aren't broadcasting “hnunting” directly from lines.
I had no other place to put them, they weren't working anywhere.
-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

asivi wrote:

Hi, put a wait until not touching player in your right and left lines, in hunt you can remove the forever loops and the stop blocks.
Awesome, I'll try that! I'll get back to you on that.
-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

-Scotch- wrote:

asivi wrote:

Hi, put a wait until not touching player in your right and left lines, in hunt you can remove the forever loops and the stop blocks.
Awesome, I'll try that! I'll get back to you on that.
It didn't work, you have to have a forever loop on it.
awesome332
Scratcher
6 posts

Broadcasting Trouble

thanks!!! i did it and it really worked!
-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

awesome332 wrote:

thanks!!! i did it and it really worked!
Wait, what? I think you might be on the wrong forum…
deck26
Scratcher
1000+ posts

Broadcasting Trouble

I really think you should create a new project with a simpler version of the movement and line detection. Avoid over-complicating your code - you seem to have a habit of sticking a forever loop around things if unsure of what to do. For example you currently have in the RightLine sprite in https://scratch.mit.edu/projects/122698947/

forever

repeat until <not <touching [Player v]>>
if <touching [Player v]> then
broadcast [Right v]
end
end

end
Either the repeat until or the if block is redundant if you think it through and in either case the broadcast is going to happen repeatedly until the Player moves away from touching the line. That can mean the first few blocks of a receiver script get run time and time again. More likely what you need is something like


forever
wait until <touching [Player v]>
broadcast [Right v] // or perhaps a broadcast and wait
wait until <not <touching [Player v]>>

end
which is simpler and gives more control.
-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

deck26 wrote:

I really think you should create a new project with a simpler version of the movement and line detection. Avoid over-complicating your code - you seem to have a habit of sticking a forever loop around things if unsure of what to do. For example you currently have in the RightLine sprite in https://scratch.mit.edu/projects/122698947/

forever

repeat until <not <touching [Player v]>>
if <touching [Player v]> then
broadcast [Right v]
end
end

end
Either the repeat until or the if block is redundant if you think it through and in either case the broadcast is going to happen repeatedly until the Player moves away from touching the line. That can mean the first few blocks of a receiver script get run time and time again. More likely what you need is something like


forever
wait until <touching [Player v]>
broadcast [Right v] // or perhaps a broadcast and wait
wait until <not <touching [Player v]>>

end
which is simpler and gives more control.
The first example is something I was doing to do because someone said that it would work, which I confirmed that it doesn't.

On the other hand, I don't think I'd be able to create an entirely new project - first off, that'd take forever, and second, there's only a few things that don't work. If things run properly, then there's no need to change them. If I have problems, I'll just try to figure it out on my own. And if I can't, I'll take to these forums and have others help figuring it out.

Thank you for your help, I'll try this code. It makes sense, seeing it now. However, my problem was never getting the line scripts to change backgrounds, I couldn't get the Hunting broadcast to work. Everything else with the line script is fine, and works as it should be.

Last edited by -Scotch- (Dec. 19, 2016 22:40:45)

-Scotch-
Scratcher
100+ posts

Broadcasting Trouble

I just used your (Deck26) code, and it made the lines and backdrops move more efficiently.


But that's not what I'm happy about! I considered (I forget who said it) what someone had said, about my computer doing some scripts before others. So, I made a 0.5 delay on when the Hunting sprite broadcasts hunting. Then, I went into the game, and it worked!

Thankyou to all who helped on this project!
deck26
Scratcher
1000+ posts

Broadcasting Trouble

-Scotch- wrote:

deck26 wrote:

I really think you should create a new project with a simpler version of the movement and line detection. Avoid over-complicating your code - you seem to have a habit of sticking a forever loop around things if unsure of what to do. For example you currently have in the RightLine sprite in https://scratch.mit.edu/projects/122698947/

forever

repeat until <not <touching [Player v]>>
if <touching [Player v]> then
broadcast [Right v]
end
end

end
Either the repeat until or the if block is redundant if you think it through and in either case the broadcast is going to happen repeatedly until the Player moves away from touching the line. That can mean the first few blocks of a receiver script get run time and time again. More likely what you need is something like


forever
wait until <touching [Player v]>
broadcast [Right v] // or perhaps a broadcast and wait
wait until <not <touching [Player v]>>

end
which is simpler and gives more control.
The first example is something I was doing to do because someone said that it would work, which I confirmed that it doesn't.

On the other hand, I don't think I'd be able to create an entirely new project - first off, that'd take forever, and second, there's only a few things that don't work. If things run properly, then there's no need to change them. If I have problems, I'll just try to figure it out on my own. And if I can't, I'll take to these forums and have others help figuring it out.

Thank you for your help, I'll try this code. It makes sense, seeing it now.
Making a new project can be done very quickly by copying what you have and deleting all the bits that have nothing to do with the movement and line detection. Your aim is to strip out as much as possible so you can concentrate on the actual problem without distraction. Debugging takes effort!

Powered by DjangoBB