Is it possible to read a string as a numeral and/or vice versa?

I’m having trouble with trying to read a string as a numeral. For instance, I have variable x and y as the grid coordinate.

I am using x and y as strings so that I can use it as a reference.

e.g:
*temp x “1”
*temp y “1”

so that something like this works:

*goto (x)-(y)
*images (x)-(y).png

However, I also want to be able to change the value through arithmetic operators so that I can do something like this:

For example:

*set x 0
*set y 0

*label 0-0

You are north!

*choice
  #go south
    ***set y + 1**
    *goto ${x}-${y}

*label 0-1
*images $(x)-$(y).png

You are south!

*choice
  #go north
    ***set y - 1**
    *goto ${x}-${y}
  #go south
    ***set y + 1**
    *goto ${x}-${y}
  #go east
    ***set x + 1**
    *goto ${x}-${y}

etc

Obviously, the bolded part will simply not work since variable x and y are string data types.

I have tried making them numeric data types instead, but then, they cannot work as references.

Is there anyway to read a string as a numeral or a numeral as a string?

1 Like

*goto will look for a label, so this won’t work.

My first question would be what you want this for.

*goto and *label don’t accept variables as their reference. However, you can always create *labels as much as x*y (and consequentially, x*y amount of images).

Thanks everyone for the help everyone.

You’re right that goto doesn’t work, so I just changed things around so I dont need to rely on goto for navigation. I still needed a way for numerals to be read as strings though, so I can make use of image/[string].jpg etc.

But I resolved this by creating a string and a numeral variable for both x and y, then created a subroutine for synchronising them so they had the same value. That way, i can use the numeral version for arithmetic and use the subroutine to update the string version. Thanks again everyone