I was making a crafting system and I was wondering how I could make it so that the template for what you could craft would know what it should craft when you click on the text.
this is what I have so far for crafting the text template:
Craftable.prototype.onStateChanged = function(state) {
if (played == true){
for (var i = this.entity.children.length - 1; i >= 0; i--) {
this.entity.children[i].destroy();
}
}
const craftableItems = this.getCraftableItems();
craftableItems.forEach(item => {
let template = this.app.assets.find('Text');
if (template) {
var text = template.resource.instantiate();
let capitalizedName = Helper.capitalizeEveryWord(item.name)
text.element.text = capitalizedName
this.entity.addChild(text);
}
});
played = true
};