# Variables with the same name but different types

**URL:** <https://forum.choiceofgames.com/t/variables-with-the-same-name-but-different-types/108870>\
**Category:** ChoiceScript Help\
**Created:** [October 23, 2021, 1:20am UTC](https://forum.choiceofgames.com/t/variables-with-the-same-name-but-different-types/108870 "2021-10-23T01:20:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArchivistAlpha096](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/archivistalpha096/32/203655_2.png) [@ArchivistAlpha096](https://forum.choiceofgames.com/u/ArchivistAlpha096)\
**Post date:** [October 23, 2021, 1:20am UTC](https://forum.choiceofgames.com/t/variables-with-the-same-name-but-different-types/108870/1 "2021-10-23T01:20:20Z")

</div>

So, I am a little unclear on something.  
To make some things, such as calling orientation or height or what not with fairly long, at least for variables, titles, I have, for example.

```
*set mc_height "very tall"
*set mc_height0

```

Will that work, or do I have put a different variable, because they are both MC\_height? Also, I think I ran into something like this where I did that and because it changed the variable from a “” to a number, when I typed in the \*if (quoted variable name), it didn’t trigger because it wasn’t that variable anymore.

---

<div class="post-metadata">

**Author:** ![Gower](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/gower/32/21972_2.png) [@Gower](https://forum.choiceofgames.com/u/Gower)\
**Post date:** [October 23, 2021, 2:45am UTC](https://forum.choiceofgames.com/t/variables-with-the-same-name-but-different-types/108870/2 "2021-10-23T02:45:51Z")

</div>

Fairly certain you have to designate each individual variable as a string, boolean, or number. You cannot make the same variable exist in different types.

You’d have to do something like  
`*create height_describe ""`

And then

```choicescript
*if mc_height > 1000
   *set height_describe "very tall"

```

and so forth.

> [@ArchivistAlpha096](#):
>
> Also, I think I ran into something like this where I did that and because it changed the variable from a “” to a number, when I typed in the \*if (quoted variable name), it didn’t trigger because it wasn’t that variable anymore.

I’m not 100% sure what this means, but possibly has to do with the fact that a numeral can exist both as a number variable and as a string. In other words, you can store 6 as a numeral and “6” as a string. But I’m not quite sure if that was what you are referring to.

---

<div class="post-metadata">

**Author:** ![ArchivistAlpha096](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/archivistalpha096/32/203655_2.png) [@ArchivistAlpha096](https://forum.choiceofgames.com/u/ArchivistAlpha096)\
**Post date:** [October 23, 2021, 3:44am UTC](https://forum.choiceofgames.com/t/variables-with-the-same-name-but-different-types/108870/3 "2021-10-23T03:44:38Z")

</div>

Thanks, I thought it was something like that. I think what happened with my example was that it was a string, and then I accidentally sent it to a number, so then the string no longer existed and the game had nothing to trigger since it was set up with the assumption that the strings still existed.

---

<div class="post-metadata">

**Author:** ![TimberWoolf](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/timberwoolf/32/69602_2.png) [@TimberWoolf](https://forum.choiceofgames.com/u/TimberWoolf)\
**Post date:** [October 26, 2021, 3:49pm UTC](https://forum.choiceofgames.com/t/variables-with-the-same-name-but-different-types/108870/4 "2021-10-26T15:49:09Z")

</div>

Arrays might also be useful in this case. It allows you to do things like this, which seems to be what you’re trying.

```
*set mc_height "very tall"
*set mc_measure 6
*set feature "measure"
Your character is ${mc["height"]}, standing at ${mc[feature]} feet.
// Your character is very tall, standing at 6 feet.

```

It would probably help in some measure to keep variables separated, especially when they refer to the same thing?

Check out:

> **[Arrays](https://choicescriptdev.fandom.com/wiki/Arrays)**
>
> Choicescript supports an array syntax to access a specific entry out of a sequence of related data points. If you use square brackets \[\] after a variable name, the value of a second variable will be concatenated using underscore. See this example....
