# How do you return Start Location using LUA

**URL:** <https://discourse.cataclysmdda.org/t/how-do-you-return-start-location-using-lua/18478>\
**Category:** The Toolbox\
**Created:** [January 21, 2019, 6:26pm UTC](https://discourse.cataclysmdda.org/t/how-do-you-return-start-location-using-lua/18478 "2019-01-21T18:26:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sneeze-attack](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/sneeze-attack/32/4220_2.png) [@sneeze-attack](https://discourse.cataclysmdda.org/u/sneeze-attack)\
**Post date:** [January 21, 2019, 6:26pm UTC](https://discourse.cataclysmdda.org/t/how-do-you-return-start-location-using-lua/18478/1 "2019-01-21T18:26:16Z")

</div>

Hi, I’m new to using programming languages, so please excuse my ignorance here, but how do you return the player’s starting location in a string format using LUA?  
I’m using `dofile` in my json mapgen to load a LUA script at the end.  
Right now when I use

> local ps = player.start\_location

and then write the value of ps to a log file, I end up with

> userdata: 0x559bf5658358

I assume I am not formatting or calling the data properly to see a value in human readable format. My other thought is that there is currently no way of getting this data without adding to the LUA class definitions.  
Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [January 21, 2019, 7:55pm UTC](https://discourse.cataclysmdda.org/t/how-do-you-return-start-location-using-lua/18478/2 "2019-01-21T19:55:06Z")

</div>

Do you need to know name/id of starting scenario or name/id of overmap terrain player has started in?

---

<div class="post-metadata">

**Author:** ![sneeze-attack](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/sneeze-attack/32/4220_2.png) [@sneeze-attack](https://discourse.cataclysmdda.org/u/sneeze-attack)\
**Post date:** [January 21, 2019, 8:03pm UTC](https://discourse.cataclysmdda.org/t/how-do-you-return-start-location-using-lua/18478/3 "2019-01-21T20:03:45Z")

</div>

Thanks for the quick reply.  
The name of type `start_location` if that is possible.  
I want to set up logic based upon which start location the player has chosen.

---

<div class="post-metadata">

**Author:** ![Zhilkin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/zhilkin/32/3749_2.png) [@Zhilkin](https://discourse.cataclysmdda.org/u/Zhilkin)\
**Post date:** [January 21, 2019, 8:22pm UTC](https://discourse.cataclysmdda.org/t/how-do-you-return-start-location-using-lua/18478/4 "2019-01-21T20:22:58Z")

</div>

`start_location` field of `player` class [returns variable of `start_location_id` type](https://github.com/CleverRaven/Cataclysm-DDA/blob/0d681892fb1f77288014fe8e1405ba2e257ee733/lua/class_definitions.lua#L1756)).

```auto
start_location = { type = "start_location_id", writable = true },

```

`start_location_id` [is basically `string_id`](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/lua/class_definitions.lua#L1756):

```auto
    start_location = {
        string_id = "start_location_id",
        attributes = {
        },
        functions = {
        }
    },

```

You can use `:str()` to return string representation of `string_id` variables (similarly you can use`:to_i()` to return number representation of `int_id` variables - hints are in [class\_definitions.lua](https://github.com/CleverRaven/Cataclysm-DDA/blob/master/lua/class_definitions.lua#L1756)).

That means you have to use `player.start_location:str()`.

---

<div class="post-metadata">

**Author:** ![sneeze-attack](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/sneeze-attack/32/4220_2.png) [@sneeze-attack](https://discourse.cataclysmdda.org/u/sneeze-attack)\
**Post date:** [January 21, 2019, 8:28pm UTC](https://discourse.cataclysmdda.org/t/how-do-you-return-start-location-using-lua/18478/5 "2019-01-21T20:28:29Z")

</div>

Thank you! This is immensely helpful for me.
