Jump to content

Is modifying existing functions safe?


Recommended Posts

I've been considering recently working on a mod that serves to make Don't Starve's combat system a little more robust, and my first step with doing that was to add a sort of Pokemon-esque damage types system (I.e. Certain enemies would take more or less damage from different weapons, and different kinds of armor would protect you better from different types.)

My first thought on doing that was to change the function for calculating damage, but I vaguely recall being told that editing existing components and whatnot was kind of a terrible idea, so, before I try to continue with this, thoughts?

Link to comment
Share on other sites

If you are editing them by overwriting them, that is greatly frown upon as your mod will not be compatible with other mods. However, if you use the proper api (AddComponentPostInit) and change the functions that way it isn't frowned upon because your code will be compatible with other mods.

Just depends on if you want your mod to be compatible with other mods.

Link to comment
Share on other sites

34 minutes ago, Rosten said:

Is there any documentation for using these APIs anywhere?

You can find a full list of the 'API' inside the modutil.lua file in the scripts folder. However, there is no other documentation to tell you how it works, you will need to experiment and test things for yourself.

Link to comment
Share on other sites

2 hours ago, Kzisor said:

You can find a full list of the 'API' inside the modutil.lua file in the scripts folder. However, there is no other documentation to tell you how it works, you will need to experiment and test things for yourself.

Do you happen to know if using the AddComponentPostInit on a vanilla prefab will overwrite the component (if it already exists) with a modded one?

Link to comment
Share on other sites

Just now, zazabar said:

Do you happen to know if using the AddComponentPostInit on a vanilla prefab will overwrite the component (if it already exists) with a modded one?

AddComponentPostInit, allows you to hook into the component it doesn't overwrite it. You will still need to overwrite the functionality of the component you want to change.

Link to comment
Share on other sites

18 minutes ago, Serpens said:

download some simple mods and see how those things are used there ;)

Not all mods are created equally, meaning not all mods use the API. While this is decent advice, I would avoid giving it because of that sole reason. Take a gander at the workshop, only about half use proper API, and the other half probably don't work properly after all the updates.

Link to comment
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
 Share

×
  • Create New...