Mentos Posted October 7, 2022 Share Posted October 7, 2022 So i've been trying to make bundles that work identically to gift bundles and while i got everything to work i can't figure out how to handle the inventory images. (my inventory is full of bundles in this pic) Anyway the bundle code is mostly copy pasted from the base game and klei seems to handle inventory images differently. Code in question (the part that handles inv images) local function MakeBundle(name, onesize, variations, loot, tossloot, setupdata, bank, build, inventoryimage) local assets = { Asset("ANIM", "anim/whiskybundle.zip"), Asset("ATLAS", "images/inventoryimages/whiskybundle_small.xml"), Asset("IMAGE", "images/inventoryimages/whiskybundle_small.tex"), Asset("ATLAS", "images/inventoryimages/whiskybundle_small1.xml"), Asset("IMAGE", "images/inventoryimages/whiskybundle_small1.tex"), Asset("ATLAS", "images/inventoryimages/whiskybundle_medium.xml"), Asset("IMAGE", "images/inventoryimages/whiskybundle_medium.tex"), Asset("ATLAS", "images/inventoryimages/whiskybundle_medium1.xml"), Asset("IMAGE", "images/inventoryimages/whiskybundle_medium1.tex"), Asset("ATLAS", "images/inventoryimages/whiskybundle_large.xml"), Asset("IMAGE", "images/inventoryimages/whiskybundle_large.tex"), Asset("ATLAS", "images/inventoryimages/whiskybundle_large1.xml"), Asset("IMAGE", "images/inventoryimages/whiskybundle_large1.tex") } local prefabs = { "ash", "whiskybundle_unwrap", } if variations ~= nil then for i = 1, variations do if onesize then table.insert(assets, Asset("INV_IMAGE", (inventoryimage or name)..tostring(i))) else table.insert(assets, Asset("INV_IMAGE", (inventoryimage or name).."_small"..tostring(i))) table.insert(assets, Asset("INV_IMAGE", (inventoryimage or name).."_medium"..tostring(i))) table.insert(assets, Asset("INV_IMAGE", (inventoryimage or name).."_large"..tostring(i))) end end elseif not onesize then table.insert(assets, Asset("INV_IMAGE", (inventoryimage or name).."_small")) table.insert(assets, Asset("INV_IMAGE", (inventoryimage or name).."_medium")) table.insert(assets, Asset("INV_IMAGE", (inventoryimage or name).."_large")) end local prefabs = { "ash", name.."_unwrap", } if loot ~= nil then for i, v in ipairs(loot) do table.insert(prefabs, v) end end local function UpdateInventoryImage(inst) local suffix = inst.suffix or "_small" if variations ~= nil then if inst.variation == nil then inst.variation = math.random(variations) end suffix = suffix..tostring(inst.variation) local skin_name = inst:GetSkinName() if skin_name ~= nil then inst.components.inventoryitem:ChangeImageName(skin_name..(onesize and tostring(inst.variation) or suffix)) else inst.components.inventoryitem:ChangeImageName(name..(onesize and tostring(inst.variation) or suffix)) end elseif not onesize then local skin_name = inst:GetSkinName() if skin_name ~= nil then inst.components.inventoryitem:ChangeImageName(skin_name..suffix) else inst.components.inventoryitem:ChangeImageName(name..suffix) end end end local function OnWrapped(inst, num, doer) local suffix = (onesize and "_onesize") or (num > 3 and "_large") or (num > 1 and "_medium") or "_small" inst.suffix = suffix UpdateInventoryImage(inst) if inst.variation then suffix = suffix.."1" end inst.AnimState:PlayAnimation("idle"..suffix) if doer ~= nil and doer.SoundEmitter ~= nil then doer.SoundEmitter:PlaySound(inst.skin_wrap_sound or "dontstarve/common/together/packaged") end end I've looked at other similar items, i've butchered this code in like 3 different ways and i haven't made any progress on this for a week now so if anyone knows what's up please help. Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/ Share on other sites More sharing options...
Rickzzs Posted October 9, 2022 Share Posted October 9, 2022 Did you forget to load assets either in modmain.lua or in prefab file? Did you forget to call RegisterInventoryItemAtlas? RegisterInventoryItemAtlas("images/" .. xmlfile .. ".xml", image .. ".tex") RegisterInventoryItemAtlas("images/" .. xmlfile .. ".xml", hash(image .. ".tex")) Did you forget to specify the inventoryitem.atlasname and inventoryitem.imagename? inst.components.inventoryitem.atlasname = "images/"..atlasname..".xml" -- "images/bundle.xml" inst.components.inventoryitem.imagename = imagename --"bundle" Â 1 Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/#findComment-1601915 Share on other sites More sharing options...
Mentos Posted October 9, 2022 Author Share Posted October 9, 2022 4 hours ago, Rickzzs said: Did you forget to load assets either in modmain.lua or in prefab file? Did you forget to call RegisterInventoryItemAtlas? RegisterInventoryItemAtlas("images/" .. xmlfile .. ".xml", image .. ".tex") RegisterInventoryItemAtlas("images/" .. xmlfile .. ".xml", hash(image .. ".tex")) Did you forget to specify the inventoryitem.atlasname and inventoryitem.imagename? inst.components.inventoryitem.atlasname = "images/"..atlasname..".xml" -- "images/bundle.xml" inst.components.inventoryitem.imagename = imagename --"bundle" Â Nope, i have all assets loaded in modmain. Specifying the inventory image didn't work either cause the UpdateInventoryImage function would replace them with assets it couldn't find. If u remember gift bundles change their inventory image and sprites depending on how much stuff is in them. I didn't find a solution and the bundle code is too confusing to me so yea i just gave up, got rid of UpdateInventoryImage and added a static inventory image. still thank u tho Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/#findComment-1601961 Share on other sites More sharing options...
Rickzzs Posted October 10, 2022 Share Posted October 10, 2022 12 hours ago, Mentos said: snip So the problem is that the inventory cannot find your image file. You may want to look at client_log or trace from inventory.lua to see where things goes unintended. One more suggestion is that you can pack all inventory images into one xml because that is the convention. Things may go wrong if you have multiple xml for a single prefab because it is not design to be. 1 Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/#findComment-1602115 Share on other sites More sharing options...
Mentos Posted October 10, 2022 Author Share Posted October 10, 2022 7 hours ago, Rickzzs said: So the problem is that the inventory cannot find your image file. You may want to look at client_log or trace from inventory.lua to see where things goes unintended. One more suggestion is that you can pack all inventory images into one xml because that is the convention. Things may go wrong if you have multiple xml for a single prefab because it is not design to be. ohh good idea thank you, i'll try again and see if i can get it to work Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/#findComment-1602150 Share on other sites More sharing options...
Mentos Posted October 11, 2022 Author Share Posted October 11, 2022 On 10/10/2022 at 4:18 AM, Rickzzs said: One more suggestion is that you can pack all inventory images into one xml because that is the convention. Things may go wrong if you have multiple xml for a single prefab because it is not design to be. I tried doing this but the download link for the atlas packer on the forums is dead. Would u happen to have a copy? Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/#findComment-1602357 Share on other sites More sharing options...
Rickzzs Posted October 11, 2022 Share Posted October 11, 2022 6 hours ago, Mentos said: I tried doing this but the download link for the atlas packer on the forums is dead. Would u happen to have a copy? I posted a tool collection in the tutorial and guide forum. You can find what you need there. 1 Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/#findComment-1602440 Share on other sites More sharing options...
Mentos Posted October 12, 2022 Author Share Posted October 12, 2022 8 hours ago, Rickzzs said: I posted a tool collection in the tutorial and guide forum. You can find what you need there. finally got them to work ty so much ur a legend Link to comment https://forums.kleientertainment.com/forums/topic/143636-need-some-help-with-gift-type-bundle-inv-images/#findComment-1602508 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