FurryEskimo Posted September 20, 2023 Share Posted September 20, 2023 Does anyone know how to scan the contents on a bundle without opening it? I'm trying to check the contents of an inventory and realized people may have items in a bundle. I also want to be able to give items, and storing them in a bundle first would make it less intrusive. I found the code for 'bundle', and I see the use of 'MakeBundle' and 'MakeWrap', which is hopefully half the battle, but don't quite understand how the data I need is being stored. local function MakeBundle(name, onesize, variations, loot, tossloot, setupdata, bank, build, inventoryimage) local assets = { Asset("ANIM", "anim/"..(inventoryimage or name)..".zip"), } 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..tostring(inst.variation) 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 local function OnUnwrapped(inst, pos, doer) if inst.burnt then SpawnPrefab("ash").Transform:SetPosition(pos:Get()) else local loottable = (setupdata ~= nil and setupdata.lootfn ~= nil) and setupdata.lootfn(inst, doer) or loot if loottable ~= nil then local moisture = inst.components.inventoryitem:GetMoisture() local iswet = inst.components.inventoryitem:IsWet() for i, v in ipairs(loottable) do local item = SpawnPrefab(v) if item ~= nil then if item.Physics ~= nil then item.Physics:Teleport(pos:Get()) else item.Transform:SetPosition(pos:Get()) end if item.components.inventoryitem ~= nil then item.components.inventoryitem:InheritMoisture(moisture, iswet) if tossloot then item.components.inventoryitem:OnDropped(true, .5) end end end end end SpawnPrefab(name.."_unwrap").Transform:SetPosition(pos:Get()) end if doer ~= nil and doer.SoundEmitter ~= nil then doer.SoundEmitter:PlaySound(inst.skin_wrap_sound or "dontstarve/common/together/packaged") end inst:Remove() end local OnSave = variations ~= nil and function(inst, data) data.variation = inst.variation end or nil local OnPreLoad = variations ~= nil and function(inst, data) if data ~= nil then inst.variation = data.variation end end or nil local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank(bank or name) inst.AnimState:SetBuild(build or name) inst.AnimState:PlayAnimation( variations ~= nil and (onesize and "idle_onesize1" or "idle_large1") or (onesize and "idle_onesize" or "idle_large") ) inst:AddTag("bundle") --unwrappable (from unwrappable component) added to pristine state for optimization inst:AddTag("unwrappable") if setupdata ~= nil and setupdata.common_postinit ~= nil then setupdata.common_postinit(inst, setupdata) end inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem:SetSinks(true) if inventoryimage then inst.components.inventoryitem:ChangeImageName(inventoryimage) end if variations ~= nil or not onesize then inst.components.inventoryitem:ChangeImageName( name.. (variations == nil and "_large" or (onesize and "1" or "_large1")) ) end inst:AddComponent("unwrappable") inst.components.unwrappable:SetOnWrappedFn(OnWrapped) inst.components.unwrappable:SetOnUnwrappedFn(OnUnwrapped) inst.UpdateInventoryImage = UpdateInventoryImage MakeSmallBurnable(inst, TUNING.SMALL_BURNTIME) MakeSmallPropagator(inst) inst.components.propagator.flashpoint = 10 + math.random() * 5 inst.components.burnable:SetOnBurntFn(onburnt) inst.components.burnable:SetOnIgniteFn(onignite) inst.components.burnable:SetOnExtinguishFn(onextinguish) MakeHauntableLaunchAndIgnite(inst) if setupdata ~= nil and setupdata.master_postinit ~= nil then setupdata.master_postinit(inst, setupdata) end inst.OnSave = OnSave inst.OnPreLoad = OnPreLoad return inst end return Prefab(name, fn, assets, prefabs) end return MakeContainer("bundle_container", "ui_bundle_2x2"), MakeContainer("construction_container", "ui_bundle_2x2"), --"bundle", "bundlewrap" MakeBundle("bundle", false, nil, { "waxpaper" }), MakeWrap("bundle", "bundle_container", nil, false), --"gift", "giftwrap" MakeBundle("gift", false, 2), MakeWrap("gift", "bundle_container", nil, true), --"redpouch" MakeBundle("redpouch", true, nil, { "lucky_goldnugget" }, true, redpouch), MakeBundle("redpouch_yotp", false, nil, nil, true, redpouch_yotp), MakeBundle("redpouch_yotc", false, nil, nil, true, redpouch_yotc), MakeBundle("redpouch_yotb", false, nil, nil, true, redpouch_yotb), MakeBundle("redpouch_yot_catcoon", false, nil, nil, true, redpouch_yot_catcoon), MakeBundle("redpouch_yotr", false, nil, nil, true, redpouch_yotr), MakeBundle("yotc_seedpacket", true, nil, nil, true, yotc_seedpacket), MakeBundle("yotc_seedpacket_rare", true, nil, nil, true, yotc_seedpacket_rare), MakeBundle("carnival_seedpacket", true, nil, nil, true, carnival_seedpacket), MakeBundle("hermit_bundle", true, nil, nil, true, hermit_bundle), MakeBundle("hermit_bundle_shells", true, nil, nil, true, hermit_bundle_shells, "hermit_bundle","hermit_bundle","hermit_bundle"), MakeBundle("wetpouch", true, nil, JoinArrays(table.getkeys(wetpouch.loottable), GetAllWinterOrnamentPrefabs()), false, wetpouch) Some basic code I have for checking the inventroy: local function CheckInventory(inst) for k, v in pairs(inst.components.container.slots) do if true then --Code 1 else --Code 2 end end end Link to comment https://forums.kleientertainment.com/forums/topic/151038-scanningcreating-bundled-wraps/ Share on other sites More sharing options...
Hamurlik Posted September 20, 2023 Share Posted September 20, 2023 I don't have any experience with this, but you could check out "Insight" or "Show Me" mods. They have a feature to show what contents a bundle holds when mousing over it in the inventory. That's all I can help. Good luck. Link to comment https://forums.kleientertainment.com/forums/topic/151038-scanningcreating-bundled-wraps/#findComment-1665803 Share on other sites More sharing options...
FurryEskimo Posted September 21, 2023 Author Share Posted September 21, 2023 21 hours ago, Hamurlik said: I don't have any experience with this, but you could check out "Insight" or "Show Me" mods. They have a feature to show what contents a bundle holds when mousing over it in the inventory. That's all I can help. Good luck. Thanks for the tip, that’s probably exactly what I need. I think the answer’s looking me square in the face, and I just don’t know it yet. Link to comment https://forums.kleientertainment.com/forums/topic/151038-scanningcreating-bundled-wraps/#findComment-1665951 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