Sign in to follow this  
Ran

Changing vanilla recipes

Recommended Posts

Ran    15

This one's a bit different from my usual. This time, I actually know how to do something, but I'd like to see if there's a cleaner way of doing it. More efficient, etc. Mostly cause I've been noticing the crazy FPS loss that having more and more mods is causing to my game, and I'm trying to cut down on mods, combine several into the same, clean up the codes a bit, etc. (On that note, is it the same to have a bunch of small mods, or a big one that does everything combined? Performance-wise, that is.)

 

I wanna change some vanilla recipes, and I know one way of doing it, but I get the feeling it's kind of the "dirty" way of doing it. Dunno if it affects performance or what, but it probably isn't the right way. Right now I'm simply making a mod folder and putting a modified recipes.lua inside scripts. But this had a visible change: some mod recipes switched order with the vanilla ones. Namely, some mod recipes are now before the vanilla ones on the crafting menu, which wasn't the case before. It doesn't really bother me per se, but it makes me feel like I shouldn't do it that way :p

 

So is there a more... professional way of modifying vanilla recipes?

Share this post


Link to post
Share on other sites
Ran    15

So it's basically the same as in the recipes.lua file, but adding the GLOBAL before a couple things, from what I'm getting.

Share this post


Link to post
Share on other sites
SenL    30

I may have misread, but did you copy the file recipes.lua into your mod's and edit it ... or just copy part of it into your modmain.lua?

 

Also I'm no expert. rezecib or someone else may have a better answer :).

Share this post


Link to post
Share on other sites
Ran    15

I copied it whole, then modified it. I was afraid the game maybe skips the original file altogether, so if I deleted something from it I might make it unavailable in-game. The file is still called recipes.lua, inside a scripts folder, inside the mod folder.

 

I'm gonna try your method, but now I'm wondering on some details. Like, in the recipes.lua file there's a

require "recipe"require "tuning"

at the beginning, I'm not sure if I need that on the new modmain.lua.

 

And then, previously I had a

GLOBAL.LoadScript("recipes.lua")

at the start of my modmain.lua, but dunno if I still need it there since I'm not using the original file anymore.

Edited by Ran

Share this post


Link to post
Share on other sites
SenL    30

No I don't think you need "GLOBAL.LoadScript("recipes.lua")".

My mod doesn't have require "recipe" or require "tuning" either.

Give it a try.

Share this post


Link to post
Share on other sites
Ran    15

Well actually it just gave me an error for trying to have those 'require' up there, so there we go, lol. And it seems indeed I don't need to load recipes.lua either.

 

It work just fine, awesome. Only it moves the modified recipes to the bottom of their respective tabs, but well, no big deal. At least I don't need that extra scripts folder inside my mod anymore :razz:

Edited by Ran

Share this post


Link to post
Share on other sites
rezecib    3169
I copied it whole, then modified it.
Definitely avoid doing stuff like that whenever possible-- it's a recipe for having your mod broken by updates and other mods :p

 

But yeah, SenL was right-- you can just declare the recipe again with different ingredients, because if you look at scripts/recipe.lua, when a recipe is defined, the prefab it makes (recipe calls this "name") is used to put the recipe in the AllRecipes table. So... AllRecipes.torch is the torch recipe. If you declare the torch recipe again, it'll get put there, replacing the old recipe.

 

Because you should be doing this in the modmain, though, you need to prepend GLOBAL. on a few things, like SenL did. 

 

You can get around moving the recipes around the tabs by storing the sortkey before and after, but this may cause other issues? I'm not sure. For example:

local torchsortkey = GLOBAL.AllRecipes.torch.sortkeylocal torchrecipe = GLOBAL.Recipe(...) -- whatever you want the recipe to beGLOBAL.AllRecipes.torch.sortkey = torchsortkey

Share this post


Link to post
Share on other sites
Ran    15

Hm, not quite sure what the sortkey is, actually. From what I've seen recipes simply show up in the order they are on the recipes.lua file, and any extra ones from mods go at the botton. So makes sense that modded vanilla ones go at the bottom too I guess. Though dunno how the game handles multiple mods adding recipes on the same tab, is there a mod load order?

 

Edit: Oh man, I just realized I made this on the wrong forum, it wasn't supposed to be on the DST part o_o My bad.

Edited by Ran

Share this post


Link to post
Share on other sites
rezecib    3169

@Ran, Oh, in that case, you can definitely change the sortkey without any problems. In DST it might cause issues, but in single-player it'll be fine. Sortkey in single-player just determines where it shows up in the recipe list. By default, recipe assigns the next number as the sortkey, which is why they don't play with it at all in recipes.lua, but you can look at Webber/Wigfrid to see them changing sortkeys.

Share this post


Link to post
Share on other sites
Ran    15

Oh, right, there's character-specific recipes, I should have thought of that. I'll check it out, thanks.

Share this post


Link to post
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
Sign in to follow this