Jump to content

Recommended Posts

Hi, this is probably an easy question to be answered, but how would one go about making a character modify an existing recipe? For example, the Umbrella takes 6 twigs, 1 pig skin, and 2 silk to craft. How would I make it easier to craft down to 3 twigs and 1 silk for a character?

That code changes the recipe for everyone if the mod is loaded into the game. You need to be able to check the name of the character against an if statement to get it to change the recipe for a single character. This is very close to something I have been working at. The large issue is becoming the lack of an official API. 

 

 AddPrefabPostInit("umbrella", function(inst)
    if GLOBAL.GetPlayer().prefab == "your_characters_name" then
    GLOBAL.GetRecipe("umbrella").ingredients = {GLOBAL.Ingredient("twigs",3),GLOBAL.Ingredient("silk",1)}
    end
end)

 

Just finished testing this. With this placed in your modmain.lua file for the character you are modding will change the recipe only for the character name you place in the if statement.  Note, "your_character_name" should actually be the name of the prefab file for your modded character in all lower case. For most people this will be the name of the character, but on the off chance I thought I'd mention this.

I wish I could tell you exactly how it works, but it is working for me right now. Hope that helps. Maybe I can apply this to what I need too :D.

 

EDIT: Turns out this was exactly the answer I was looking for too, and it works well with just about any prefab in the game about which you want to add or change something.

It is many hours later now, as compared to the time of this original post, and a thought just came to me. This code, if used in DTS, would very likely mean everyone in the game would get this change on their character as well. That may or may not matter to you, but you are basically over writing the default code with your desired effect. Food for thought.

Edited by HatefulGravey

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
×
  • Create New...