Blade & Sorcery
0 of 0

File information

Last updated

Original upload

Created by

Ebediam

Uploaded by

Ebediam

Virus scan

Safe to use

Tags for this mod

About this mod

(VIDEO INSIDE) Are you tired of going to the book to summon your weapons? Say no more! Use this spell to summon the item selector TO YOUR HAND. Remove the spell to remove the item selector. It always appears on your left hand.

Permissions and credits
Changelogs
public class ItemSelector : LevelModule
{
public bool bookSpawnedRight;
public bool bookSpawnedLeft;

public GameObject book;
public GameObject bookInstance;

public override void OnLevelLoaded(LevelDefinition levelDefinition)
{

bookSpawnedRight = false;
bookSpawnedLeft = false;


}

public override void Update(LevelDefinition levelDefinition)
{

bookSpawnedRight = CheckForSpell(Player.local.body.handRight, bookSpawnedRight);
bookSpawnedLeft = CheckForSpell(Player.local.body.handLeft, bookSpawnedLeft);

if(bookInstance != null)
{
bookInstance.transform.LookAt(Player.local.head.transform);
bookInstance.transform.Rotate(90f, 0f, 0f);
}

}


bool CheckForSpell(BodyHand hand, bool bookSpawned)
{

if (hand.caster.currentSpell != null && hand.interactor.grabbedHandle == null && !bookSpawned)
{
if (hand.caster.currentSpell.name == "ItemSelectorSpell(Clone)")
{
if(book == null)
{
if (GameObject.Find("ItemStorage") != null)
{
book = GameObject.Find("ItemStorage");
}
}
else if(bookInstance == null)
{
bookSpawned = true;
bookInstance = GameObject.Instantiate(book, Creature.player.body.handLeft.interactor.transform.position - Creature.player.body.handLeft.interactor.transform.right.normalized * 0.35f - Creature.player.body.handLeft.interactor.transform.forward.normalized * 0.2f, Creature.player.body.handLeft.interactor.transform.rotation, Creature.player.body.handLeft.interactor.transform);

}


}
}

if (bookSpawned)
{
if (hand.caster.currentSpell != null)
{
if (hand.caster.currentSpell.name != "ItemSelectorSpell(Clone)")
{
GameObject.Destroy(bookInstance);
bookSpawned = false;
}
}
else
{
GameObject.Destroy(bookInstance);
bookSpawned = false;
}
}

return bookSpawned;
}

public override void OnLevelUnloaded(LevelDefinition levelDefinition)
{
// Called when the level unload
book = null;
bookInstance = null;
}
}