How do you return Start Location using LUA

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!

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

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.

start_location field of player class returns variable of start_location_id type).

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

start_location_id is basically string_id:

    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).

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

1 Like

Thank you! This is immensely helpful for me.