Jump to content

Recommended Posts

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?

@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.

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...