neahxx Posted October 30, 2018 Share Posted October 30, 2018 (edited) Hello fellow modders and DST players, I'm wondering how I would look through the recipe list from the file, Recipes.lua Instructions: Read recipes file. Read through recipe list for entries with science/magic level 1. Return a list of the recipe names for each entry. Step 4 I can do on my own, but I'll explain for context. I need to return all the recipes that use a certain station level so I can add the recipe to my character's knowledge. Why am i doing this in such a specific way? I want to make it so my character has the equivalent of Wickerbottom's knowledge of first level of crafting (Plus for magic), except requires the respective second station for further recipes. inst:DoTaskInTime(0, function(inst) inst.components.builder:AddRecipe("shovel") inst:PushEvent("unlockrecipe", { recipe = "shovel" }) end) If you can help with this, I'd be extremely grateful. Edited October 30, 2018 by neahxx Link to comment Share on other sites More sharing options...
Electroely Posted October 30, 2018 Share Posted October 30, 2018 (edited) The table "AllRecipes" (declared in scripts/recipe.lua) stores every declared crafting recipe. In a Recipe object, the Recipe.level variable contains a table of the recipe's (no idea what these are called) tech levels. Here's what I used to find out what the shovel recipe's level variable contains: (printwrap goes through a table and prints out every key and value) So for your purposes, I imagine you'd have code that looks like this: inst:DoTaskInTime(0, function(inst) for k, v in pairs(AllRecipes) do if v and v.level and (v.level.SCIENCE == 1 or v.level.MAGIC == 1) then inst.components.builder:AddRecipe(v.name) inst:PushEvent("unlockrecipe", { recipe = v.name }) end end end) I haven't tested it, but if it works it should be compatible with modded recipes as well as vanilla ones. Edited October 30, 2018 by Electroely Link to comment Share on other sites More sharing options...
neahxx Posted October 30, 2018 Author Share Posted October 30, 2018 (edited) Thanks a ton, I'll try this in a bit then post the results later this evening. Edit: Can't post the results yet due to other mod bugs. Edited October 31, 2018 by neahxx Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now