Discuss Scratch

Foregrounded
Scratcher
2 posts

How would i remove the first letter of a variable

I am working on a level editor decoder but i need to remove the first letter of a variable so i can move on to the next object
can anyone help?
crumbthehog
Scratcher
92 posts

How would i remove the first letter of a variable

Foregrounded wrote:

I am working on a level editor decoder but i need to remove the first letter of a variable so i can move on to the next object
can anyone help?
try this:
set [pre set] to []
set [index] to [2]
repeat (length of (variable))
set [pre set] to (join (pre set) (letter (index) of (variable))
change [index] by (1)

end
set [variable] to (pre set)

Last edited by crumbthehog (Oct. 18, 2022 17:27:47)

DeveloperTools
Scratcher
100+ posts

How would i remove the first letter of a variable

Foregrounded wrote:

I am working on a level editor decoder but i need to remove the first letter of a variable so i can move on to the next object
can anyone help?
Why do you need to remove the first letter in order to go to the next object?
To remove the first letter, do this:

// PUT THIS BEFORE YOU DELETE ANYTHING!! \\

set [i v] to [1]
repeat (length of [list v] :: list)
add (letter (i) of (VARIABLE)) to [list v]
change [i v] by [1]
end

When i need to delete a letter ::hat grey
delete [1] of [list v]
set [VARIABLE v] to (list ::list)

Last edited by DeveloperTools (Oct. 18, 2022 17:36:58)

Oumuamua
Scratcher
1000+ posts

How would i remove the first letter of a variable

a bit different aproach https://scratch.mit.edu/projects/398795014/editor/



You can set variable to output at the end

Greets

Last edited by Oumuamua (Oct. 18, 2022 20:43:36)

Foregrounded
Scratcher
2 posts

How would i remove the first letter of a variable

mod ples close this
DifferentDance8
Scratcher
1000+ posts

How would i remove the first letter of a variable

Foregrounded wrote:

mod ples close this
Well, considering that you made this post on Yesterday 08:40:04, and now it's Today 04:45 PM, you can just press “Close Topic” to close this topic.

Powered by DjangoBB