Jump to content

Recommended Posts

Greetings!

Sooo, I was thinking about giving my custom character a backback as a starting item, but I'm not sure if it's ever possible, as backpacks can't be put into inventories.

How is this works?

A simple "backpack" to the starting item list does the trick, or is it a lot more difficult?

Thanks in advance!

Edited by BillTheCipher

Well, somehow I remember I did start with backpacks, but I can't test scripts now, so I just have to guess:

local function _OnNewSpawn()
  SpawnPrefab("backpack")
  end

Add this function to your character.lua.

maybe this will work?

Edited by Combustiblemon
On 2/8/2021 at 7:36 AM, BillTheCipher said:

@Combustiblemon This coding spawned a backpack in a random place in the world :apathy:

In my mod, I use a line of code in my character's prefab file to make her spawn with a Hat on, maybe the same can be done with the backpack slot.

Try having this function run when your character spawns in. That should be the function OnNewSpawn if you used the character template.
 

local function SpawnWithStuff(inst)
    local backpack = SpawnPrefab("backpack")
    inst.components.inventory:Equip(backpack)
end

If this doesn't work, an easy option may be to make your own version of the backpack that can also act as an inventory item, specifically so you can properly spawn with it.

Edited by TheSkylarr
  • Like 1

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