spad4 Posted February 1, 2019 Share Posted February 1, 2019 I don't know what I should put in modmain and modinfo in order for my mod to work properly. I've looked through some of the mods I have downloaded, but I don't understand what I would need for my mod. All it does is change a few stats in tuning.lua. I also don't know where to find tutorials for this, I've already looked through some of the forum posts for help and tutorials. YouTube doesn't have much either. Link to comment Share on other sites More sharing options...
Ultroman Posted February 2, 2019 Share Posted February 2, 2019 (edited) Most of the stuff in modinfo is self-explanatory. Modmain is your mod code. Take a look at my mod Metabolizer. It only changes a single tuning variable, so it should be a good baseline. Here is the modinfo from that mod. Scroll down for explanations! --[[ Copyright © 2015 Ultroman ]] name = "Metabolizer" description = "Allows you to set the base rate of hunger.\nRanges are: 400-200% loss in increments of 25, and 200% loss to 200% gain in increments of 5%.\nShould be compatible with mods that change the time-settings, which factors into the calculation of the hunger-rate." author = "Ultroman" version = "0.0.5" forumthread = "" api_version = 6 dst_api_version = 10 -- line added for forum thread; is not like this in mod currently dont_starve_compatible = false reign_of_giants_compatible = false shipwrecked_compatible = false dst_compatible = true all_clients_require_mod = false client_only_mod = false server_filter_tags = {"metabolizer", "hunger", "rate", "metabolism"} priority = 0 icon_atlas = "preview.xml" icon = "preview.tex" -- This is a shortened version of the configuration_options available in the mod. There are 4 times as many in the actual mod. configuration_options = { { name = "HungerVariable", label = "Hunger Rate %", options = { {description = "default loss", data = 100}, {description = "95% loss", data = 95}, {description = "90% loss", data = 90}, {description = "85% loss", data = 85}, {description = "80% loss", data = 80}, {description = "75% loss", data = 75}, {description = "70% loss", data = 70}, {description = "65% loss", data = 65}, {description = "60% loss", data = 60}, {description = "55% loss", data = 55}, {description = "50% loss", data = 50}, {description = "45% loss", data = 45}, {description = "40% loss", data = 40}, {description = "35% loss", data = 35}, {description = "30% loss", data = 30}, {description = "25% loss", data = 25}, {description = "20% loss", data = 20}, {description = "15% loss", data = 15}, {description = "10% loss", data = 10}, {description = "5% loss", data = 5}, {description = "No loss", data = 0}, }, default = 100, } } The first line just shows how to make comments. Everything after two dashes like this -- is ignored. The copyright stuff is just a joke name => Name of the mod description => The description shown in the mod menu in the game. Typing \n jumps down a line. There is another way to write the description which might make more sense to you. description = [[First line of Mod Description Second line of mod description Third line of mod description]] version => Your own arbitrary version number. Only use numbers and periods for this e.g. 0.2.5 or 0.1 or 1 forumthread => you can put in an id for a forumthread on the Klei forum here, so when you click the globe-button in the mod menu it opens that forum thread in your default browser. If you just leave it empty like I have, it takes you to the Steam Workshop page (if there is one). api_version => this must be set to 10 for Don't Starve Together mods and 6 for Don't Starve mods UNLESS you also provide the next variable. dst_api_version => If you also provide this variable, your modinfo file can be used for both DS and DST, because DST will then just read the dst_api_version variable and DS will read api_version. In that case, set api_version to 6 and dst_api_version to 10. dont_starve_compatible => is your mod compatible with vanilla Don't Starve?reign_of_giants_compatible => is your mod compatible with Don't Starve's Reign of Giants DLC?shipwrecked_compatible => is your mod compatible with Don't Starve's Shipwrecked DLC?hamlet_compatible => is your mod compatible with Don't Starve's Hamlet DLC?dst_compatible => is your mod compatible with Don't Starve Together? all_clients_require_mod => (ONLY APPLICABLE TO DST) Do all clients require your mod? This is sometimes a difficult one to answer, but in your case set it to false, since it is only a server mod (I might be mistaken...not sure if none of the tuning variables are used on the clients...mine are not). If this was a mod which added an item to the game or something, then all clients need the mod, because it'll contain new images etc. In that case, set this to true. client_only_mod => (ONLY APPLICABLE TO DST) Is this mod only changing client-side things? This is sometimes a difficult one to answer, but in your case set it to false, since your mod is a server mod. If you are only making changes to UI and do not change any variables in the world or on entities, this could most likely be set to true instead. If this is true, then all_clients_require_mod should be set to false. server_filter_tags => (ONLY APPLICABLE TO DST) A collection of tags for filtering servers when trying to find a server to join priority => This is a special one. It helps determine which order mods are loaded in. The lower the value, the later the mod is loaded, and consequently, the higher the value, the earlier the mod is loaded. Just leave it at 0 in your case. icon_atlas => The XML file containing the atlas for your preview image.icon => The TEX file containing the image data for your preview image. configuration_options => The collection of configuration options, each with a variable-name, a label for the menu, and all the possible values for this option. For DST mods, you have an extra attribute you can add to your configuration options called "hover". It's the text shown at the top of the mod settings menu, when you hover the mouse over an option. For an example of hover text, check out my simple mod Monster Ash Drop Tuner. Note that you are restricted to only two lines. Edited March 3, 2019 by Ultroman 1 1 1 Link to comment Share on other sites More sharing options...
spad4 Posted February 2, 2019 Author Share Posted February 2, 2019 (edited) So if I were changing stats in tuning.lua, would I write something like GLOBAL.TUNING.SPIDER_HEALTH = 150 And if I was changing something that's in a prefab, (multitool effectiveness multiplier) how would I change that? I also have a couple of other mod ideas, one I'm currently working on, which is a rock that functions like a nightmare light (minus phase effects). How would I implement that? Do I add the code into a prefabs folder for my mods' scripts folder, then reference it in modmain? Edited February 2, 2019 by spad4 Link to comment Share on other sites More sharing options...
Ultroman Posted February 2, 2019 Share Posted February 2, 2019 Yes. The following will change every instance of the given prefab. AddPrefabPostInit("PREFAB_NAME", function(inst) -- make your changes to the components on the inst parameter, which is a single instance of the prefab. end Link to comment Share on other sites More sharing options...
spad4 Posted February 2, 2019 Author Share Posted February 2, 2019 (edited) so my modmain code should look something like... GLOBAL.TUNING.SPIDER_HEALTH = 150, GLOBAL.TUNING.SPIDER_DAMAGE = 35, GLOBAL.TUNING.SPIDER_WARRIOR_DAMAGE = 35, GLOBAL.TUNING.SPIDER_WARRIOR_ATTACK_PERIOD = 2, GLOBAL.TUNING.HOUND_HEALTH = 200, GLOBAL.TUNING.HOUND_DAMAGE = 30, GLOBAL.TUNING.HOUND_SPEED = 9, GLOBAL.TUNING.MOONHOUND_HEALTH = 200, GLOBAL.TUNING.MOONHOUND_DAMAGE = 30, GLOBAL.TUNING.MOONHOUND_SPEED = 9, GLOBAL.TUNING.FIREHOUND_HEALTH = 150, GLOBAL.TUNING.ICEHOUND_HEALTH = 150, also, could you explain what you meant by make your changes to the components on the inst parameter, which is a single instance of the prefab. Edited February 2, 2019 by spad4 Link to comment Share on other sites More sharing options...
Ultroman Posted February 2, 2019 Share Posted February 2, 2019 In order to change things on the components of items, like the multipliers you talked about, you need to access and change the components directly on each of the instances of these items, by doing something like this in an AddPrefabPostInit. inst.components.somecomponent.somevariable = 1 -- where 1 is just an example of a value Look at the code for the prefabs you want to change, to see which components are on them, and then look at the code for these components, to see what you can change on them and how. Link to comment Share on other sites More sharing options...
spad4 Posted February 2, 2019 Author Share Posted February 2, 2019 (edited) Do I have to put my changes to tuning.lua in this statement? if GLOBAL.TheNet and GLOBAL.TheNet:GetIsServer() then end The code I have written in modmain right now doesn't seem to be working. (below is everything I have in my modmain) local TUNING = GLOBAL.TUNING -- not sure if i need this or not GLOBAL.TUNING.SPIDER_HEALTH = 150, GLOBAL.TUNING.SPIDER_DAMAGE = 35, GLOBAL.TUNING.SPIDER_WARRIOR_DAMAGE = 35, GLOBAL.TUNING.SPIDER_WARRIOR_ATTACK_PERIOD = 2, GLOBAL.TUNING.HOUND_HEALTH = 200, GLOBAL.TUNING.HOUND_DAMAGE = 30, GLOBAL.TUNING.HOUND_SPEED = 9, GLOBAL.TUNING.MOONHOUND_HEALTH = 200, GLOBAL.TUNING.MOONHOUND_DAMAGE = 30, GLOBAL.TUNING.MOONHOUND_SPEED = 9, GLOBAL.TUNING.FIREHOUND_HEALTH = 150, GLOBAL.TUNING.ICEHOUND_HEALTH = 150, GLOBAL.TUNING.CRAWLINGHORROR_HEALTH = 400, GLOBAL.TUNING.CRAWLINGHORROR_DAMAGE = 35, GLOBAL.TUNING.TERRORBEAK_HEALTH = 300, GLOBAL.TUNING.TERRORBEAK_DAMAGE = 60, Edited February 2, 2019 by spad4 Link to comment Share on other sites More sharing options...
Ultroman Posted February 3, 2019 Share Posted February 3, 2019 Yes. Put your tuning changes into an if-statement like that. The first line local TUNING = GLOBAL.TUNING -- not sure if i need this or not is supposed to save you some characters in your code, and right now you're not using it for anything. It takes GLOBAL.TUNING and makes a reference to it in a local variable. To avoid confusion, I would not call it TUNING. Also, you don't put commas at the end of lines in LUA. You should take at least a crash course in LUA, if you want to code mods. Otherwise it'll take you weeks, if you have to ask on the forum for every little thing, and though I'm a patient man, even I have limits Do like this. local _G = GLOBAL local _T = _G.TUNING if _G.TheNet and _G.TheNet:GetIsServer() then _T.SPIDER_HEALTH = 150 _T.SPIDER_DAMAGE = 35 _T.SPIDER_WARRIOR_DAMAGE = 35 _T.SPIDER_WARRIOR_ATTACK_PERIOD = 2 _T.HOUND_HEALTH = 200 _T.HOUND_DAMAGE = 30 _T.HOUND_SPEED = 9 _T.MOONHOUND_HEALTH = 200 _T.MOONHOUND_DAMAGE = 30 _T.MOONHOUND_SPEED = 9 _T.FIREHOUND_HEALTH = 150 _T.ICEHOUND_HEALTH = 150 _T.CRAWLINGHORROR_HEALTH = 400 _T.CRAWLINGHORROR_DAMAGE = 35 _T.TERRORBEAK_HEALTH = 300 _T.TERRORBEAK_DAMAGE = 60 end Link to comment Share on other sites More sharing options...
spad4 Posted February 3, 2019 Author Share Posted February 3, 2019 (edited) Alright, thanks a ton. I won't bother you anymore. About the commas thing, I've read multiple times to read the game's code for help and in tuning.lua they were at the end of the lines so I wasn't sure. Edited February 3, 2019 by spad4 Link to comment Share on other sites More sharing options...
Ultroman Posted February 3, 2019 Share Posted February 3, 2019 (edited) You're welcome And it's fine. Just letting you know that you can save a lot of annoyance and lifetime doing mods, if you learn the language. On the commas, that's how you declare/fill collections when you initialize them, because it's in sort of list-form. You want to manipulate them after they've been initialized, so you have to do it one by one. Good luck with your mod! Didn't you also want to change some multipliers? Edited February 3, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now