Discuss Scratch

JoshsAccount
Scratcher
100+ posts

Split to list block

yes i am aware i just started another thread but this just came to me and it's so good
another port from snap!'s blocks
ok here it is:
split [Hello, world!] by [,] to [My list v] :: list
IndexErrorException
Scratcher
500+ posts

Split to list block

Wonderful suggestion, could have used this in many of my technical projects. Scratch does need more string manipulation and it's annoying to self implement. SUPPORT
TurtleLegos
Scratcher
1000+ posts

Split to list block

Use?
IndexErrorException
Scratcher
500+ posts

Split to list block

Turtle it's more of a technical block but imagine this.

If I have this string: “Hello, Hi, What's your name?”, notice how there is commas between each text? This block basically splits this main string into smaller ones. So it would turn into a list like this:

1: Hello
2: Hi
3: What's your name?

This could be useful for input, and encoding and decoding of save strings for games.
Yellowsheep43
Scratcher
1000+ posts

Split to list block

I would say there was a workaround if the Other suggestion was already implemented.
TurtleLegos
Scratcher
1000+ posts

Split to list block

XxhackerlolxX wrote:

Turtle it's more of a technical block but imagine this.

If I have this string: “Hello, Hi, What's your name?”, notice how there is commas between each text? This block basically splits this main string into smaller ones. So it would turn into a list like this:

1: Hello
2: Hi
3: What's your name?

This could be useful for input, and encoding and decoding of save strings for games.
No support, you can just add it to the list.
IndexErrorException
Scratcher
500+ posts

Split to list block

OMG, what if it's user input? What about save codes for games? There may be workarounds but those are slow and annoying to make.
JoshsAccount
Scratcher
100+ posts

Split to list block

was thinking it could be useful for substitution, e.g.
(My Variable :: grey) (hello user, welcome to the project!) :: grey ring

// start with this variable and use the block:

split (My Variable) by [user] to [My List v] :: list

// to result in:

(My List :: grey) (hello :: list) (user :: list) (, welcome to the project!:: list) :: ring grey

// and use:

set [# v] to [0]
repeat until <(item (#) of [My List v]) = [user]
change [# v] by (1)
end
replace item (#) of [My List v] with (username)
set [My Variable v] to (My List)

// to result in:

(My Variable :: grey) (hello Username, welcome to the project!) :: grey ring

Powered by DjangoBB