Jump to content

Character Modding Questions.


Recommended Posts

So, I'm currently working on a mod for Reign of Giants and I want to ask people who know how to change up a character's gameplay.

The questions I'm asking are listed below:

  • How do I disable or remove certain items from the crafting tab?
  • How do I add in my own crafting tab and tab contents?
  • How do I add my own items?
Link to comment
Share on other sites

If you are a newcomer to modding for Don't Starve, I can really recommend that you start by looking through this post, to save you some hardships later, and maybe even keep it handy when you're first starting out.

For your two last points, look at this and then this. Same thread, but the last (fixed) version doesn't include creating the tab. This is how you'd do it in DST, and I think it's the same in DS, but I'm not sure. Pretty sure, though. You will need to learn how to work with textures for this one.

For your first point, I think the only way you can disable certain craftable items is like the code below. WARNING: Untested code!! Remember to put in actual recipe names, and put this in the fn() or postinit function for your character:

-- Make a list of the recipes you want to disable for your character.
-- You can put this line at the top of your character code, outside the fn() / postinit function.
local unwanted_recipes = { "RECIPE_NAME", "OTHER_RECIPE_NAME" }

-- This next part goes in the fn() / postinit function.
-- We listen for the event pushed by the builder-component whenever the techtree changes,
-- which happens whenever the character enters/exits the radius of a prototyper.
inst:ListenForEvent("techtreechange", function(inst, data)
	local builder = inst.components.builder
	local recipes = builder.recipes
	local remove_count = 0
	
	-- Run over all currently known recipes backwards (so we can remove while iterating).
	for i=#recipes,1,-1 do
		local v = recipes[i]
		-- Run over all unwanted recipes, and if the known recipe has the name of an unwanted recipe,
		-- we remove it from the table of known recipes, add 1 to remove_count, and go to the next known recipe.
		for i2, v2 in ipairs(unwanted_recipes) do
			if v == v2 then
				table.remove(recipes, i)
				remove_count = remove_count + 1
				break
			end
		end
	end
	-- We correct the count of known recipes.
	builder.recipe_count = builder.recipe_count - remove_count
end)

This code should btw work happily with my Long-range Research mod ;)

Link to comment
Share on other sites

6 hours ago, Ultroman said:

If you are a newcomer to modding for Don't Starve, I can really recommend that you start by looking through this post, to save you some hardships later, and maybe even keep it handy when you're first starting out.

For your two last points, look at this and then this. Same thread, but the last (fixed) version doesn't include creating the tab. This is how you'd do it in DST, and I think it's the same in DS, but I'm not sure. Pretty sure, though. You will need to learn how to work with textures for this one.

For your first point, I think the only way you can disable certain craftable items is like the code below. WARNING: Untested code!! Remember to put in actual recipe names, and put this in the fn() or postinit function for your character:


-- Make a list of the recipes you want to disable for your character.
-- You can put this line at the top of your character code, outside the fn() / postinit function.
local unwanted_recipes = { "RECIPE_NAME", "OTHER_RECIPE_NAME" }

-- This next part goes in the fn() / postinit function.
-- We listen for the event pushed by the builder-component whenever the techtree changes,
-- which happens whenever the character enters/exits the radius of a prototyper.
inst:ListenForEvent("techtreechange", function(inst, data)
	local builder = inst.components.builder
	local recipes = builder.recipes
	local remove_count = 0
	
	-- Run over all currently known recipes backwards (so we can remove while iterating).
	for i=#recipes,1,-1 do
		local v = recipes[i]
		-- Run over all unwanted recipes, and if the known recipe has the name of an unwanted recipe,
		-- we remove it from the table of known recipes, add 1 to remove_count, and go to the next known recipe.
		for i2, v2 in ipairs(unwanted_recipes) do
			if v == v2 then
				table.remove(recipes, i)
				remove_count = remove_count + 1
				break
			end
		end
	end
	-- We correct the count of known recipes.
	builder.recipe_count = builder.recipe_count - remove_count
end)

This code should btw work happily with my Long-range Research mod ;)

Um... I'm sorry it's just that I'm REALLY new to doing code like this. 
The main question is where do I put it?

Link to comment
Share on other sites

It all goes in your character's prefab file. It says where to put each part, in the comments in the code. Read all the comments I wrote. If you are unsure about something, please ask (but try some things out first, to see if you can get it working; figuring things out for yourself gives you a great feeling :) ).

If I were you (being as new to this as you seem to be hinting; correct me if I'm wrong), I would start by studying other mods. Simple ones, like the ones I link to in my newcomer-post (which is also full of good advice). When you get how they work, or at least have a good idea, start looking at character mods. They are easily some of the most difficult mods to make without introducing bugs. And when the mod is done, you have to know exactly how it works, in order to maintain it.

Link to comment
Share on other sites

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.

×
  • Create New...