How to change entity display name from lua console

I know it’s a super beginner question, but how do you change an entity’s name from the lua console?

Are you talking about a localization string? Or a hearthling/critter/NPC’s name?

I was thinking specifically of items, like furniture.
Also what do you mean by localization string?

Localization strings are all the text that is language-specific. Basically any text you see in the game is a localization string, with the exception of random names like hearthling/critter/NPC names (though maybe those are also localized, I’m not sure). If you extract your stonehearth.smod file and look in the locales/en.json file, you’ll see what I mean.

1 Like

oh thank you! I remember seeing entity display names as some weird functions in jsons, guess that explains why. But I was hoping there was a way to change the name of individual entities mid-game through lua commands.

they arent but they could be. (they are in the file used to define a kingdom in “”'s not with the 18n stuff in front
they are though more easilly replaced with mixing in the apropriate {} part.

Select the desired entity, open the lua console (requires the debug tool enabled), and type this:

radiant.entities.set_display_name(e, "Your chosen name here")

3 Likes

exactly what I’ve been looking for. Thank you very much!

1 Like

I’m curious, what do you need that command for? What situation exists where its needed XD?

I got sick of how it’s incredibly difficult it is to find who a bed’s owner is so I decided to pick up modding and make it so a bed’s name goes “(bed owner)'s comfy bed” instead of just “comfy bed”

@kaimonkey this sounds like something up your alley, I know an amberstone from the amberstone quest renames itsself on the fly on two variables(its the quest to aquire two bunnies and the place needs enough beds and pretyness, I’m assuming we could make it so beds load in their owner and use that in their name? Without manualy abusing lua code to rename it)

1 Like

You wouldn’t even need to rename it necessarily, if you only cared about the unit frame: just mod the unit frame to check if the selected bed has an owner and put it in the displayed name string.

2 Likes