aikawayumi Posted September 1, 2023 Share Posted September 1, 2023 I understand being able to let your characters have custom responses when you "examine" an item. Though is it possible to have the actual item's name show something generic like, "paper" for papyrus or "weapon" for a thulecite club? Like making them unidentified only when using that specific character? Link to comment https://forums.kleientertainment.com/forums/topic/150766-unidentified-items-only-for-a-specific-character/ Share on other sites More sharing options...
ClumsyPenny Posted September 1, 2023 Share Posted September 1, 2023 (edited) Wagstaff's tools have a mechanic kind of like that. They have vague names when viewed by most characters except for Winona, who knows their actual name. This is handled by the function displaynamefn in the tools prefab file. In your case, it sounds like you want this to apply to most items in the game. In that case, I'd hook into EntityScript:GetBasicDisplayName() and have some special behavior for your character there. Here's some example code I made (it goes in modmain): local _old_getbasicdisplayname = GLOBAL.EntityScript.GetBasicDisplayName function GLOBAL.EntityScript:GetBasicDisplayName(...) local name -- Make this run only if the player's prefab matches with your character if GLOBAL.ThePlayer and GLOBAL.ThePlayer.prefab == "yourcharacterprefab" then -- Change the prefab to match your character!! -- Check if the item matches any of our possible names name = self:HasTag("weapon") and "Weapon" or self.prefab == "papyrus" and "Paper" -- Add new lines as needed here or nil end -- If a possible name was found, return that one if name ~= nil then return name end -- If all else fails, use the old behavior for displaying names return _old_getbasicdisplayname(self, ...) end Keep in mind to replace "yourcharacterprefab" with the respective character prefab name, and also remember that this runs on the client as well, so you won't have access to components and a few other things to find the item names to replace. I recommend sticking to tags (HasTag) and prefab names (.prefab), just like in my example. Edited September 1, 2023 by ariadnesGambit Link to comment https://forums.kleientertainment.com/forums/topic/150766-unidentified-items-only-for-a-specific-character/#findComment-1662992 Share on other sites More sharing options...
aikawayumi Posted September 1, 2023 Author Share Posted September 1, 2023 1 hour ago, ariadnesGambit said: -- Check if the item matches any of our possible names name = self:HasTag("weapon") and "Weapon" or self.prefab == "papyrus" and "Paper" -- Add new lines as needed here or nil This part kinda feels weird to me. not sure if it is lua's syntax or DST's. i normally read this as "setting the variable "name" to spear and a string "Weapon". so, like concatenating both spear's name and the string "weapon". If ill be coding this, I might go with this algorithm: if self.prefab == "papyrus" then name = "Paper" end doing so though would then probably give me a lot of elseif's so your way is actually cleaner. I think this would be similar to Java's "case"? Anyway, yea, this works and is actually simpler than having multiple if's. Thank you. 1 Link to comment https://forums.kleientertainment.com/forums/topic/150766-unidentified-items-only-for-a-specific-character/#findComment-1663017 Share on other sites More sharing options...
ClumsyPenny Posted September 2, 2023 Share Posted September 2, 2023 4 hours ago, aikawayumi said: This part kinda feels weird to me. not sure if it is lua's syntax or DST's. It's Lua's syntax, using "and" and "or" like that is basically just like using "if" and "else". I think you should do whatever makes the most sense to you, after all the code needs to be readable to you first and foremost! 4 hours ago, aikawayumi said: Anyway, yea, this works and is actually simpler than having multiple if's. Thank you. You're welcome! Link to comment https://forums.kleientertainment.com/forums/topic/150766-unidentified-items-only-for-a-specific-character/#findComment-1663047 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now