Jump to content

Would it be possible to give names to creatures other then pigmen?


Recommended Posts

would anyone know how to add names? because I added 

STRINGS.MOSSLINGNAMES =
{
    "Lil' Dude",
}

in the strings.lua and I also added 

#. STRINGS.MOSSLINGNAMES.1
msgctxt "STRINGS.MOSSLINGNAMES.1"
msgid "Lil' Dude"
msgstr ""

in strings.pot but nothing happens :(... I hope somebody can tell me what i'm doing wrong...

Link to comment
Share on other sites

Adding new strings into STRINGS table does nothing until they are used somewhere.

Pigman prefab does (apart some tag optimization):

inst:AddComponent("named")
inst.components.named.possiblenames = STRINGS.PIGNAMES
inst.components.named:PickNewName()

Thus, try

inst:AddComponent("named")
inst.components.named.possiblenames = STRINGS.MOSSLINGNAMES
inst.components.named:PickNewName()

 

Link to comment
Share on other sites

I have this code in my mossling.lua prefab

local function fn()
local inst = CreateEntity()
inst:AddTag("_named")
if not TheWorld.ismastersim then
return inst
end

inst:RemoveTag("_named")
inst:AddComponent("named")
inst.components.named:PickNewName()
inst.components.named.possiblenames = STRINGS.MOSSLINGNAMES

And still nothing happens. no crash, no nothing :(! Also, I copy and pasted strings.lua & strings.pot and put edited versions in my mod folder. Maybe i'm not supposed to that or I put them in wrong place? I put my strings.lua where my mod main is and I made an "language" folder to put my strings.pot in just like actual Don't Starve Together folder... Really hope this is fixable & thanks for helping :D!

Link to comment
Share on other sites

2 minutes ago, SuperDavid said:

I have this code in my mossling.lua prefab


local function fn()
local inst = CreateEntity()
inst:AddTag("_named")
if not TheWorld.ismastersim then
return inst
end

inst:RemoveTag("_named")
inst:AddComponent("named")
inst.components.named:PickNewName()
inst.components.named.possiblenames = STRINGS.MOSSLINGNAMES

And still nothing happens. no crash, no nothing :(! Also, I copy and pasted strings.lua & strings.pot and put edited versions in my mod folder. Maybe i'm not supposed to that or I put them in wrong place? I put my strings.lua where my mod main is and I made an "language" folder to put my strings.pot in just like actual Don't Starve Together folder... Really hope this is fixable & thanks for helping :D!

try putting possiblenames above PickNewName

Link to comment
Share on other sites

I changed inst.components.named.possiblenames = STRINGS.MOSSLINGNAMES into inst.components.named.possiblenames = STRINGS.PIGNAMES and it immediately works with the pignames but not my custom STRINGS.MOSSLINGNAMES  names, maybe it's because I have only 1 name I need over 100 like the pigmen?! Dang, i'm so confused :?... 

Link to comment
Share on other sites

Named:PickNewName() should handle only one name in the table just fine.

Try entering into the debug console: print(tostring(STRINGS.MOSSLINGNAMES));dumptable(STRINGS.MOSSLINGNAMES);
Does it print your names table? If it prints nil, then the table was not assigned properly. If it's set directly from modmain, GLOBAL.STRINGS.MOSSLINGNAMES may be needed.

Link to comment
Share on other sites

When I did  print(tostring(STRINGS.MOSSLINGNAMES));dumptable(STRINGS.MOSSLINGNAMES); in game debug console nothing was printed back not even nil & I just added  GLOBAL.STRINGS.MOSSLINGNAMES  into my modmain and it crashes the game.

Link to comment
Share on other sites

Files /strings.lua and /languages/strings.pot are ignored, they are not loaded at all. Only files in scripts folder can override game's lua files (and even then it should be used sparingly, to avoid incompatibilities with future versions of the game and other mods).

Put into modmain (anywhere after local STRINGS = GLOBAL.STRINGS, but not inside of GLOBAL.TheNet:GetIsMasterSimulation() check):

STRINGS.MOSSLINGNAMES =
{
    "Fried Chicken",
    "Lil' Dude",
	-- ...
}

 

Edited by Muche
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...