Alright, that title is a bit of a handful, so let me explain.
The GetImage() function in inventoryitem_replica will default to the the prefabs string concatenated with ".tex". Sounds good for your usual icon.
However, when you set imagename, or ChangeImageName it instead opts for the self.classified.image netvar, and this netvar is a hash. This works just fine for vanilla items.
However for modded items this'll be a little weird, so for example, let's say I have an item with two states and it switches inventory icons, the first state works fine as it's icon is just the same as the prefab, but the second state is a differently named icon so of course we have to use ChangeImageName. So I'll probably have my RegisterInventoryItemAtlas be something like..., like you'd usually do with any other RegisterInventoryItemAtlas:
RegisterInventoryItemAtlas(GLOBAL.resolvefilepath("images/inventoryimages/exampleitem_state2.xml"), "exampleitem_state2.tex")
However, since we set a image name, the game will pass a hash to GetInventoryItemAtlas when calling GetAtlas(). That means, if we actually wanted the game to set exampleitem_state2 properly, we'd instead need to return the hash for the "imagename", since GetInventoryItemAtlas won't be getting the actual name of the icon as a string.
RegisterInventoryItemAtlas(GLOBAL.resolvefilepath("images/inventoryimages/exampleitem_state2.xml"), hash("exampleitem_state2.tex"))
This is kind of a little unfriendly for modders and makes it a bit hard to figure out, a friend of mine had an issue with their inventory item that changes icons and I had found this little clink in how the inventory icon system works. Perhaps when using RegisterInventoryItemAtlas the game should automatically put a hash of the imagename into inventoryItemAtlasLookup, instead of modders having to realize themselves the game is passing a hash on the client for their set image name and that they instead need to use a hash for the imagename of their custom icon.
1. Call RegisterInventoryItemAtlas for your custom icon different from the name of your items prefab.
2. Call inventoryitem:ChangeImageName for your prefab to give it a icon different from the name of the prefab
3. Notice inventory icon doesn't work
There are no comments to display.
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