Jump to content

Recommended Posts

Ok, posted revised versions of the files used by these example mods and mods based on them for the Doorway update.NOTE: If you are making a new crafting tab, make sure this is done in the modmain but outside any GamePostInit or SimPostInit functions. The game's new loading process now requires this.

print("Loading My Cool Mod....")...--Add tab to master list defined in constants.lua--NOTE: Path to image in hard codes for the mod's folder name and MUST match the path specified in this mod's prefabs.xmlRECIPETABS["NEWTABNAME"] = {str = STRINGS.TABS.NEWTABNAME, sort=10, icon = "mods/MOD NAME/images/tab_newtabname.tex"}...local function modGamePostInit()    -- Do stuffendAddGamePostInit(modGamePostInit)local function modSimPostInit(player)    -- Do stuffendAddSimPostInit(modSimPostInit)print("loaded!")
WrathOf's Alternate files for Mods Edited by WrathOf

You should just have to replace your old version of the crafting.lua file with the new one I posted and then move the lines where you are adding the new tab to outside of the AddCraftingMenu function:

--NEW LocationRECIPETABS["CRAFT"] = {str = STRINGS.TABS.CRAFT, sort=10, icon = "mods/Uncraftable Craftables/images/tab_craftableuncraftables.tex"}local function AddCraftingMenu()...    --OLD Location    --RECIPETABS["CRAFT"] = {str = STRINGS.TABS.CRAFT, sort=10, icon = "mods/Uncraftable Craftables/images/tab_craftableuncraftables.tex"}...

Only in this section of the forums would these posts not get flamed with tl;dr responses. :lol: [MENTION=3587]Stroomschok[/MENTION]Where did you run off to? :D

I didn't have much time to check back yet. Never would have guessed that buying a new house is this much work >_<I'll check your response tomorrow, after I had some fun with the latest update of the game ;)

[MENTION=20527]VirtualVampire[/MENTION]Not sure what you mean? The game files are in the data/scripts folder and are text files with the .lua extension which you can edit in Notepad or whatever plain text editor you prefer.You can install one or all of my example mods to get you started with a folder structure to copy files into and then experiment with them from there. Make sure you mods uses the same scripts/prefabs or whatever folder structure the game uses for the file you are changing and the game will generally try to use your version versus the standard one.

If i want to change 2 recipes, is this code correct?

-- Example Recipe Mod-- by WrathOf-- v0.7-- Updated for Revision 74452 2013-03-12_14-18-42 (A Little Rain Must Fall)--------------------------------------------------------------------------------- Support thread here: ---- This is a basic mod that allows you to change the items required to make a-- craftable in the game such as tool and weapons.-- -- Refer to the recipes.lua file in the game's scripts folder to see what the-- existing recipes are and what the internal names for the ingredients are.------ Note: Currently requires an override of the crafting.lua file to overcome a--       coding bug in the game's version.  Make sure it is included with your--       mods that change or make new crafting recipes.------ To install this mod, put this file in a folder under-- "...\Steam\steamapps\common\dont_starve\mods" called "Example Recipe Mod",-- then open the "modsettings.lua" file in the mods folder and add the-- following but without the beginning "--":----ModManager:AddMod("Example Recipe Mod")---- When you run the game you should see a screen pop up that lists this mod as-- being loaded.---------------------------------------------------------------------------------print("Example Recipe Mod loaded.")--Callback function to change the recipe for pan flutes at GamePostInit.--The name can be almost anything, just don't start with 0-9 and use the exact--same name in the AddGamePostInit line below.local function modGamePostInit()	--Search for the recipe you want to change	local recipe = GLOBAL.GetRecipe("panflute")	--If find it then change it	if recipe then		--Set the ingredients for a recipe to a new list		recipe.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("cutgrass", 1),		}		--No need to update the crafting menu since this change is done before the game builds the menu	end		--Search for the recipe you want to change	local recipe2 = GLOBAL.GetRecipe("meatrack")	--If find it then change it	if recipe2 then		--Set the ingredients for a recipe to a new list		recipe2.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("twigs", 1),		}		--No need to update the crafting menu since this change is done before the game builds the menu	endend--Add a post init callback to the game when this mod is loaded.--This will tell the game to run the function above after loading the game's--main screen but before handing control over to the player.AddGamePostInit(modGamePostInit)--Callback function to change the recipe for pan flutes at SimPostInit.--Use this version if need to access hud to force an update to the crafting menu.local function modSimPostInit( maincharacter )	--Search for the recipe you want to change	local recipe = GLOBAL.GetRecipe("panflute")	--If find it then change it	if recipe then		--Set the ingredients for a recipe to a new list		recipe.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("cutgrass", 1),		}		--Should not be necessary, but wanted to show how to do this just in case		--Get reference to crafting menu		local craftmenu = maincharacter.HUD.controls.crafttabs		--Tell menu to update so recipe changes appear		if craftmenu then craftmenu:UpdateRecipes() end	end	--Search for the recipe you want to change	local recipe2 = GLOBAL.GetRecipe("meatrack")	--If find it then change it	if recipe2 then		--Set the ingredients for a recipe to a new list		recipe2.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("twigs", 1),		}		--Should not be necessary, but wanted to show how to do this just in case		--Get reference to crafting menu		local craftmenu = maincharacter.HUD.controls.crafttabs		--Tell menu to update so recipe changes appear		if craftmenu then craftmenu:UpdateRecipes() end	endend--Add a post init callback to the game when this mod is loaded.--This will tell the game to run the function above after loading a saved game--but before handing control over to the player.--uncomment to try but comment out AddGamePostInit line above so only one or--the other method is used.--AddSimPostInit(modSimPostInit)

Or there is more optimized code for it?

Edited by WrathOf
added spoiler tags (via Threadmins and Group Moderators)

The modGamePostInit method is fine, you do not need to do both. I was just showing 2 contexts of accomplishing this. Just delete the modSimPostInit portion or clear it out and use the function for some other purpose.Also, you could declare the recipe variable once and use it repeatedly....local recipe = nilrecipe = GLOBAL.GetRecipe("panflute")if recipe ....recipe = GLOBAL.GetRecipe("meatrack")if recipe ....I am showing you how to change an existing recipe so that the order in the menu is kept. You could also just redefine it but then it will show up at the end of the list for a given crafting tab....--(in modmain, not inside a function, near top before these vars are used)--Declare local versions of vars used from game's global environmentRECIPETABS = GLOBAL.RECIPETABSRecipe = GLOBAL.RecipeIngredient = GLOBAL.Ingredient--in the modGamePostInit functionRecipe("panflute", { Ingredient("cutgrass", 1) }, RECIPETABS.MAGIC, 2)Recipe("meatrack", { Ingredient("twigs", 1) }, RECIPETABS.FARM, 1, "meatrack_placer")But you will need to use my alternate version of "crafting.lua" to fix a bug in the code. Hope that is not more confusing :S

Edited by WrathOf
adjusted code for clarity

The modGamePostInit method is fine, you do not need to do both. I was just showing 2 contexts of accomplishing this. Just delete the modSimPostInit portion or clear it out and use the function for some other purpose.

thanks, it works now :)Here is code that i use

--Callback function to change the recipe for pan flutes at SimPostInit.--Use this version if need to access hud to force an update to the crafting menu.local function modSimPostInit( maincharacter )	local xrveleasyrecipe = nil	--Search for the recipe you want to change	xrveleasyrecipe = GLOBAL.GetRecipe("panflute")	--If find it then change it	if xrveleasyrecipe then		--Set the ingredients for a recipe to a new list		xrveleasyrecipe.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("cutgrass", 1),		}		--Should not be necessary, but wanted to show how to do this just in case		--Get reference to crafting menu		local craftmenu = maincharacter.HUD.controls.crafttabs		--Tell menu to update so recipe changes appear		if craftmenu then craftmenu:UpdateRecipes() end	end	--Search for the recipe you want to change	xrveleasyrecipe = GLOBAL.GetRecipe("meatrack")	--If find it then change it	if xrveleasyrecipe then		--Set the ingredients for a recipe to a new list		xrveleasyrecipe.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("rope", 1),			GLOBAL.Ingredient("twigs", 1),		}		--Should not be necessary, but wanted to show how to do this just in case		--Get reference to crafting menu		local craftmenu = maincharacter.HUD.controls.crafttabs		--Tell menu to update so recipe changes appear		if craftmenu then craftmenu:UpdateRecipes() end	endend--Add a post init callback to the game when this mod is loaded.--This will tell the game to run the function above after loading a saved game--but before handing control over to the player.--uncomment to try but comment out AddGamePostInit line above so only one or--the other method is used.AddSimPostInit(modSimPostInit)

Edited by WrathOf
added spoiler tags (via Threadmins and Group Moderators)

Looks fine....you can move the update code out of the if statements to do it once at the end though....

--Callback function to change the recipe for pan flutes at SimPostInit.--Use this version if need to access hud to force an update to the crafting menu.local function modSimPostInit( maincharacter )	local xrveleasyrecipe = nil	--Search for the recipe you want to change	xrveleasyrecipe = GLOBAL.GetRecipe("panflute")	--If find it then change it	if xrveleasyrecipe then		--Set the ingredients for a recipe to a new list		xrveleasyrecipe.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("cutgrass", 1),		}	end	--Search for the recipe you want to change	xrveleasyrecipe = GLOBAL.GetRecipe("meatrack")	--If find it then change it	if xrveleasyrecipe then		--Set the ingredients for a recipe to a new list		xrveleasyrecipe.ingredients = {			--Each ingredient is the internal name for it & the amount needed			GLOBAL.Ingredient("rope", 1),			GLOBAL.Ingredient("twigs", 1),		}	end	--Should not be necessary, but wanted to show how to do this just in case	--Get reference to crafting menu	local craftmenu = maincharacter.HUD.controls.crafttabs	--Tell menu to update so recipe changes appear	if craftmenu then craftmenu:UpdateRecipes() endend--Add a post init callback to the game when this mod is loaded.--This will tell the game to run the function above after loading a saved game--but before handing control over to the player.AddSimPostInit(modSimPostInit)

Ok added a new example mod for adding a placer prefab to an existing prefab, marble pillars in this case.I hope to get all the existing examples updated to using the new ModLib mod tommorow for proper Doorway update support.

[MENTION=10271]WrathOf[/MENTION], perhaps you could shed some of your limitless modding knowledge on this situation here?

I've managed to create a custom prefab (thanks to your amazing mod examples, which I couldn't have done without). Functionally it works perfectly fine, and after many tedious hours of raging at a screen I manged to fix my file-path issues for my custom image file with the crafting menu (as your examples only show how to create a structure rather than an inventory item).

However the item itself in the inventory (and on the ground, despite using a pre-existing .zip anim file) is invisible, and I've yet to figure out how to have it display the (or any) image.

Any advice would be greatly appreciated, else I just keep trying my method of breaking the game untill I figure out how everything fits together! :wilson_smile:

EDIT - I had not realized the 'modlib' shows how to do this.... *awks*

It now works! :D

Edited by DaS

[MENTION=20527]VirtualVampire[/MENTION]Not sure what you mean? The game files are in the data/scripts folder and are text files with the .lua extension which you can edit in Notepad or whatever plain text editor you prefer.You can install one or all of my example mods to get you started with a folder structure to copy files into and then experiment with them from there. Make sure you mods uses the same scripts/prefabs or whatever folder structure the game uses for the file you are changing and the game will generally try to use your version versus the standard one.

Oh I wrote mode instead mode, (-‸ლ) Im still a bit confused, I figure it out though. Thanks, quick youtube video would be nice if possible. Oh and by the way obey the Lord and Master, Foamy.

Hey is there anyway to change the amount of picking items? like flints or carrots or grasses for example i want to change amount of cutgrass a grass tuft give me from 1 to 3 how can i do it? i try use lootdropper comp but i think its for things they can drop items not pickable free items on ground?im getting mad xD

Hey is there anyway to change the amount of picking items? like flints or carrots or grasses for example i want to change amount of cutgrass a grass tuft give me from 1 to 3 how can i do it? i try use lootdropper comp but i think its for things they can drop items not pickable free items on ground?im getting mad xD

This will make you pickup 3 grass.
AddPrefabPostInit("grass", function (inst)		inst.components.pickable.numtoharvest = 3	end)
I can also show you how to get a random amount.

Note to everyone: This thread needs a massive update. The latest Cave update is changing how most of this works (and is making things easier), so keep this in mind when reading it.

Also, with the next update in a few days, ModLib is no longer needed. There are example mods included with the game files in your mod directory that explain the new procedures pretty well. Ask if you have any questions.

Noob Question:

I want my game to have 24 segment days instead of 16..why? i don't know...i just do (hello OCD)

The easy part was getting the day to be 24 "hours" long

---contents of modmain.lua local seg_time = 30 --seconds per segment local total_day_time = seg_time*24 --number of segments in a day --default: : 16 = 8 mins ..24 = 12mins --day phases -- settings are for summer daylocal day_segs = 12 	--default:  10local dusk_segs = 8 	--default:  4local night_segs = 4  	--default:  2---i split those with HFs dawn mode (<3 ) in mind where dusk = evening+dawn --->i find 12day-4dusk-4night-4dawn  to be a fair distribution for summer---TUNING.AUTOSAVE_INTERVAL = total_day_timeTUNING.SEG_TIME = seg_timeTUNING.TOTAL_DAY_TIME = total_day_timeTUNING.DAY_SEGS_DEFAULT = day_segsTUNING.DUSK_SEGS_DEFAULT = dusk_segsTUNING.NIGHT_SEGS_DEFAULT = night_segs---this doesn't look the most efficient way to do it, but ...monkey see, monkey do---

All that remained was defining my assets (which i did) .

---contents of modmain.luaAssets = {	Asset("IMAGE", MODROOT.."images/clock_hand_24.tex")	Asset("IMAGE", MODROOT.."images/clock_night_24.tex")	Asset("IMAGE", MODROOT.."images/clock_rim_24.tex")	Asset("IMAGE", MODROOT.."images/clock_wedge_24.tex")}

and "asking" the game to swap the original textures with the ones i provided.Which is where i am stuck.

I have taken a peak inside a few mods, but those that define new textures also come with added features that when trying to figure what is what, "if it weren't for my horse.." pops into mind and i have to stop or risk an aneurysm.

So...is there a way to do this through code (prefab??) rather than having to replace the original texture files?

Thanks in advance.

[e] upon further investigation i found that the textures i want to replace are referenced in hud.lua, but i am still missing the function that asks for the switch [e]

Edited by dw420

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
×
  • Create New...