Bubblez Posted September 10, 2017 Share Posted September 10, 2017 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 Link to comment Share on other sites More sharing options...
alainmcd Posted September 10, 2017 Share Posted September 10, 2017 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). Link to comment Share on other sites More sharing options...
Bubblez Posted September 11, 2017 Author Share Posted September 11, 2017 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? Link to comment Share on other sites More sharing options...
Bubblez Posted September 11, 2017 Author Share Posted September 11, 2017 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 Link to comment Share on other sites More sharing options...
Bubblez Posted September 11, 2017 Author Share Posted September 11, 2017 Actually there are no food recipes here. I'm so blind :S Do those exist else where? Link to comment Share on other sites More sharing options...
alainmcd Posted September 11, 2017 Share Posted September 11, 2017 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". Link to comment Share on other sites More sharing options...
Bubblez Posted September 12, 2017 Author Share Posted September 12, 2017 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? Link to comment Share on other sites More sharing options...
alainmcd Posted September 13, 2017 Share Posted September 13, 2017 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. Link to comment Share on other sites More sharing options...
Bubblez Posted September 13, 2017 Author Share Posted September 13, 2017 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. Link to comment Share on other sites More sharing options...
alainmcd Posted September 13, 2017 Share Posted September 13, 2017 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. ? Link to comment Share on other sites More sharing options...
Bubblez Posted September 13, 2017 Author Share Posted September 13, 2017 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". Link to comment Share on other sites More sharing options...
alainmcd Posted September 13, 2017 Share Posted September 13, 2017 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. Link to comment Share on other sites More sharing options...
Bubblez Posted September 13, 2017 Author Share Posted September 13, 2017 @alainmcd Found it in the strings.lua. Is it possible to convert that into JSON as well? Link to comment Share on other sites More sharing options...
Bubblez Posted September 13, 2017 Author Share Posted September 13, 2017 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? Link to comment Share on other sites More sharing options...
alainmcd Posted September 13, 2017 Share Posted September 13, 2017 Hey, you said it was the last question! 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. Link to comment Share on other sites More sharing options...
Bubblez Posted September 13, 2017 Author Share Posted September 13, 2017 1 minute ago, alainmcd said: Hey, you said it was the last question! 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 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. Link to comment Share on other sites More sharing options...
alainmcd Posted September 13, 2017 Share Posted September 13, 2017 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! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.