Jump to content

Adding function of Wickerbottom book crafting


Recommended Posts

Hello,

 

I tried make my own OC in DST, so I've done drawing and setting default status.

However, I want to give him a crafting tab of Wickerbottom(book) but I couldn't.

 

I added code

inst:AddTag("bookbuilder")

under the local common_postinit = function(inst) line and I also added

inst:AddComponent("reader")

under the local master_postinit = function(inst) line.
  

I could launch my character without any trouble, but there is no crafting tab with my character. How can I fix it?

 

If I just add any book to other categories(etc, magic) then I can craft it and read it but my mental and health status changed. Also, in this case, some of starting items gone...

 

I searched forum but cannot find the solution. Thanks to read.

Link to comment
Share on other sites

If you could provide your characters prefab file that would help identifing the problem because right now I just added the "bookbuilder" tag and the "reader" tag to a custom character and the crafting tab showed up.

  • Like 1
Link to comment
Share on other sites

 

54 minutes ago, IThatGuyI said:

If you could provide your characters prefab file that would help identifing the problem because right now I just added the "bookbuilder" tag and the "reader" tag to a custom character and the crafting tab showed up.

 

I tested it right now, (just added character.lua, without adding book recipe in the other tab) but still there is no book tab!

I added other perks a lot, so it could be something wrong with other script lines. 

 

here is my mod main and character lua file! Really thank you for assist.

 

urain.luamodmain.lua

 

Link to comment
Share on other sites

In your urain.lua file you've put the common_postinit function twice, one before the master_postinit and one after. The one before has the tag "bookbuilder" but the one after doesn't. I'm guessing the MakePlayerCharacter function uses the latest function so in your characters case it's only using the common_postinit that doesn't have the "bookbuilder" tag.

You can fix this by combing both of the common_postinit functions, like this for example:

local function common_postinit (inst)
	inst.MiniMapEntity:SetIcon("urain.tex")
  
  	inst:AddTag("bookbuilder")
  	inst:AddTag("reader")
  	inst:AddTag("urain")
  
  	inst:AddComponent("sanityaura")
  	inst.components.sanityaura.aurafn = checkaura
end

 

Also, 2 tips regarding your urain.lua file:

- The common_postinit doesn't need "return inst"

- And this part:

inst:ListenForEvent(
            "picksomething",
            function(inst, data)
                if(data and data.object and data.object.prefab=="sapling")
                then
                    if(inst and inst.components and inst.components.sanity)
                    then
                        inst.components.sanity:DoDelta(3)
                    end
                end
            end
        )

    inst:ListenForEvent(
            "picksomething",
            function(inst, data)
                if(data and data.object and data.object.prefab=="berrybush")
                then
                    if(inst and inst.components and inst.components.sanity)
                    then
                        inst.components.sanity:DoDelta(3)
                    end
                end
            end
        )

    inst:ListenForEvent(
            "picksomething",
            function(inst, data)
                if(data and data.object and data.object.prefab=="berrybush2")
                then
                    if(inst and inst.components and inst.components.sanity)
                    then
                        inst.components.sanity:DoDelta(3)
                    end
                end
            end
        )
-- And so on......

 

Is a bit much to the eye and I think it's better to use "or" instead of creating new Listeners. It could look like this:

inst:ListenForEvent("picksomething", function(inst, data)
	if data.object.prefab == "sapling" or data.object.prefab == "berrybush" or data.object.prefab == "berrybush2" or --[[And so on...--]] then
		if inst.components.sanity ~= nil then
			inst.components.sanity:DoDelta(3)
		end
	end
end)
  
-- And
  
inst:ListenForEvent("finishedwork", function(inst, data)
	if data.target.prefab == "butterfly" or data.object.prefab == "fireflies" or --[[And so on...--]] then
		if data.action ~= nil and data.action.id == "NET" then
			if inst.components.sanity ~= nil then
				inst.components.sanity:DoDelta(3)
			end
		end
	end
end)

 

  • Like 1
Link to comment
Share on other sites

36 minutes ago, IThatGuyI said:

In your urain.lua file you've put the common_postinit function twice, one before the master_postinit and one after. The one before has the tag "bookbuilder" but the one after doesn't. I'm guessing the MakePlayerCharacter function uses the latest function so in your characters case it's only using the common_postinit that doesn't have the "bookbuilder" tag.

You can fix this by combing both of the common_postinit functions, like this for example:


local function common_postinit (inst)
	inst.MiniMapEntity:SetIcon("urain.tex")
  
  	inst:AddTag("bookbuilder")
  	inst:AddTag("reader")
  	inst:AddTag("urain")
  
  	inst:AddComponent("sanityaura")
  	inst.components.sanityaura.aurafn = checkaura
end

 

Also, 2 tips regarding your urain.lua file:

- The common_postinit doesn't need "return inst"

- And this part:


inst:ListenForEvent(
            "picksomething",
            function(inst, data)
                if(data and data.object and data.object.prefab=="sapling")
                then
                    if(inst and inst.components and inst.components.sanity)
                    then
                        inst.components.sanity:DoDelta(3)
                    end
                end
            end
        )

    inst:ListenForEvent(
            "picksomething",
            function(inst, data)
                if(data and data.object and data.object.prefab=="berrybush")
                then
                    if(inst and inst.components and inst.components.sanity)
                    then
                        inst.components.sanity:DoDelta(3)
                    end
                end
            end
        )

    inst:ListenForEvent(
            "picksomething",
            function(inst, data)
                if(data and data.object and data.object.prefab=="berrybush2")
                then
                    if(inst and inst.components and inst.components.sanity)
                    then
                        inst.components.sanity:DoDelta(3)
                    end
                end
            end
        )
-- And so on......

 

Is a bit much to the eye and I think it's better to use "or" instead of creating new Listeners. It could look like this:


inst:ListenForEvent("picksomething", function(inst, data)
	if data.object.prefab == "sapling" or data.object.prefab == "berrybush" or data.object.prefab == "berrybush2" or --[[And so on...--]] then
		if inst.components.sanity ~= nil then
			inst.components.sanity:DoDelta(3)
		end
	end
end)
  
-- And
  
inst:ListenForEvent("finishedwork", function(inst, data)
	if data.target.prefab == "butterfly" or data.object.prefab == "fireflies" or --[[And so on...--]] then
		if data.action ~= nil and data.action.id == "NET" then
			if inst.components.sanity ~= nil then
				inst.components.sanity:DoDelta(3)
			end
		end
	end
end)

 

Really Thanks! It works! I can find the book tab with my character. ( I tried make neat with my scripts but it makes error. so I just fixed the book issue. < solved this issue too. Thanks a lot!)

Could you give me an any tip for the perk which drain sanity when character destroy the plant?I know Wormwood has this kind of perk but the mechanism seems bit more meticulous.

Can I use 

inst:ListenForEvent

for this case? 

Edited by Yienb
Link to comment
Share on other sites

27 minutes ago, Yienb said:

I tried make neat with my scripts but it makes error. so I just fixed the book issue.

Well, if it crashes send me a screenshot or a client_log.

And about the sanity penalty. I looked in the Wormwoods prefab file and it seems pretty complicated I admit. Although I think it's possible to use other methods to achieve the same effect.

inst:ListenForEvent is definitely possible but there might be better options. You're free to experiment.

  • Like 1
Link to comment
Share on other sites

17 minutes ago, IThatGuyI said:

Well, if it crashes send me a screenshot or a client_log.

And about the sanity penalty. I looked in the Wormwoods prefab file and it seems pretty complicated I admit. Although I think it's possible to use other methods to achieve the same effect.

inst:ListenForEvent is definitely possible but there might be better options. You're free to experiment.

I solved issue! There might be spelling error.

Hmm, better option. I suppose to try then. Thnks!

 

Can we make poisonous weapon in DST? I tried with this forum tip, but I couldn't apply it.

As I asked other, There is no poisonous weapon in DST, So I just wonder we can so do that or systemically it is impossible.

Actually, I think it is possible that I misunderstood abc.lua / Is that mean my custom item.lua? / should I attach the 

-- Deals poison damage on single target
            inst.components.weapon:SetOnAttack(poisonattack) -- Poison single target function being call

this line under the 

local function fn(Sim)

     local inst = CreateEntity()

?

Edited by Yienb
Link to comment
Share on other sites

Poisonable is a component used in Don't Starve Shipwrecked. It isn't in DST. You could probably implement it to DST with the right coding but that would be a lot of work I assume.

Edited by IThatGuyI
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

1 minute ago, IThatGuyI said:

Poisonable is a component used in Don't Starve Shipwrecked. It isn't in DST. You could probably implement it to DST with the right coding but that would be a lot of work I assume.

A right, super thankful answer! Every mysteries solved! I thought I've done something wrong...

I am not sure where are you on earth, but I will appreciate toward the direction where you are located!

Thanks a lot!

  • Like 1
Link to comment
Share on other sites

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
 Share

×
  • Create New...