Jump to content

Recommended Posts

Hello everyone!

 

I'm new to modding but have some coding experience, and I came across an issue I don't understand.

I am trying to add a component to several prefabs but it inexplicably seems to work with some but not with others. So in modmain.lua I put :

local function MakePrefabFixedSpring( prefab )
prefab:AddComponent( "spring" )
prefab.components.spring.springsound = "dontstarve/pig/PigKingHappy"
end
AddPrefabPostInit( "sapling", MakePrefabFixedSpring )

and I know this works, as I have an action that tests the presence of the component spring.

However, when I try 

local function MakePrefabFixedSpring( prefab )
prefab:AddComponent( "spring" )
prefab.components.spring.springsound = "dontstarve/pig/PigKingHappy"
end
AddPrefabPostInit( "pond", MakePrefabFixedSpring )

my action is absolutely ignored.

 

So where is my mistake?

Is simply pond the wrong name? if so, where can I find where all the right names are?

Can the pond not be target of a custom action? (I doubt that)

Am I missing something else entirely?

 

Thanks for any help

Link to comment
https://forums.kleientertainment.com/forums/topic/30786-adding-component-to-pond/
Share on other sites

It seems as if "pond" IS the wrong name. Usually this prefabpostinit needs the x in x.lua which has to be a file in scripts/prefabs so x is the 1. parameter in the function. When im searching for prefab names, i usually use the dont-starve wiki. http://dont-starve-game.wikia.com/wiki/Pond Theres the value "DebugSpawn", which you probably should know. DebugSpawn console command uses the prefab name, just like all lua scripts do.

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