This is actually possible and doesn't require many changes to the original script.
Find def pbItemCrafter at the bottom of the script that comes with this resource and replace it with this:
Ruby:
def pbItemCrafter(stock)
for i in 0...stock.length
raise _INTL("You are missing an ingredient or quantity value.") if stock[i][1].length%2 !=0
itemdata = GameData::Item.try_get(stock[i][0])
for j in 0...stock[i][1].length/2
ingr = stock[i][1][2*j]
cost = stock[i][1][2*j+1]
if !GameData::Item.try_get(ingr) || cost==0
raise _INTL("At least one ingredient or quantity value is invalid.")
end
end
if !itemdata # If target item does not exist
stock[i] = nil
end
end
stock.compact! # Remove nils
if stock.empty?
raise _INTL("After data validation, there are no items left in your input array. Please check for typos before trying again.")
end
end
You might have noticed that the number 123 appears a few times in these new lines you've added. That's because I've used game variable 123 to store the crafting recipes. This approach allows you to have the player "learn" new recipes on the fly by adding those recipes into this game variable. Here's an example of what I mean (this bit will need to be in an event):
Ruby:
pbGet(123).push(
[:SITRUSBERRY,[:POTION,2]]
)
Here, we take our game variable 123 (which is an array - I'll get onto that at the end) and we append it with our Sitrus Berry recipe. You'll notice that the formatting is identical to the original resource.
You can have the player learn multiple recipes at once like this:
If you want to use a different game variable, you just have to change the 123 everywhere.
Now for the most important part. Before the player is to learn a new recipe, you need to put this bit of code somewhere:
Ruby:
pbSet(123,[]) if pbGet(123)==0
You can put it in the same event where the player learns their first recipe or, if you're not adding this to a game with players already having save files, you can put it in the intro event. It's up to you. All I'll say is if you don't put it before the first recipe is learned, your game will crash.
I think that's all you need. If you're using a custom pause menu, I'll let you work out how to get this working with that based on the information I've given.
Let me know if there are any issues with this.
Having trouble finding cmd____ = -1 lines in the UI_PauseMenu script (accessed via Tools -> Script Editor). It might be because I'm working on Pokemon Essentials 21.1 and they've changed things?
Having trouble finding cmd____ = -1 lines in the UI_PauseMenu script (accessed via Tools -> Script Editor). It might be because I'm working on Pokemon Essentials 21.1 and they've changed things?
This section is for the discussion of the tutorials and resources on Eevee Expo. To find tutorials and resources, check out the Tutorial and Resource Manager for optimal navigation.