SenL Posted January 22, 2015 Share Posted January 22, 2015 Let's say I have a non-craftable custom sword and then I got killed far far from resurrect portal (endless mode). As a ghost, I have to go back to the portal (or touch stone) and become alive again. However, I would like this sword to be "right there" right now instead of right where I died. Is that possible to do? Link to comment https://forums.kleientertainment.com/forums/topic/49543-make-item-stay-with-ghost-possible/ Share on other sites More sharing options...
rezecib Posted January 22, 2015 Share Posted January 22, 2015 @SenL, Yup, this should definitely be possible. Ghosts technically have inventories, they're just hidden (there were some bugs a while back-- not sure if they're still around-- where if you died crafting a telltale heart, it'd go into your ghost inventory). Probably the easiest way to do this would be to use a toground function like Abigail's Flower (listens for the event ondropped), and have the toground delete the sword and spawn a new one in the character's inventory. This would probably involve storing a pairing of sword items and players somewhere so it handles properly with multiple copies of the character. Link to comment https://forums.kleientertainment.com/forums/topic/49543-make-item-stay-with-ghost-possible/#findComment-604744 Share on other sites More sharing options...
Kzisor Posted January 22, 2015 Share Posted January 22, 2015 Let's say I have a non-craftable custom sword and then I got killed far far from resurrect portal (endless mode). As a ghost, I have to go back to the portal (or touch stone) and become alive again. However, I would like this sword to be "right there" right now instead of right where I died. Is that possible to do? You could try the following code which basically makes any item with the nodrop tag unable to be dropped on the ground. local function InventoryPostInit(inst) local inst._DropItem = inst.DropItem local function inst:DropItem(inst, wholestack, randomdir, pos) if inst:HasTag("nodrop") then return end inst:_DropItem(inst, wholestack, randomdir, pos) end return instendAddComponentPostInit("inventory", InventoryPostInit)local function InventoryItemPostInit(inst) local inst._OnDropped = inst.OnDropped local function inst:OnDropped(randomdir) if self.inst:HasTag("nodrop") then return end inst:_OnDropped(randomdir) end return instendAddComponentPostInit("inventoryitem", InventoryItemPostInit) I haven't tested this code, but in theory it should work. ~Kzisor/Ysovuka P.S. this code goes in your modmain.lua file. Link to comment https://forums.kleientertainment.com/forums/topic/49543-make-item-stay-with-ghost-possible/#findComment-604756 Share on other sites More sharing options...
Jjmarco Posted January 22, 2015 Share Posted January 22, 2015 What about this line?inst.components.inventoryitem.keepondeath = true Link to comment https://forums.kleientertainment.com/forums/topic/49543-make-item-stay-with-ghost-possible/#findComment-604881 Share on other sites More sharing options...
Kzisor Posted January 22, 2015 Share Posted January 22, 2015 What about this line?inst.components.inventoryitem.keepondeath = true Looks like this only works when the function DropEverything is called. So it might possibly work for the OP. Link to comment https://forums.kleientertainment.com/forums/topic/49543-make-item-stay-with-ghost-possible/#findComment-604889 Share on other sites More sharing options...
Jjmarco Posted January 22, 2015 Share Posted January 22, 2015 @Kzisor, that's what I figured, if the OP's only concern is keeping the item when dying, then it's definetly enough. Link to comment https://forums.kleientertainment.com/forums/topic/49543-make-item-stay-with-ghost-possible/#findComment-604893 Share on other sites More sharing options...
SenL Posted January 23, 2015 Author Share Posted January 23, 2015 Wow it works! Thanks all! Link to comment https://forums.kleientertainment.com/forums/topic/49543-make-item-stay-with-ghost-possible/#findComment-605144 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