Recommended Posts

Bubblez    11

Hello,

I was thinking about making an app with all the craftable items and food recipes so that the user can "check/queue" items that they want to craft and the app would give them the total materials required.

The reason why I want to build such app is that I often tend to waste my days being confused about what I should gather next and since I'm speaking about Don't Starve Together in particular, it gets more frustrating because we can't really pause the game.

So yea, after googling a bit I didn't find a similar app/web app.

My question is, does Klei provide an API/JSON file with all the items that exist? I highly doubt it. What about the wiki? Am I able to access its data freely in a formatted way? What if I'm gonna build my own JSON for all the items, am I allowed to use the wiki's images for free?

Thanks and I hope someone from Klei takes a look at this :)

Share this post


Link to post
Share on other sites
alainmcd    861

Most of the game logic is in Lua. You can find the recipes in the data/scripts/recipes.lua file of your DS installation (and data/DLC0001/scripts/recipes.lua for RoG and data/DLC0002/scripts/recipes.lua for SW, would also recommend that you check the recipe.lua file in the same folders). The game includes a JSON library (data/scripts/json.lua) and I/O facilities, so you could encode the Recipes table to JSON and export it to a new file directly from within the game (the default output path is the data folder).

As for the images, you should be fine with using the ones in the wiki. If it's for personal use, then surely it's ok, if you intend to distribute it, you should check the license, but probably you'd only have to mention where you got them from. Or you can convert the TEX images yourself to PNG with ktools or TEXTool (there might be newer versions).

  • Like 1

Share this post


Link to post
Share on other sites
Bubblez    11
16 hours ago, alainmcd said:

Most of the game logic is in Lua. You can find the recipes in the data/scripts/recipes.lua file of your DS installation (and data/DLC0001/scripts/recipes.lua for RoG and data/DLC0002/scripts/recipes.lua for SW, would also recommend that you check the recipe.lua file in the same folders). The game includes a JSON library (data/scripts/json.lua) and I/O facilities, so you could encode the Recipes table to JSON and export it to a new file directly from within the game (the default output path is the data folder).

As for the images, you should be fine with using the ones in the wiki. If it's for personal use, then surely it's ok, if you intend to distribute it, you should check the license, but probably you'd only have to mention where you got them from. Or you can convert the TEX images yourself to PNG with ktools or TEXTool (there might be newer versions).

What about the craft-able items?

Share this post


Link to post
Share on other sites
Bubblez    11

Oh my bad I accidentally saw the food recipes only and I thought that's all that is in the file. It does have all the items. That's perfect I hope.

Thanks a lot for pointing that out :)

  • Like 1

Share this post


Link to post
Share on other sites
Bubblez    11

Actually there are no food recipes here. I'm so blind :S

Do those exist else where? 

  • Like 1

Share this post


Link to post
Share on other sites
alainmcd    861

Yes, the equivalent files for foods are data/scripts/preparedfoods.lua and cooking.lua. But you can just use this.

Also, in single player, character-specific recipes (both for foods (Warly) and craftables (Wickerbottoms's books, Wigfrid's spear and helm, maybe other stuff)) are declared in the character's file in data/scripts/prefabs/CHARACTERNAME.lua, data/scripts/DLC0001 or DLC0002/prefabs/CHARACTERNAME.lua for RoG and SW. Whereas in DST, all craftables are declared in the recipes.lua file, with character-restricted recipes having a special tag, like "bookbuilder" for Wickerbottom. Note that Wigfrid is called "wathgrithr" in the code and Maxwell is "waxwell".

Edited by alainmcd
  • Like 1

Share this post


Link to post
Share on other sites
Bubblez    11
On 9/11/2017 at 2:19 PM, alainmcd said:

Yes, the equivalent files for foods are data/scripts/preparedfoods.lua and cooking.lua. But you can just use this.

Also, in single player, character-specific recipes (both for foods (Warly) and craftables (Wickerbottoms's books, Wigfrid's spear and helm, maybe other stuff)) are declared in the character's file in data/scripts/prefabs/CHARACTERNAME.lua, data/scripts/DLC0001 or DLC0002/prefabs/CHARACTERNAME.lua for RoG and SW. Whereas in DST, all craftables are declared in the recipes.lua file, with character-restricted recipes having a special tag, like "bookbuilder" for Wickerbottom. Note that Wigfrid is called "wathgrithr" in the code and Maxwell is "waxwell".

Dumb question, any idea how or where I can use the json.lua to convert the recipe files? Do I do it from the game's console?

Share this post


Link to post
Share on other sites
alainmcd    861

Yep, try this in the console:

local recipes = io.open("recipes.json", "w"); recipes:write(json.encode(Recipes)); recipes:close()
local foods = io.open("foods.json", "w"); foods:write(json.encode(require"preparedfoods")); foods:close()

You can do it from the main menu. If you have SW installed and want the vanilla or RoG recipes, start a new vanilla/RoG non SW compatible game, then copy-paste it into the console. As noted above, character-specific recipes not included unless you start a game with the character.

  • Like 1

Share this post


Link to post
Share on other sites
Bubblez    11
10 hours ago, alainmcd said:

Yep, try this in the console:


local recipes = io.open("recipes.json", "w"); recipes:write(json.encode(Recipes)); recipes:close()
local foods = io.open("foods.json", "w"); foods:write(json.encode(require"preparedfoods")); foods:close()

You can do it from the main menu. If you have SW installed and want the vanilla or RoG recipes, start a new vanilla/RoG non SW compatible game, then copy-paste it into the console. As noted above, character-specific recipes not included unless you start a game with the character.

The one for Recipes isn't working. I get an error in the console saying that variable Recipes isn't declared.

Also the foods.json, for some reason all online JSON validators don't like it.

Share this post


Link to post
Share on other sites
alainmcd    861
7 minutes ago, Bubblez said:

The one for Recipes isn't working. I get an error in the console saying that variable Recipes isn't declared.

I hadn't checked DST, try instead AllRecipes:

local recipes = io.open("recipes.json", "w"); recipes:write(json.encode(AllRecipes)); recipes:close()

 

11 minutes ago, Bubblez said:

Also the foods.json, for some reason all online JSON validators don't like it.

I just checked the resulting JSON for SW and DST and this online validator gave me an OK for both. ?

  • Like 1

Share this post


Link to post
Share on other sites
Bubblez    11

THANKS A LOT. For some reason they didn't get validated in other websites. But yea they work well now.

Last question I hope, do you know how the items' real names are mapped in game to the ones in the lua/json? You know, saddle_basic is mapped to "Saddle".

  • Like 1

Share this post


Link to post
Share on other sites
alainmcd    861

The file you want is data/scripts/strings.lua. The STRINGS table contains all names, verbs, descriptions, or whatever in the game. I imagine you'll want to export the STRINGS.NAMES table to JSON and then check if the name of a given item exists as an index to that table (in all caps). Or something like that.

Share this post


Link to post
Share on other sites
Bubblez    11
2 minutes ago, alainmcd said:

The file you want is data/scripts/strings.lua. The STRINGS table contains all names, verbs, descriptions, or whatever in the game. I imagine you'll want to export the STRINGS.NAMES table to JSON and then check if the name of a given item exists as an index to that table (in all caps). Or something like that.

I replied to you at the same time :)

So yea, is it possible to convert it to JSON? 

Share this post


Link to post
Share on other sites
alainmcd    861

Hey, you said it was the last question! :p

local names = io.open("names.json", "w"); names:write(json.encode(STRINGS.NAMES)); names:close()

Works for SW, haven't tried to validate it, though. As noted, the index is the name used in the game code in all caps.

  • Like 1

Share this post


Link to post
Share on other sites
Bubblez    11
1 minute ago, alainmcd said:

Hey, you said it was the last question! :p


local names = io.open("names.json", "w"); names:write(json.encode(STRINGS.NAMES)); names:close()

Works for SW, haven't tried to validate it, though. As noted, the index is the name used in the game code in all caps.

I said I hope it is :p

Worked like a charm. Sorry if I seemed a bit of a noob here. I've never used Lua before :)

I REALLY appreciate your help. Hope you have a nice day.

  • Like 1

Share this post


Link to post
Share on other sites
alainmcd    861

No worries, we're all learning here! Don't hesitate to ask if anything else pops up.

Thank you, and a nice day to you too!

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