Sign in to follow this  
Veketh

Coding - Amount of starting items!

Recommended Posts

Veketh    5

So I wanted to give a certain amount of starting item (etc. grass) to my character, but I don't really know how to do it. Can someone help me with this?

Share this post


Link to post
Share on other sites
Ultroman    727

Look in your character's Lua files. There's a list called start_inv near the top. Just populate that with items, e.g.,

local start_inv = { "papyrus", "papyrus", "featherpencil", }

You can find the item prefab names on the Don't Starve Wiki. Here's an example for the Feather Pencil.

To give stacks of items, you just have to put in more entries of that item, like with the "papyrus" here. Those two "papyrus" will end up in the same stack.

Edited by Ultroman
update

Share this post


Link to post
Share on other sites
Ultroman    727

Yep, looks like you might be able to steal some code from that mod. Good find!

EDIT: I had a look at the original game code and the code for that mod, and updated my answer above. Just use the start_inv list. That mod's code basically mimics what start_inv already provides for an individual character, but for all characters on the server, which is not what you want.

Edited by Ultroman

Share this post


Link to post
Share on other sites
Muskar    8
On 8/4/2019 at 5:43 PM, Ultroman said:

Look in your character's Lua files. There's a list called start_inv near the top. Just populate that with items, e.g.,


local start_inv = { "papyrus", "papyrus", "featherpencil", }

You can find the item prefab names on the Don't Starve Wiki. Here's an example for the Feather Pencil.

To give stacks of items, you just have to put in more entries of that item, like with the "papyrus" here. Those two "papyrus" will end up in the same stack.

I didn't understand what you meant by "your character's Lua files", so I searched through all scripts for "start_inv" with Notepad++'s Find In Files feature and found out you were talking about 'scripts/prefabs/[character_name].lua'. These scripts are found in data/databundles/scripts.zip in the Steam directory.

How to effectuate the changes with that knowledge is another issue. The readme in the data folder suggests extracting and then renaming the zip file for a temporary pseudo-modding solution.

Note, this isn't actually a feature I'm looking to do. I'm just trying to learn through others and share what I can.

Share this post


Link to post
Share on other sites
Ultroman    727
29 minutes ago, Muskar said:

I didn't understand what you meant by "your character's Lua files", so I searched through all scripts for "start_inv" with Notepad++'s Find In Files feature and found out you were talking about 'scripts/prefabs/[character_name].lua'. These scripts are found in data/databundles/scripts.zip in the Steam directory.

How to effectuate the changes with that knowledge is another issue. The readme in the data folder suggests extracting and then renaming the zip file for a temporary pseudo-modding solution.

Note, this isn't actually a feature I'm looking to do. I'm just trying to learn through others and share what I can.

Exactly...but not exactly :P

Yes, you can edit the game files after extracting them for testing things in the game, but I'd advise anyone to go the distance to set up a proper mod instead. Much less confusion, if you know how to do it, that is. You should never mess with the actual files of the game, unless you just want to mess around or test something, but it's exceedingly error-prone compared to the mod API approach.

What I actually meant by "your character's Lua files" was not the character files from the game, but the similar files in a character mod. Any character mod should have the start_inv list in some form, unless the character starts with nothing.

Share this post


Link to post
Share on other sites
Muskar    8
39 minutes ago, Ultroman said:

Exactly...but not exactly :P

Yes, you can edit the game files after extracting them for testing things in the game, but I'd advise anyone to go the distance to set up a proper mod instead. Much less confusion, if you know how to do it, that is. You should never mess with the actual files of the game, unless you just want to mess around or test something, but it's exceedingly error-prone compared to the mod API approach.

What I actually meant by "your character's Lua files" was not the character files from the game, but the similar files in a character mod. Any character mod should have the start_inv list in some form, unless the character starts with nothing.

Yes, it says as much in the scripts readme and it's pretty obvious too, I'd say. I still have no idea what "the similar files in a character mod" means. Do you have a thread to refer to, to get the knowledge that you seemingly assume your audience has?

Share this post


Link to post
Share on other sites
Muskar    8
47 minutes ago, Ultroman said:

I'd recommend this post as a great place to start :) 

 

Yeah, your collection was much appreciated. It was a great relief after finding that most of the other stuff was outdated and no longer working, like the official sample mods.

Out of curiosity, I'm guessing that if you copied a character's prefab script, e.g. Wilson, into [YourModDirectory]\scripts\prefabs and then changed that file instead, it'd overwrite the original one, right? If so, that seems like a method that requires frequent mod updates. Isn't there a more longer-term way to only overwrite the specific starting_inv part?

Share this post


Link to post
Share on other sites
Ultroman    727
2 hours ago, Muskar said:

Yeah, your collection was much appreciated. It was a great relief after finding that most of the other stuff was outdated and no longer working, like the official sample mods.

Out of curiosity, I'm guessing that if you copied a character's prefab script, e.g. Wilson, into [YourModDirectory]\scripts\prefabs and then changed that file instead, it'd overwrite the original one, right? If so, that seems like a method that requires frequent mod updates. Isn't there a more longer-term way to only overwrite the specific starting_inv part?

You are correct in all of that.

Yes, there is, but people mostly don't edit the original character prefabs. They might make a duplicate character and change the code, but rarely do they change the existing characters individually, as in mods will usually instead set a certain starting inventory which is used for any character chosen by the player, instead of it being character-specific. I am still not sure exactly what you want to accomplish, which is why I can't tell you how to best accomplish it. So, what are you actually trying to build?

Edited by Ultroman
  • Thanks 1

Share this post


Link to post
Share on other sites
Muskar    8
1 hour ago, Ultroman said:

You are correct in all of that.

Yes, there is, but people mostly don't edit the original character prefabs. They might make a duplicate character and change the code, but rarely do they change the existing characters individually, as in mods will usually instead set a certain starting inventory which is used for any character chosen by the player, instead of it being character-specific. I am still not sure exactly what you want to accomplish, which is why I can't tell you how to best accomplish it. So, what are you actually trying to build?

Thanks, that's good to know.

If you must know, I'm doing a UI mod. Essentially a questing mod but more like a tutorial assistant with progress and suggested solutions to problems previously faced, but no rewards beyond the inherent experience of being better at survival (aimed at more casual players). So not anything related to this topic. I'm just trying to get a better grasp at how things work and speed up the tedious task of looking through the entire source code to understand how to accomplish a long list of basic things. And I've only been able to find one related mod which was abandoned and not that close to what I want to do.

 

Share this post


Link to post
Share on other sites
Ultroman    727

Could you have a more Danish-sounding name? XD Dane here.

OK, some of these should be trivial, depending on your feature-set, but since you're making a client UI mod, you'll have to get really close with RPCs to retrieve or listen to information from the server. I'd look into some of the amazing APIs people have written. Serpens, Rezecib and a bunch of other brilliant people have solved many of these problems. I'd suggest figuring out if there's a DST modding Discord or something, or just start looking into these APIs and what they can help with, and perhaps reach out via the forum to ask for help in doing these things. It is very important to describe your scope and the exact problem you're asking about, since broad posts are too long for people to assess whether they can help before they give up trying to understand to problem and move on.

You have a lot of complex stuff ahead of you, communicating with the server. Unless you make it a server-mod instead, which pushes information to ALL players on the server, instead of it being a client mod. Both are interesting, but the client-mod makes it opt-in.

Edited by Ultroman

Share this post


Link to post
Share on other sites
Muskar    8
1 hour ago, Ultroman said:

Could you have a more Danish-sounding name? XD Dane here.

OK, some of these should be trivial, depending on your feature-set, but since you're making a client UI mod, you'll have to get really close with RPCs to retrieve or listen to information from the server. I'd look into some of the amazing APIs people have written. Serpens, Rezecib and a bunch of other brilliant people have solved many of these problems. I'd suggest figuring out if there's a DST modding Discord or something, or just start looking into these APIs and what they can help with, and perhaps reach out via the forum to ask for help in doing these things. It is very important to describe your scope and the exact problem you're asking about, since broad posts are too long for people to assess whether they can help before they give up trying to understand to problem and move on.

You have a lot of complex stuff ahead of you, communicating with the server. Unless you make it a server-mod instead, which pushes information to ALL players on the server, instead of it being a client mod. Both are interesting, but the client-mod makes it opt-in.

Nope. I'm the only person in the world with my name so there's no hiding from my Danishness :P

Thanks for the advice. I'll definitely take note of that.

I want it to be a client-mod exactly for the opt-in reason. Basically, my ambition is to create the tutorial that I feel a great game like this deserves. For many games there's only a minority who will opt-in for support features etc. but this is a hardcore game that seemingly scares away a lot of people who are not comfortable doing trial and error, and I want to do what I can to remedy that without ruining (imo) the spirit of the game like making the game super easy like most mods do.

My initial goals have been readjusted a bit after working with the (frankly) lack of documentation, so now I just want a few basic quests to work and judging which fundamentals are easiest to figure out on the fly.

Share this post


Link to post
Share on other sites
Ultroman    727

I think that's wise. Start small. You can always do version 2.0, and once you've made the first iteration, you'll have a much better idea of what you're dealing with and how you would approach it if you were to start over...and then you do...at least with the parts that are hopelessly broken, because they will be with your first contraption. You'd be the first person to perfectly program something on the first try without structural weaknesses and idiocy seeping from every line :) You need to write a lot of code to learn why and how bad code is bad. And don't be afraid to start over. You can always copy/paste the parts that worked in your previous iteration, but remember the phrase "kill your darlings". If it would benefit you greatly to tear down some code that you're really proud of or feel intimidated by refactoring, you have to be strong enough to do it anyway. That's probably one of the biggest struggles of programming. That, and naming things...so many things to name...constantly...

Share this post


Link to post
Share on other sites
Muskar    8
9 hours ago, Ultroman said:

I think that's wise. Start small. You can always do version 2.0, and once you've made the first iteration, you'll have a much better idea of what you're dealing with and how you would approach it if you were to start over...and then you do...at least with the parts that are hopelessly broken, because they will be with your first contraption. You'd be the first person to perfectly program something on the first try without structural weaknesses and idiocy seeping from every line :) You need to write a lot of code to learn why and how bad code is bad. And don't be afraid to start over. You can always copy/paste the parts that worked in your previous iteration, but remember the phrase "kill your darlings". If it would benefit you greatly to tear down some code that you're really proud of or feel intimidated by refactoring, you have to be strong enough to do it anyway. That's probably one of the biggest struggles of programming. That, and naming things...so many things to name...constantly...

I certainly have a lot of things to learn still, but I probably wouldn't be here if I weren't interested in making this specific mod, so that'll continue to be my ambition. I'd rather start with aiming for version 0.1 and then working toward 1.0. It's far too early to talk about a version 2.0. Or talking about fears before I've even seriously begun. This is a project I'm doing for fun, so as long as I enjoy working on it, I'm doing it the right way. That's how I see it.

Anyway, I'm certainly counting on looking into Rezecib's Combined Status mod which I think hooks into a lot ot things I need. At this point, I'm still figuring out how to figure things out. Thanks for recommending Serpens, I see they made many mods, so I'll keep them in mind.

  • Like 1
  • Health 1

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