Hyaciao Posted May 4, 2015 Share Posted May 4, 2015 Okay I actually have two problems again. Though this time, they are hopefully less problematic for my simpleton brain to understand. I hope people aren't like, oh man... they're back again with more stressful problems. Number 1. (Removing generic inventory slots)I've seen a lot of mods that give additional slots. So I tried to use them as references namely this one DarkXero's Explaination. However they aren't really helping me a lot since I want to remove inventory slots (The default ones where picked up items go into.) Number 2. (Item that gives passive health restoration when held by "mycustomcharacter")This one might actually be somewhere deep deep at the bottom of the archives but I couldn't find it. I'm aware of the sanity restoration code since I found it from the life giving amulet and the nightsword.lua. So using that + what I can conjure from all the component folder this sort of works but it seems to only work on the character.lua only. inst.components.health:StartRegen(1, 1) Link to comment https://forums.kleientertainment.com/forums/topic/53499-help-script-for-removing-player-inventory-slots/ Share on other sites More sharing options...
DarkXero Posted May 4, 2015 Share Posted May 4, 2015 Unfortunately, what I helped Gigadroid with won't be of much use for that. There are two ways we can do the inventory thing. We screw with the widget and we make an inventory with dummy items bound to the character so that they don't even drop on death, therefore having an effective reduced inventory, with the item tiles with dummy items being inaccessible. We edit the inventory component when the mod loads. This one involves overriding the constructor for the inventory class, since the max slots variable is made readonly after construction. But before we go into this, tell, the reduced inventory applies to everyone or just a custom character? Because if you want to reduce everyone's inventory all you need in the modmain is:GLOBAL.MAXITEMSLOTS = 5For the health, put on the onequipfn of your item: owner.healthtask = owner:DoPeriodicTask(1, function() owner.components.health:DoDelta(0.5, true) end)and in the onunequipfn: if owner.healthtask then owner.healthtask:Cancel() owner.healthtask = nil endso when using the item as amulet, you recover health, 0.5 health per second. Or do you mean held as in, "in inventory"? Link to comment https://forums.kleientertainment.com/forums/topic/53499-help-script-for-removing-player-inventory-slots/#findComment-634373 Share on other sites More sharing options...
Hyaciao Posted May 4, 2015 Author Share Posted May 4, 2015 For the first one. I would like to only have to affect my own characters as I'm sure affecting everyone would cause some compatibility issues. (Although I will note this down as it might make an interesting mod later. Man I learn so much from you! So thank you ) For number 2. Onequip as in held hand. So what you already posted is perfect thanks! Link to comment https://forums.kleientertainment.com/forums/topic/53499-help-script-for-removing-player-inventory-slots/#findComment-634374 Share on other sites More sharing options...
DarkXero Posted May 4, 2015 Share Posted May 4, 2015 local inventory = GLOBAL.require("components/inventory")local old = inventory._ctorlocal function OnDeath(inst) if inst.components.inventory ~= nil then inst.components.inventory:DropEverything(true) endendinventory._ctor = function(self, inst) self.inst = inst self.isopen = false self.isvisible = false --Hacky flags for altering behaviour when moving items between containers self.ignoreoverflow = false self.ignorefull = false self.silentfull = false self.ignoresound = false self.itemslots = {} self.maxslots = self.inst.maxslotsinv or GLOBAL.MAXITEMSLOTS self.equipslots = {} self.activeitem = nil self.acceptsstacks = true self.ignorescangoincontainer = false self.opencontainers = {} self.dropondeath = true inst:ListenForEvent("death", OnDeath) if inst.replica.inventory.classified ~= nil then GLOBAL.makereadonly(self, "maxslots") GLOBAL.makereadonly(self, "acceptsstacks") GLOBAL.makereadonly(self, "ignorescangoincontainer") endendlocal invreplica = GLOBAL.require("components/inventory_replica")invreplica.GetNumSlots = function(self) if self.inst.components.inventory ~= nil then return self.inst.components.inventory:GetNumSlots() else return self.inst.maxslotsinv or GLOBAL.MAXITEMSLOTS endendUse that for custom characters. Put in the common_postinit of your character:inst.maxslotsinv = 5to have 5 items. Link to comment https://forums.kleientertainment.com/forums/topic/53499-help-script-for-removing-player-inventory-slots/#findComment-634453 Share on other sites More sharing options...
Hyaciao Posted May 4, 2015 Author Share Posted May 4, 2015 That was perfect! Thank you! Link to comment https://forums.kleientertainment.com/forums/topic/53499-help-script-for-removing-player-inventory-slots/#findComment-634468 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