Jump to content

How to check which character is being played?

Recommended Posts

I'm working on a character mod, and I'm trying to make her able to use a specific item in a way that none of the other characters can. I have all the code written out and right there, but I need to find the boolean value to go into the if statement I'm going to surround it with. This is my first mod, and I'm not very familiar with the way Don't Starve's code is laid out, so I don't know how to actually check it.


Usually, something like this would be named GetWorld().Player.identy() == myCharacter.identity(), or maybe Player.isInstanceOf(myCharacter). I just don't know what it would be in Don't Starve and I've been looking all afternoon and can't figure it out. Any help?

Link to comment
Share on other sites


I should probably elaborate a tiny bit:

if GetPlayer().prefab == <myprefabname> then



If you need to do this check a lot, near the top of your modmain add local is_<myprefabname> and use that in your checks.

Link to comment
Share on other sites


Thanks. This fixed it, and now it works! On the to the feature.


There's also a component called "playerspecific", it removes the item if the player isn't the one specified.

I'm aware of playerspecific, and it's not what I was looking for. The item I want to add the functionality to needs to be available to everyone. The item is an important component of many crafting recipes and naturally appears throughout the world, so it would be very bad to make it playerspecific.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...