Question with strings

I have something to do with strings I need help with.
If I do a save code like 138_285, is it possible to extract the two numbers from the save input to get the values of them, split up and without the underscore?
It’s kinda confusing, sorry?

14 Likes

No first post pls.
It’s ok if you don’t understand, just put in poll so I will make edits to the thing

  • Confusing
  • It’s fine

0 voters

5 Likes

Ok, here is a simpler explanation.( I think) I want to know if I can have a save code 136_936, and still be able to get the two numbers, without the underscore. Is there a way to get rid of the underscore, and still be able to separately get the values of the two numbers, with them separable instead of a single string.
Wow that’s still confusing. Oh well.

4 Likes

A bit difficult but You can do it
I am too lazy for an explanation tho

1 Like

yes

do var x = characters in (said variable that stores that) at index (0) to (3)
then var y = characters in (said variable that stores that) at index (4) to (saidVariableThatStoresThat(length))

that should work

4 Likes

Wait, for the second one it starts @ 5 cuz no underscore, no?

1 Like

so hang on
you wanna get 136 and 196, in a save code which I’m guessing is the string variables block, without the underscore, and keep them in the same string block?

3 Likes

Maybe add this code?

set num to (138_285)
set num_ans to ((characters in (num) at index (0) to ((((num) length) - (3))
set num_ans2 to ((characters in (num) at index (4) to (((num) length))

I maybe wrong

2 Likes

do 4 here

and 3 here

2 Likes

no, it starts at 4

remember the last number isn’t actually included in the string

2 Likes

Woooooops :/
knew it, i was wrong!

3 Likes

wait if you’re doing number length - (x) then 4 is correct

3 Likes

Really man?
I cant edit it again!

3 Likes

If you have the same amount of digits every time, you can use get characters in range with some leading characters and whatnot.

_002_123_124

get range (1,4), etc.

1 Like

Repeat times (length of string)
{
Check if else (character in string at index checkIndex) matches _ AND chk = 0
{
Set chk to 1
Set power.index to 0
Repeat times (length of string - (checkIndex + 1))
{
Set number to character in string at (checkIndex+power.index+1)
Set main second number to ((main second number times (10 to the power of power.index))+number)
Increase power.index by 1
}
}
Else
{
check if chk = 1
{
Set number to character in string at index checkIndex
Set main first number to ((main first number times (10 to the power of power.index))+number)
Increase checkIndex by 1
}
}
}

checkIndex, power.index, main first (second) number, and number are all game variables, starting at 0…

1 Like

@noobcoder2000 ^

1 Like

:confused: well I used the two numbers as an explanation, it is actually going to be different, because it’s going to represent variables like money.

1 Like

I think my brain hurts. Could you please show a picture instead? :face_with_head_bandage:

1 Like

I’ll see what I can do…

2 Likes


This is the example I used to separate numbers from a fraction string.

The numerator would be the first number, and the denominator would be the second number. The last block is not necessary.

Shows the rest of the code in some blocks

2 Likes