Jump to content

Recommended Posts

Posted

I'm working on a mod that's got a lot of different features. In the process of writing it, I've added several different Capabilities to the player, for storing different types of information and functionality. Now I'm trying to tidy up my code and wondering if it would be better to have just a single player Capability, to store all the various information I need. In quite a lot of cases, I need to use information from multiple Capabilities in the same place anyway, so keeping it all together seems more efficient. Is there any particular reason to prefer multiple simple Capabilities over fewer, larger Capabilities - or vice versa?

Posted

I asked this same question just a few weeks ago. I'm sure others will have their own advice, but personally I think it's mostly a matter of style and organization. What will help you make sense of the code when you need to update to the next version of Forge 6 months from now? What would help others make sense of it when they write an add-on or want to help you fix a big?

 

In my case, I have two capabilities set up so far--one to keep track of player thirst, and one for a whole set of booleans that keep track of whether the player has seen certain hints I give out. If I add a new capability that's closely related to thirst or relies somehow on thirst, like maybe temperature or drunkenness, I might piggy back on my existing thirst capability. But in general I think it's good to keep them separated just for organization's sake.

Posted

Do other people care about your data?

If its just data that you hold on to and deal with and others dont know what to do with it then use 1 cap.

If implemented correctly, 1 cap is massivly more performant then multiple.

If implemented incorrectly 1 cam is HUGELY more performant then multiple.

If you're just storing data for your internal use, use one.

If you are providing functionality that external modders would use. Seperate on logical functional lines to define a clear API.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Thanks for the tips. I'm not planning for external modders, and I think it'll be easier for me to understand and organise by keeping everything together - so I think I'll settle on combining it all into one.

 

6 minutes ago, LexManos said:

If implemented correctly, 1 cap is massivly more performant then multiple.

If implemented incorrectly 1 cam is HUGELY more performant then multiple.

Does more performant mean better performance or worse?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.