#How do I set a certain character in a string?

1 messages · Page 1 of 1 (latest)

winter sphinx
#

I’m generating a random integer, then trying to grab the character at that random integer in the string. However, this doesn’t work. I used subscripts and those did not work because you can’t “set” those, only “extract”.

pure anvil
#

split your string at "" and set the nth element to whatever then join your list with ""

winter sphinx
#

n being the number?

#

ah

winter sphinx
pure anvil
#

yes

#

breaks your string into each induvidual character

winter sphinx
cedar comet
#

{_steal::%{_goal}%}

winter sphinx
#

what no

#

I need to get the #th element of something

#

%{_goal}% doesn't exist in {_steal::*}

cedar comet
#

Wait why is it in your line then

cedar comet
winter sphinx
#

like?

cedar comet
pure anvil
pure anvil
cedar comet
#

Wait the syntax is n th not nth?

winter sphinx
#

it doesn't change anything

#

the syntax is the same

pure anvil
#

i thought it was

winter sphinx
#

and using a normal number (like 1) doesn't work

pure anvil
#

thats weird

pure anvil
cedar comet
#

I assume you set {_steal::*} to yourString split by “”?

winter sphinx
#
        set {_goal} th element of {_steal::*} to "&a&l█"```
#

ignore the indentation

cedar comet
#

That should give you {_steal::1}, …, {_steal::n}

winter sphinx
#

ahhh!!!

#

i get it

#

index is used in variables

#

using split

#

how does the join syntax work?
set {_steal} to {_steal::*} join at ""

#

i don't understand it