Discuss Scratch

FormulaFanboyYT
Scratcher
37 posts

Help With Ask/Answers In 3.0

Hello all!

So I created this programming language in Scratch 2.0. The problem I've run into is that in Scratch 2.0, the “enter” symbol was completely ignores when being entered as an answer, which made code lines possible– however, in Scratch 3.0, it converts them to spaces. The first thing I tried was to simply remove spaces from any scripts, but this is a problem since some script types, such as NPC dialogue, must have spaces. Simply put, I need to stop Scratch 3.0 from converting the enter symbol into a space, or at least be able to detect the difference between a space and a return… be it with an unofficial extension, some code magic, or what-have-you. Somebody please tell me how to make this happen.

Last edited by FormulaFanboyYT (May 26, 2020 19:35:31)

Sheep_maker
Scratcher
1000+ posts

Help With Ask/Answers In 3.0

I think this is just a difference between how Flash and certain browsers deal with newlines when pasting into a single line input. I noticed, however, that Microsoft Edge removes newlines only in the address bar, so I guess you could paste it there and copy before pasting into your project's ask box

(I'm assuming that the enter symbol is the newline character since the other symbol ‘↵’ works for me in 3.0)

You could also remove the newlines by running some JavaScript:
`Your code
here`.replace(/\r?\n/g, '')

- Sheep_maker This is a kumquat-free signature. :P
This, my signature, appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
FormulaFanboyYT
Scratcher
37 posts

Help With Ask/Answers In 3.0

Sheep_maker wrote:

I think this is just a difference between how Flash and certain browsers deal with newlines when pasting into a single line input. I noticed, however, that Microsoft Edge removes newlines only in the address bar, so I guess you could paste it there and copy before pasting into your project's ask box

(I'm assuming that the enter symbol is the newline character since the other symbol ‘↵’ works for me in 3.0)

You could also remove the newlines by running some JavaScript:
`Your code
here`.replace(/\r?\n/g, '')

Thanks! The javascript option sounds like my best bet; how should I go about adding this to Scratch? I believe I saw a JavaScript extension at one point, would that work?

Edit: I found an extension that adds JavaScript, and I tried doing it, but it didn't work… I'm probably doing it wrong, you'll have to forgive me as I've not used JavaScript before.

Last edited by FormulaFanboyYT (May 26, 2020 19:54:33)

FormulaFanboyYT
Scratcher
37 posts

Help With Ask/Answers In 3.0

Sheep_maker wrote:

I think this is just a difference between how Flash and certain browsers deal with newlines when pasting into a single line input. I noticed, however, that Microsoft Edge removes newlines only in the address bar, so I guess you could paste it there and copy before pasting into your project's ask box

(I'm assuming that the enter symbol is the newline character since the other symbol ‘↵’ works for me in 3.0)

You could also remove the newlines by running some JavaScript:
`Your code
here`.replace(/\r?\n/g, '')

I tried doing what worked for me last time (with the clones), and opened up the HTMLifier in Notepad. I actually managed to find some code that said what's in the code box, but when replacing “\n” with “”, the issue still wasn't fixed. I tried many other things that also didn't work. Do you know where in the code I might be able to find the part that turns line breaks into spaces?

"+n.replace(/\r?\n/g,"\n")

Last edited by FormulaFanboyYT (May 26, 2020 20:50:54)

FormulaFanboyYT
Scratcher
37 posts

Help With Ask/Answers In 3.0

@Sheep_maker What you were describing with the URL box of a browser also works with my browser, Firefox… and that does in fact make the code work, however, I would like to be able to automate that process somehow within Scratch.

Last edited by FormulaFanboyYT (May 26, 2020 21:16:23)

Sheep_maker
Scratcher
1000+ posts

Help With Ask/Answers In 3.0

FormulaFanboyYT wrote:

Do you know where in the code I might be able to find the part that turns line breaks into spaces?
It's a feature built into browsers, unfortunately

If you're using the HTMLifier, you can probably replace
<input type="text" id="answer">
which is a single line input, with
<textarea id="answer"></textarea>
which'll allow newline characters. It won't remove them, but it won't replace them with spaces either, I think

- Sheep_maker This is a kumquat-free signature. :P
This, my signature, appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }

Powered by DjangoBB

Standard | Mobile