Jump to content

Reaching out for Understanding


Recommended Posts

Hello Mod Community!

 

So... I'm understand pretty well how programming works. If, then, else statements; Loops; variables; objects (although im not familiar with LUA objects) arrays, ect...

That being said, I'm still an armature, and was wondering if anyone knows of a guide on how Don't Starve's engine works.

 

For example, I'd like to mod my character so that when he eats meat he loses sanity. Or if he chops down a tree. But The sanity feature seems to be more complex than the health or hunger features. And part of the problem is I kind of get lost in tracking down the connections between objects and their functions. 

Any tip or pointers would be much appreciated, thanks!

Link to comment
Share on other sites

Look at the pinned posts at the top. There aren't a whole lot of guides detailing the engine, because any guide that covers an appreciable amount is basically the same amount of work to read as just reading the game's code. That being said, in my guide I did link a post (in the links at the end) that goes through many of the components.

 

For tracking down connections between things, find-in-files is your best friend. Just set it to search within the scripts folder, and it'll find pretty much anything you're looking for.

 

One of the aspects of Lua you may not be familiar with is functions as arguments. Many components have variables for holding custom functions. I'm guessing you probably want to provide a small function to the oneatfn variable in your character's eater component, something like this:

inst.components.eater.oneatfn = function(inst, food)    if food:HasTag("meat") then --you may want to use the tag "edible_MEAT" instead        inst.components.sanity:DoDelta(-5)    endend
Edited by rezecib
  • Like 1
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...