Jump to content

Recommended Posts

Not something I think can likely be achieved but I was wondering if there was any way to have a character start a game equipped with an item. My reason for asking is that the custom item I have is a backpack and I'd like it to function much like the vanilla backpack where characters can't keep the item in their inventory as to avoid abusing its extra inventory slots. However because it can't be stored in inventory, the character won't actually start with the item.

If this isn't possible, I'd then ask if it's possible to script a way for a player to only keep one of said item in their inventory.

Edited by Eranthis

In your master_postinit add the following code if it doesn't exist or add it to the OnNewSpawn function if it does.

inst.OnNewSpawn = function()
	local backpack = SpawnPrefab("backpack") --change the "backpack" to your prefab name
	inst.components.inventory:Equip(backpack)
end

Cheers,

Iron_Hunter

17 hours ago, IronHunter said:

In your master_postinit add the following code if it doesn't exist or add it to the OnNewSpawn function if it does.


inst.OnNewSpawn = function()
	local backpack = SpawnPrefab("backpack") --change the "backpack" to your prefab name
	inst.components.inventory:Equip(backpack)
end

Cheers,

Iron_Hunter

Alright that solved it. Thanks!

Edited by Eranthis

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