. . . Posted August 25, 2016 Share Posted August 25, 2016 (edited) Would it be possible to give a character backpack inventory without having a backpack equipped? Like say when my character goes insane I want him to get that inventory the krampus sack gives without having to equip anything, would that be possible? Of course it would probably conflict with my character being able to wear backpacks if it's possible but I assume the easy fix would just be to remove the ability to equip backpacks for my character when he goes insane. Anyways, I would really, really love if someone could answer this because this's something i've been wanting to do for a long time but all the times I tried to do it failed... So, it'd be great if someone could actually tell me if this would be possible or not . Thanks for reading my question !!! Problem's down below VVV Edited September 16, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/ Share on other sites More sharing options...
Serpens Posted August 25, 2016 Share Posted August 25, 2016 (edited) why not actually give your character krampus bagback ? And remove it, when sanity is higher again. But don't forget to save the items in inventory. Anyway, I don't think this is a good idea. Since it is hard to control the sanity ingame. And suddenly you are loosing items stored in this bag, just because you got some sanity. And of course you will put your previous bagback down everytime you become insane... this is not very nice gameplay I think. Edited August 25, 2016 by Serpens Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-806945 Share on other sites More sharing options...
. . . Posted August 25, 2016 Author Share Posted August 25, 2016 2 hours ago, Serpens said: why not actually give your character krampus bagback ? And remove it, when sanity is higher again. But don't forget to save the items in inventory The problem's that if I equip him a invisible krampus sack when he goes insane then he won't be able to equip stuff like armor or else the invisible krampus sack would fall off, so that's why I wanted to know if I can just give him the backpack stuff without needing to equip anything...but it seems that may not be possible ... I hope it can be possible if only someone would be able to know to tell me xD... Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-806980 Share on other sites More sharing options...
Serpens Posted August 25, 2016 Share Posted August 25, 2016 Ah yes... I always play with a mod that allows armor + backpack, that's why I did not thought about armor steamcommunity.com/sharedfiles/filedetails/?id=496249680 I'm quite sure it is possible, but I don't know how. And I think it will be quite complicated and error prone... so you should think carefully if this is worth the hassle.. Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-806982 Share on other sites More sharing options...
. . . Posted August 26, 2016 Author Share Posted August 26, 2016 (edited) Well, I tried adding these codes in my character.lua inst.components.container:Open(inst) MakeInventoryPhysics(inst) inst:AddTag("backpack") inst:AddComponent("container") inst.components.container:WidgetSetup("krampus_sack") and it just crashes the game saying "[00:00:22]: [string "../mods/Adam DST Mod/scripts/prefabs/adam.l..."]:816: attempt to index field 'container' (a nil value)" I don't understand why it crashes ... I'd really appreciate some guidance ! Edited August 26, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-807307 Share on other sites More sharing options...
DarkXero Posted August 26, 2016 Share Posted August 26, 2016 character.lua: local function CloseInsaneContainer(inst) inst.insanecontainer.components.container:DropEverything() inst.insanecontainer.components.container:Close() end local function OpenInsaneContainer(inst) inst.insanecontainer.components.container:Open(inst) end local function AttachInsaneContainer(inst, data) if inst.insanecontainer ~= nil then inst.insanecontainer:Remove() inst.insanecontainer = nil end inst.insanecontainer = data and SpawnSaveRecord(data.insanecontainer) or SpawnPrefab("insanecontainer") inst.insanecontainer.entity:SetParent(inst.entity) inst.insanecontainer.entity:AddFollower() inst.insanecontainer.Follower:FollowSymbol(inst.GUID, "swap_body", 0, 0, 0) end local function OnDespawn(inst) if inst.insanecontainer ~= nil then inst.savedata_insanecontainer = inst.insanecontainer:GetSaveRecord() inst.insanecontainer:Remove() end end local function OnSave(inst, data) if inst.insanecontainer ~= nil then data.insanecontainer = inst.savedata_insanecontainer or inst.insanecontainer:GetSaveRecord() end end local function OnLoad(inst, data) if data ~= nil and data.insanecontainer ~= nil then AttachInsaneContainer(inst, data) end if inst.components.sanity:IsSane() then CloseInsaneContainer(inst) else OpenInsaneContainer(inst) end end local function master_postinit(inst) AttachInsaneContainer(inst) inst.OnDespawn = OnDespawn inst.OnSave = OnSave inst.OnLoad = OnLoad inst:ListenForEvent("gosane", CloseInsaneContainer) inst:ListenForEvent("goinsane", OpenInsaneContainer) end Merge it properly with your OnSave, OnLoad, OnDespawn functions, if they exist. Pay attention as my OnSave, OnLoad functions make use of the data argument, so include it if you don't have it. This code takes care of handling the container. prefabs/insanecontainer.lua: local data_insanecontainer = { widget = { slotpos = {}, animbank = "ui_krampusbag_2x8", animbuild = "ui_krampusbag_2x8", pos = Vector3(-5, -120, 0), }, issidewidget = true, type = "insanepack", } for y = 0, 6 do table.insert(data_insanecontainer.widget.slotpos, Vector3(-162, -75 * y + 240, 0)) table.insert(data_insanecontainer.widget.slotpos, Vector3(-162 + 75, -75 * y + 240, 0)) end local function OnEntityReplicated(inst) inst.replica.container:WidgetSetup("insanecontainer", data_insanecontainer) end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddNetwork() inst:AddTag("CLASSIFIED") inst:AddTag("NOCLICK") inst.entity:SetPristine() if not TheWorld.ismastersim then inst.OnEntityReplicated = OnEntityReplicated return inst end inst:AddComponent("inventoryitem") inst.components.inventoryitem.canbepickedup = false inst:AddComponent("container") inst.components.container:WidgetSetup("insanecontainer", data_insanecontainer) return inst end return Prefab("insanecontainer", fn) This code is the container itself. It makes use of the data parameter of WidgetSetup to initialize a similar widget to the krampus sack. This can coexist with armor and backpacks. Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-807355 Share on other sites More sharing options...
. . . Posted August 26, 2016 Author Share Posted August 26, 2016 (edited) @DarkXero Wow !!! Thank you so, so, so much DarkXero you're so awesome !!!! I'm very sorry but i'm getting this crash when I try to start the game, i'm very sorry to bother you so, so much ... [00:00:22]: [string "../mods/Adam DST Mod/scripts/prefabs/adam.l..."]:780: attempt to index field 'insanecontainer' (a nil value) LUA ERROR stack traceback: ../mods/Adam DST Mod/scripts/prefabs/adam.lua:780 in (upvalue) AttachInsaneContainer (Lua) <774-783> ../mods/Adam DST Mod/scripts/prefabs/adam.lua:842 in (upvalue) master_postinit (Lua) <838-2017> scripts/prefabs/player_common.lua:1803 in (field) fn (Lua) <1536-1844> scripts/mainfunctions.lua:146 in () ? (Lua) <135-177> I added the code to go in my character's lua & merged the code with any of the functions that already existed. And I copied & pasted my character.lua & deleted all the code, renamed it "insanecontainer" & added all the insane container code into it & put it in my prefabs folder but this crash then happened. I'm really sorry I must've done something wrong but I don't what... Please forgive me & thank you so much for making so much code for me , I really thank you !!!!!!!!!!! PS. If you need me to post my character just tell me I do it right away! Edited August 26, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-807363 Share on other sites More sharing options...
DarkXero Posted August 26, 2016 Share Posted August 26, 2016 Did you add "insanecontainer" to PrefabFiles on modmain? Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-807376 Share on other sites More sharing options...
. . . Posted August 26, 2016 Author Share Posted August 26, 2016 10 minutes ago, DarkXero said: Did you add "insanecontainer" to PrefabFiles on modmain? It works now & it's gorgeous !!!!!! Thank you so, so, so, so, so much DarkXero, you should be called the DarkHero of all modders !!!!!! Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-807378 Share on other sites More sharing options...
. . . Posted September 12, 2016 Author Share Posted September 12, 2016 (edited) @DarkXero If you have any time to spare anytime could you maybe please help me fix 2 problems with "insanecontainer" ? #1 - It happens when my character goes in the darkness for some reason the insanecontainer closes & doesn't get open again until he goes insane again & is in light... Look! #2 - Also, you remember gelid mode? In gelid mode my character's inventory becomes a fridge! Would it be possible if you could also tell me how I make the insanecontainer act as a fridge when it's owner has " act.target.noactualfreezing:set(true) " and when the owner becomes " act.target.noactualfreezing:set(false) " it loses the fridge tag? I would really, really appreciate your help DarkXero because I have no idea why the container closes in darkness & I have no idea how to make it act as a fridge if the owner has " act.target.noactualfreezing:set(true) "... So, I beg for your help if you can help me anytime I really, really would be so happy !!! This's all the code she has related to insanecontainer insanecontainer.lua local data_insanecontainer = { widget = { slotpos = {}, animbank = "ui_krampusbag_2x8", animbuild = "ui_krampusbag_2x8", pos = Vector3(-5, -120, 0), }, issidewidget = true, type = "insanepack", } for y = 0, 6 do table.insert(data_insanecontainer.widget.slotpos, Vector3(-162, -75 * y + 240, 0)) table.insert(data_insanecontainer.widget.slotpos, Vector3(-162 + 75, -75 * y + 240, 0)) end local function OnEntityReplicated(inst) inst.replica.container:WidgetSetup("insanecontainer", data_insanecontainer) end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddNetwork() inst:AddTag("CLASSIFIED") inst:AddTag("NOCLICK") inst.entity:SetPristine() if not TheWorld.ismastersim then inst.OnEntityReplicated = OnEntityReplicated return inst end inst:AddComponent("inventoryitem") inst.components.inventoryitem.canbepickedup = false inst:AddComponent("container") inst.components.container:WidgetSetup("insanecontainer", data_insanecontainer) return inst end return Prefab("insanecontainer", fn) adam.lua -------------------------------------------------------\ -- All credit for "InsaneContainer" belong to DarkXero! ] -------------------------------------------------------/ local function CloseInsaneContainer(inst) inst.insanecontainer.components.container:DropEverything() inst.insanecontainer.components.container:Close() end local function OnLoad(inst, data) if data ~= nil and data.insanecontainer ~= nil then AttachInsaneContainer(inst, data) end if inst.components.sanity:IsSane() then CloseInsaneContainer(inst) else OpenInsaneContainer(inst) end end local function OpenInsaneContainer(inst) inst.insanecontainer.components.container:Open(inst) end local function AttachInsaneContainer(inst, data) if inst.insanecontainer ~= nil then inst.insanecontainer:Remove() inst.insanecontainer = nil end inst.insanecontainer = data and SpawnSaveRecord(data.insanecontainer) or SpawnPrefab("insanecontainer") inst.insanecontainer.entity:SetParent(inst.entity) inst.insanecontainer.entity:AddFollower() inst.insanecontainer.Follower:FollowSymbol(inst.GUID, "swap_body", 0, 0, 0) end local function OnDespawn(inst) if inst.insanecontainer ~= nil then inst.savedata_insanecontainer = inst.insanecontainer:GetSaveRecord() inst.insanecontainer:Remove() end end local function OnSave(inst, data) if inst.insanecontainer ~= nil then data.insanecontainer = inst.savedata_insanecontainer or inst.insanecontainer:GetSaveRecord() end end local master_postinit = function(inst) -- All credit for "InsaneContainer" belong to DarkXero! AttachInsaneContainer(inst) inst.OnDespawn = OnDespawn inst.OnSave = OnSave inst.OnLoad = OnLoad inst:ListenForEvent("gosane", CloseInsaneContainer) inst:ListenForEvent("goinsane", OpenInsaneContainer) end Edited September 13, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-812860 Share on other sites More sharing options...
DarkXero Posted September 13, 2016 Share Posted September 13, 2016 On 12/9/2016 at 4:58 AM, SuperDavid said: #1 - It happens when my character goes in the darkness for some reason the insanecontainer closes & doesn't get open again until he goes insane again & is in light... Look! That happens to all containers. insanecontainer.lua: local data_insanecontainer = { widget = { slotpos = {}, animbank = "ui_krampusbag_2x8", animbuild = "ui_krampusbag_2x8", pos = Vector3(-5, -120, 0), }, issidewidget = true, type = "insanepack", } for y = 0, 6 do table.insert(data_insanecontainer.widget.slotpos, Vector3(-162, -75 * y + 240, 0)) table.insert(data_insanecontainer.widget.slotpos, Vector3(-162 + 75, -75 * y + 240, 0)) end -- new function local function SpecialClose(inst) local container = inst.components.container or inst.replica.container local _Close = container.Close container.Close = function(self) if self.inst:HasTag("cantbeclosed") then return end _Close(self) end end local function OnEntityReplicated(inst) inst.replica.container:WidgetSetup("insanecontainer", data_insanecontainer) -- new code SpecialClose(inst) end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddNetwork() inst:AddTag("CLASSIFIED") inst:AddTag("NOCLICK") inst.entity:SetPristine() if not TheWorld.ismastersim then inst.OnEntityReplicated = OnEntityReplicated return inst end inst:AddComponent("inventoryitem") inst.components.inventoryitem.canbepickedup = false inst:AddComponent("container") inst.components.container:WidgetSetup("insanecontainer", data_insanecontainer) -- new code SpecialClose(inst) return inst end return Prefab("insanecontainer", fn) adam.lua: local function AttachInsaneContainer(inst, data) if inst.insanecontainer ~= nil then inst.insanecontainer:Remove() inst.insanecontainer = nil end inst.insanecontainer = data and SpawnSaveRecord(data.insanecontainer) or SpawnPrefab("insanecontainer") inst.insanecontainer.entity:SetParent(inst.entity) inst.insanecontainer.entity:AddFollower() inst.insanecontainer.Follower:FollowSymbol(inst.GUID, "swap_body", 0, 0, 0) end local function CloseInsaneContainer(inst) -- new code inst.insanecontainer:RemoveTag("cantbeclosed") inst.insanecontainer.components.container:DropEverything() inst.insanecontainer.components.container:Close() end local function OpenInsaneContainer(inst) inst.insanecontainer.components.container:Open(inst) -- new code inst.insanecontainer:AddTag("cantbeclosed") end local function OnLoad(inst, data) if data ~= nil and data.insanecontainer ~= nil then AttachInsaneContainer(inst, data) end if inst.components.sanity:IsSane() then CloseInsaneContainer(inst) else OpenInsaneContainer(inst) end end local function OnDespawn(inst) if inst.insanecontainer ~= nil then inst.savedata_insanecontainer = inst.insanecontainer:GetSaveRecord() inst.insanecontainer:Remove() end end local function OnSave(inst, data) if inst.insanecontainer ~= nil then data.insanecontainer = inst.savedata_insanecontainer or inst.insanecontainer:GetSaveRecord() end end local master_postinit = function(inst) AttachInsaneContainer(inst) inst.OnDespawn = OnDespawn inst.OnSave = OnSave inst.OnLoad = OnLoad inst:ListenForEvent("gosane", CloseInsaneContainer) inst:ListenForEvent("goinsane", OpenInsaneContainer) end This should do it. On 12/9/2016 at 4:58 AM, SuperDavid said: #2 - Also, you remember gelid mode? In gelid mode my character's inventory becomes a fridge! Would it be possible if you could also tell me how I make the insanecontainer act as a fridge when it's owner has " act.target.noactualfreezing:set(true) " and when the owner becomes " act.target.noactualfreezing:set(false) " it loses the fridge tag? local function common_postinit(inst) -- add "noactualfreezingdirty" to inst.noactualfreezing so we have an event to listen to inst.noactualfreezing = net_bool(inst.GUID, "player.noactualfreezing", "noactualfreezingdirty") end local function ApplyFridgeTag(inst) if inst.noactualfreezing:value() then inst.insanecontainer:AddTag("fridge") else inst.insanecontainer:RemoveTag("fridge") end end local function master_postinit(inst) -- after the container is attached AttachInsaneContainer(inst) -- listen to event pushed when the net variable changes inst:ListenForEvent("noactualfreezingdirty", ApplyFridgeTag) end Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-813363 Share on other sites More sharing options...
. . . Posted September 14, 2016 Author Share Posted September 14, 2016 (edited) @DarkXero I'm sorry to bother you but i'm having trouble with making the insanecontainer fridge part.. So, I added the code like this but when I try to log into a world it instant crashes & there's nothing in the log ! local function common_postinit(inst) NoGelidFreezing(inst) -- When I remove this code the game doesn't crash instantly inst:AddTag("perfect") inst:AddComponent("keyhandler") inst.MiniMapEntity:SetIcon("adam.tex") inst:ListenForEvent("keypressed", OnKeyPressed) inst.noactualfreezing = net_bool(inst.GUID, "player.noactualfreezing", "noactualfreezingdirty") inst.components.frostybreather.gelidbreath = net_bool(inst.GUID, "player.gelidbreath", "gelidbreathdirty") inst.components.frostybreather.gelidbreath:set(false) inst:ListenForEvent("gelidbreathdirty", GelidFrostyBreather) end function ApplyFridgeTag(inst) if inst.noactualfreezing:value() then inst.insanecontainer:AddTag("fridge") else inst.insanecontainer:RemoveTag("fridge") end end local master_postinit = function(inst) AttachInsaneContainer(inst) AttachInsaneContainer(inst) inst.OnDespawn = OnDespawn inst.OnSave = OnSave inst.OnLoad = OnLoad inst:ListenForEvent("gosane", CloseInsaneContainer) inst:ListenForEvent("goinsane", OpenInsaneContainer) inst:ListenForEvent("noactualfreezingdirty", ApplyFridgeTag) inst:ListenForEvent("firedamage", function(inst, data) if not inst.components.health:IsDead() and inst.gelid_mode == true then -- Break Gelid mode when take fire damage. inst.gelid_mode = nil inst:RemoveTag("fridge") inst.sg:GoToState("hit") inst.noactualfreezing:set(false, "noactualfreezingdirty") end end The code when I remove crash goes away. local function NoGelidFreezing(inst) inst.noactualfreezing = net_bool(inst.GUID, "player.noactualfreezing") inst.noactualfreezing:set(false) local _IsFreezing = inst.IsFreezing inst.IsFreezing = function(inst) if inst.noactualfreezing:value() then return false end return _IsFreezing(inst) end end Also, by 3 hours ago, DarkXero said: -- add "noactualfreezingdirty" to inst.noactualfreezing so we have an event to listen to you mean something like " inst.noactualfreezing:set(true, "noactualfreezingdirty") " & " inst.noactualfreezing:set(false, "noactualfreezingdirty") " right? Edited September 14, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-813436 Share on other sites More sharing options...
DarkXero Posted September 14, 2016 Share Posted September 14, 2016 local function NoGelidFreezing(inst) inst.noactualfreezing = net_bool(inst.GUID, "player.noactualfreezing", "noactualfreezingdirty") inst.noactualfreezing:set(false) local _IsFreezing = inst.IsFreezing inst.IsFreezing = function(inst) if inst.noactualfreezing:value() then return false end return _IsFreezing(inst) end end local function common_postinit(inst) NoGelidFreezing(inst) inst:AddTag("perfect") inst:AddComponent("keyhandler") inst.MiniMapEntity:SetIcon("adam.tex") inst:ListenForEvent("keypressed", OnKeyPressed) inst.components.frostybreather.gelidbreath = net_bool(inst.GUID, "player.gelidbreath", "gelidbreathdirty") inst.components.frostybreather.gelidbreath:set(false) inst:ListenForEvent("gelidbreathdirty", GelidFrostyBreather) end local function ApplyFridgeTag(inst) if inst.noactualfreezing:value() then inst.insanecontainer:AddTag("fridge") else inst.insanecontainer:RemoveTag("fridge") end end local function OnTakingFireDamage(inst, data) if not inst.components.health:IsDead() and inst.gelid_mode == true then inst.gelid_mode = nil inst:RemoveTag("fridge") inst.sg:GoToState("hit") inst.noactualfreezing:set(false) end end local function master_postinit(inst) AttachInsaneContainer(inst) inst.OnDespawn = OnDespawn inst.OnSave = OnSave inst.OnLoad = OnLoad inst:ListenForEvent("gosane", CloseInsaneContainer) inst:ListenForEvent("goinsane", OpenInsaneContainer) inst:ListenForEvent("noactualfreezingdirty", ApplyFridgeTag) inst:ListenForEvent("firedamage", OnTakingFireDamage) end Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-813454 Share on other sites More sharing options...
. . . Posted September 14, 2016 Author Share Posted September 14, 2016 (edited) @DarkXero ..................I'm so, so, so, sorry DarkXero for bothering you for the third time ....but there's nothing else I can do..... For some reason the InsaneContainer doesn't close anymore when I become sane! I will once again show you all the code I have for InsaneContainer because I must've done something wrong ........... EDIT: I found out that the InsaneContainer closes properly on worlds without a cave but on worlds with caves the InsaneContainer never closes ! insanecontainer.lua local data_insanecontainer = { widget = { slotpos = {}, animbank = "ui_krampusbag_2x8", animbuild = "ui_krampusbag_2x8", pos = Vector3(-5, -120, 0), }, issidewidget = true, type = "insanepack", } for y = 0, 6 do table.insert(data_insanecontainer.widget.slotpos, Vector3(-162, -75 * y + 240, 0)) table.insert(data_insanecontainer.widget.slotpos, Vector3(-162 + 75, -75 * y + 240, 0)) end local function SpecialClose(inst) local container = inst.components.container or inst.replica.container local _Close = container.Close container.Close = function(self) if self.inst:HasTag("cantbeclosed") then return end _Close(self) end end local function OnEntityReplicated(inst) inst.replica.container:WidgetSetup("insanecontainer", data_insanecontainer) SpecialClose(inst) end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddNetwork() inst:AddTag("CLASSIFIED") inst:AddTag("NOCLICK") inst.entity:SetPristine() if not TheWorld.ismastersim then inst.OnEntityReplicated = OnEntityReplicated return inst end inst:AddComponent("inventoryitem") inst.components.inventoryitem.canbepickedup = false inst:AddComponent("container") inst.components.container:WidgetSetup("insanecontainer", data_insanecontainer) SpecialClose(inst) return inst end return Prefab("insanecontainer", fn) adam.lua local function AttachInsaneContainer(inst, data) if inst.insanecontainer ~= nil then inst.insanecontainer:Remove() inst.insanecontainer = nil end inst.insanecontainer = data and SpawnSaveRecord(data.insanecontainer) or SpawnPrefab("insanecontainer") inst.insanecontainer.entity:SetParent(inst.entity) inst.insanecontainer.entity:AddFollower() inst.insanecontainer.Follower:FollowSymbol(inst.GUID, "swap_body", 0, 0, 0) end local function CloseInsaneContainer(inst) inst.insanecontainer:RemoveTag("cantbeclosed") inst.insanecontainer.components.container:DropEverything() inst.insanecontainer.components.container:Close() end local function OpenInsaneContainer(inst) inst.insanecontainer.components.container:Open(inst) inst.insanecontainer:AddTag("cantbeclosed") end local function OnLoad(inst, data) if data ~= nil and data.insanecontainer ~= nil then AttachInsaneContainer(inst, data) end if inst.components.sanity:IsSane() then CloseInsaneContainer(inst) else OpenInsaneContainer(inst) end end local function OnDespawn(inst) if inst.insanecontainer ~= nil then inst.savedata_insanecontainer = inst.insanecontainer:GetSaveRecord() inst.insanecontainer:Remove() end end local function OnSave(inst, data) if inst.insanecontainer ~= nil then data.insanecontainer = inst.savedata_insanecontainer or inst.insanecontainer:GetSaveRecord() end end local function NoGelidFreezing(inst) inst.noactualfreezing = net_bool(inst.GUID, "player.noactualfreezing", "noactualfreezingdirty") inst.noactualfreezing:set(false) local _IsFreezing = inst.IsFreezing inst.IsFreezing = function(inst) if inst.noactualfreezing:value() then return false end return _IsFreezing(inst) end end local function common_postinit(inst) NoGelidFreezing(inst) inst:AddTag("perfect") inst:AddComponent("keyhandler") inst.MiniMapEntity:SetIcon("adam.tex") inst:ListenForEvent("keypressed", OnKeyPressed) inst.components.frostybreather.gelidbreath = net_bool(inst.GUID, "player.gelidbreath", "gelidbreathdirty") inst.components.frostybreather.gelidbreath:set(false) inst:ListenForEvent("gelidbreathdirty", GelidFrostyBreather) end local function ApplyFridgeTag(inst) if inst.noactualfreezing:value() then inst.insanecontainer:AddTag("fridge") else inst.insanecontainer:RemoveTag("fridge") end end local function FireBreakGelid(inst, data) if not inst.components.health:IsDead() and inst.gelid_mode == true then -- Break Gelid mode when take fire damage. inst.gelid_mode = nil inst:RemoveTag("fridge") inst.sg:GoToState("hit") inst.noactualfreezing:set(false) inst.components.sanity:DoDelta(-15) inst.components.health:DoDelta(-30) inst.components.hunger:DoDelta(-15) inst.components.temperature.hurtrate = 4 inst.components.temperature.maxtemp = 100 inst.components.freezable:SetResistance(1) inst.components.freezable:SpawnShatterFX(4) inst.components.freezable:StartWearingOff(10) inst.components.combat.min_attack_period = 0.1 inst.components.talker:Say(GetString(inst, "ANNOUNCE_GELID_BREAK")) end end local master_postinit = function(inst) AttachInsaneContainer(inst) inst.OnDespawn = OnDespawn inst.OnSave = OnSave inst.OnLoad = OnLoad inst:ListenForEvent("gosane", CloseInsaneContainer) inst:ListenForEvent("goinsane", OpenInsaneContainer) inst:ListenForEvent("noactualfreezingdirty", ApplyFridgeTag) inst:ListenForEvent("firedamage", FireBreakGelid) end Edited September 14, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-813477 Share on other sites More sharing options...
DarkXero Posted September 14, 2016 Share Posted September 14, 2016 9 hours ago, SuperDavid said: EDIT: I found out that the InsaneContainer closes properly on worlds without a cave but on worlds with caves the InsaneContainer never closes ! insanecontainer.lua: local data_insanecontainer = { widget = { slotpos = {}, animbank = "ui_krampusbag_2x8", animbuild = "ui_krampusbag_2x8", pos = Vector3(-5, -120, 0), }, issidewidget = true, type = "insanepack", } for y = 0, 6 do table.insert(data_insanecontainer.widget.slotpos, Vector3(-162, -75 * y + 240, 0)) table.insert(data_insanecontainer.widget.slotpos, Vector3(-162 + 75, -75 * y + 240, 0)) end local function SpecialClose(inst) local container = inst.components.container or inst.replica.container local _Close = container.Close container.Close = function(self) if self.inst:HasTag("cantbeclosed") then return end _Close(self) end end local function CloseIt(inst) inst.replica.container:Close() end local function OnEntityReplicated(inst) inst.replica.container:WidgetSetup("insanecontainer", data_insanecontainer) SpecialClose(inst) inst:ListenForEvent("closepls", CloseIt) end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddNetwork() inst:AddTag("CLASSIFIED") inst:AddTag("NOCLICK") inst.closepls = net_event(inst.GUID, "closepls") inst.entity:SetPristine() if not TheWorld.ismastersim then inst.OnEntityReplicated = OnEntityReplicated return inst end inst:AddComponent("inventoryitem") inst.components.inventoryitem.canbepickedup = false inst:AddComponent("container") inst.components.container:WidgetSetup("insanecontainer", data_insanecontainer) SpecialClose(inst) return inst end return Prefab("insanecontainer", fn) adam.lua: -- new function local function CloseInsaneContainer(inst) inst.insanecontainer:RemoveTag("cantbeclosed") inst.insanecontainer.components.container:DropEverything() inst.insanecontainer.components.container:Close() inst.insanecontainer.closepls:push() end Link to comment https://forums.kleientertainment.com/forums/topic/69764-solved-how-to-give-character-extra-inventory-space/#findComment-813558 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