Jump to content

Recommended Posts

So in my mod Uncraftable Craftables I was thinking of updating it when I thought of an idea that you could backwash your items to there original state I was thinking of a new wigdet like in Handy-Crockpot but I am not that good with modmain codingAny help I would thank for! I'm looking at you [MENTION=10271]WrathOf[/MENTION] or [MENTION=3814]Starvation[/MENTION]

I am not sure I understand what you are looking for.I can help you with making a new crafting menu tab to organize your recipes but they seemed ok to me with the way you are doing now too.Are you also wanting to support hammering the crafted items back resources?EDIT:From your post above, so you want the build button on the crafting menu to create more than 1 of the item? Not sure there is a viable way to do that without getting messy.

[MENTION=12700]Heavenfall[/MENTION] No it's just I'm trying to make so you can get 2 more items when you craft but I can't seem to find the codeEDIT: Sorry didn't read it right but I'm looking in the builder component but I have no clue where I start?

Edited by Alpaca's, Starving

The walls recipe creates a stack of wall items that have a delpoy component to allow you to place them. So I guess you would need to create "_item" prefabs in a similar fashion. Everything you need should be in the walls.lua but they got a bit fancy in the way they structured the code to handle multiple types of walls in one file. You do not need to go that far though. [MENTION=3814]Starvation[/MENTION]No worries, this beyond your experience....not sure why he looped you in on this. :D

Sorry [MENTION=3814]Starvation[/MENTION] that was just for the crockpot type of thing with the recipe wigdet but I've figured that out [MENTION=10271]WrathOf[/MENTION] I'll give it another shot wish me luck!EDIT: Still needing asistance [MENTION=10271]WrathOf[/MENTION] I'm not sure what you mean by "_item" prefab and all the rest

Edited by Alpaca's, Starving

Alright let me explain this as clear as possibleAs when crafting Walls they give you multiple walls [4] So I was wondering where the code for getting multiple walls when crafting isHope that easy for you to understand [MENTION=10271]WrathOf[/MENTION] :biggrin-new:

In walls.lua at the end of the file they define a table which says...{name = "stone", loot = "rocks", maxloots = 2, stacksize = 6, ....That is used by the MakeWallType function to create 3 prefabs, a wall, a wall_item and a wall_placer.In the itemfn function used to create the wall_item prefab, it sets the stacksize as specified (6 in the stone wall case)....inst:AddComponent("stackable")inst.components.stackable.maxsize = TUNING.STACK_SIZE_MEDITEMinst.components.stackable.stacksize = data.stacksizeand then added a deployable component so that when you click a wall_item in your inventory, you can place a wall prefab.....inst:AddComponent("deployable")inst.components.deployable.ondeploy = ondeploywallinst.components.deployable.test = test_wallinst.components.deployable.min_spacing = 0inst.components.deployable.placer = "wall_"..data.name.."_placer"all of which I am sure if clear as mud.... :SI think I will just have to setup one as an example since it is hard to explain all the steps involved....so what prefab are you most interested in?

Ok so in that case, you should only need to add the workable component to the refined item's prefab in a PrefabPostInit....

inst:AddComponent("workable")inst.components.workable:SetWorkAction(ACTIONS.HAMMER)inst.components.workable:SetWorkLeft(2)inst.components.workable:SetOnFinishCallback(onhammered)inst.components.workable:SetOnWorkCallback(onhit) 
and define the onhammered and onhit functions to assign to it....
local function onhammered(inst, worker)	inst.components.lootdropper:DropLoot()	SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())	inst.SoundEmitter:PlaySound("dontstarve/common/destroy_?????")    --change to appropriate sound		inst:Remove()endlocal function onhit(inst, worker)	inst.AnimState:PlayAnimation("hit")end
where the sound can be "..../destroy_wood", "..../destroy_metal", "..../destroy_stone" or "..../destroy_straw"

[MENTION=12388]Alpaca's, Starving[/MENTION]Ok try this out as an example for the wood boards....

local function onhammered_general(inst, worker)	if inst.components.stackable then		for i=1, inst.components.stackable:StackSize() do			inst.components.lootdropper:DropLoot()		end	end	GLOBAL.SpawnPrefab("collapse_small").Transform:SetPosition(inst.Transform:GetWorldPosition())	inst.SoundEmitter:PlaySound(inst.sounds_hammered)	inst:Remove()endlocal function onhit_general(inst, worker)	--inst.AnimState:PlayAnimation("hit")endlocal function MakeDeconstructable(inst)	--Make sure have workable component	if not inst.components.workable then		inst:AddComponent("workable")	end	inst.components.workable:SetWorkAction(GLOBAL.ACTIONS.HAMMER)	inst.components.workable:SetWorkLeft(2)	inst.components.workable:SetOnFinishCallback(onhammered_general)	inst.components.workable:SetOnWorkCallback(onhit_general)	--Make sure have loot dropper which defaults to using recipe	if not inst.components.lootdropper then		inst:AddComponent("lootdropper")	end	if not inst.SoundEmitter then		inst.entity:AddSoundEmitter()	endendlocal function woodPrefabPostInit(inst)	--Call generic function to add workable component	MakeDeconstructable(inst)		--Create custom inst variable for specifying the sound to use	inst.sounds_hammered = "dontstarve/common/destroy_wood"endAddPrefabPostInit("boards", woodPrefabPostInit)

You can reduce the amount of hits to 1 with...inst.components.workable:SetWorkLeft(1)as for doing this from the crafting menu...no idea other than creating a new deconstruction menu based off of the crafting menu code...not something I am interested in taking on at the moment.

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...