Jump to content

Mod Help, Spawning Items


Recommended Posts

Hey there, I was wondering if anyone could help me with a  quirk.

Is there a possible way to spawn random items? Not with console just as a special move I guess.

I have a Pearl character and I wanted it to be a perk for her to pull random items from her gem.

Can anyone help me I can't code to save my life, I would really appreciate it. Thank you.

Link to comment
Share on other sites

Check out the catcoon prefab:

/data/scripts/prefabs/catcoon.lua

friendGiftPrefabs + PickRandomGift(which uses GetRandomItem) functions mainly.

 

Tie the same type of logic with a list of prefabs you want to use and SpawnPrefab it to create it.

You can then shove this into your inventory with <player>.components.inventory:GiveItem(<prefab>) or make it fling out with some math using <prefab>.Transform:SetPosition.

 

Reason for having a set list of potential items is that if you use some globally declared random prefab creator, then you might pull out another Wilson character and cause bad things to happen.

Edited by CarlZalph
Link to comment
Share on other sites

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
 Share

×
  • Create New...