Jump to content

Recommended Posts

Ok, on Wolfgang Classic, I've had to include the whole damn hats.lua file because I can't get this ONE line to work from the modmain:Hats.lua:

if owner:HasTag("player") then--owner.AnimState:Hide("HEAD") -- this keeps his head from dissappearing when wearing hatsend
What I'd LIKE to do:Modmain (with or without the 'if' statement):
function show_Head(inst)if owner:HasTag("player") thenowner.AnimState:Show("HEAD")endend---------------AddPrefabPostInit("hats", show_Head)
Of course the simplest approach won't work for me.I think it's another case of, hats.lua is loaded on start, then the modmain, but the modmain won't be effective if hats are swapped after load... Edited by tehMugwump

[MENTION=55]Ipsquiggle[/MENTION], in Test Tools, GetMouseWordPos now crashes the game. (used to spawn entities and objects with GetMouseWordPos).Test Tools >> commands.lua:55 - inst.Transform:SetPosition(TheInput:GetMouseWorldPos():Get())Here's the error from log:

..._starve/data/../mods/Test Tools/scripts/commands.lua:55: attempt to call method 'GetMouseWorldPos' (a nil value)LUA ERROR stack traceback:        C:/Program Files/Steam/steamapps/common/dont_starve/data/../mods/Test Tools/scripts/commands.lua(55,1) in function 'Spawn'        C:/Program Files/Steam/steamapps/common/dont_starve/data/../mods/Test Tools/scripts/components/testtoolcontroller.lua(126,1) in function 'fn'        C:/Program Files/Steam/steamapps/common/dont_starve/data/scripts/events.lua(46,1) in function 'HandleEvent'        C:/Program Files/Steam/steamapps/common/dont_starve/data/scripts/input.lua(96,1) in function 'OnKey'        C:/Program Files/Steam/steamapps/common/dont_starve/data/scripts/input.lua(223,1)C:/Program Files/Steam/steamapps/common/dont_starve/data/scripts/frontend.lua(257,1)	SCRIPT ERROR! Showing error screen
Something must have changed with 'GetMouseWorldPos' because Spawn(self.entityPrefab) still works with the other commands (inventory, food, etc) Edited by tehMugwump

Ok, on Wolfgang Classic, I've had to include the whole damn hats.lua file because I can't get this ONE line to work from the modmain:Hats.lua:

if owner:HasTag("player") then--owner.AnimState:Hide("HEAD") -- this keeps his head from dissappearing when wearing hatsend
Try this:
AddSimPostInit(function(inst)	if inst.prefab == "wolfgang" then		inst:ListenForEvent("equipped", function(inst, data)			if data.slot == GLOBAL.EQUIPSLOTS.HEAD then				inst.AnimState:Show("HEAD")			end		end)	endend)
I'm assuming you're still overriding the standard wolfgang prefab in your wolfgang classic mod. If not, change the name of the prefab accordingly. Edited by simplex

Try this:

AddSimPostInit(function(inst)	if inst.prefab == "wolfgang" then		inst:ListenForEvent("equipped", function(inst, data)			if data.slot == GLOBAL.EQUIPSLOTS.HEAD then				inst.AnimState:Show("HEAD")			end		end)	endend)
I'm assuming you're still overriding the standard wolfgang prefab in your wolfgang classic mod. If not, change the name of the prefab accordingly.
ooooo, thanks. I'll give it a go!

[MENTION=55]Ipsquiggle[/MENTION], in Test Tools, GetMouseWordPos now crashes the game. (used to spawn entities and objects with GetMouseWordPos).Test Tools >> commands.lua:55 - inst.Transform:SetPosition(TheInput:GetMouseWorldPos():Get())

TheInput:GetMouseWorldPos() no longer exists. Replacing it by TheInput:GetWorldPosition() should do it.---edit---Actually, TheInput:GetWorldPosition():Get() will give you the same as TheSim:GetPosition(), so you may prefer the latter (or not).---edit 2---I'm guessing this change was made so that naming conventions would fit conceptually with the PS4. Although I think TheInput:GetWorldPosition() should've been aliased to the old TheInput:GetMouseWorldPos() to preserve compatibility with older code, especially since that would've required a single line of code. Edited by simplex

No longer exists? Just like that? Sheesh.Thanks for looking into this [MENTION=44092]simplex[/MENTION]. Gives me a place to start!

TheInput:GetMouseWorldPos() no longer exists. Replacing it by TheInput:GetWorldPosition() should do it.---edit---Actually, TheInput:GetWorldPosition():Get() will give you the same as TheSim:GetPosition(), so you may prefer the latter (or not).---edit 2---I'm guessing this change was made so that naming conventions would fit conceptually with the PS4. Although I think TheInput:GetWorldPosition() should've been aliased to the old TheInput:GetMouseWorldPos() to preserve compatibility with older code, especially since that would've required a single line of code.

No longer exists? Just like that? Sheesh.Thanks for looking into this [MENTION=44092]simplex[/MENTION]. Gives me a place to start!

No problem. Replacing TheInput:GetMouseWorldPos() by TheInput:GetWorldPosition() really should be all you need, since TheInput:GetWorldPosition() works just like TheInput:GetMouseWorldPos() used to. And, in fact, that's what the new DebugSpawn() does!

Worked like a charm. Thanks again!

No problem. Replacing TheInput:GetMouseWorldPos() by TheInput:GetWorldPosition() really should be all you need, since TheInput:GetWorldPosition() works just like TheInput:GetMouseWorldPos() used to. And, in fact, that's what the new DebugSpawn() does!

One other thing that is now broke is 'Freebuild'.This no longer works and I have no clue what's changed with the new tech tree here either...
function Freebuild()	local inst = GetPlayer()		if inst then		if inst.components.builder.freebuildmode then			inst.components.builder.freebuildmode = false		else			inst.components.builder.freebuildmode = true		end		inst:PushEvent("techlevelchange")	endend

Worked like a charm. Thanks again!One other thing that is now broke is 'Freebuild'.This no longer works and I have no clue what's changed with the new tech tree here either...

function Freebuild()	local inst = GetPlayer()		if inst then		if inst.components.builder.freebuildmode then			inst.components.builder.freebuildmode = false		else			inst.components.builder.freebuildmode = true		end		inst:PushEvent("techlevelchange")	endend
The event's name has changed. Try replacing "techlevelchange" by "techtreechange".
  • Developer

Worked like a charm. Thanks again!One other thing that is now broke is 'Freebuild'.This no longer works and I have no clue what's changed with the new tech tree here either...

function Freebuild()    local inst = GetPlayer()        if inst then        if inst.components.builder.freebuildmode then            inst.components.builder.freebuildmode = false        else            inst.components.builder.freebuildmode = true        end        inst:PushEvent("techlevelchange")    endend
Whoops, sorry I've missed all this, between the broken notifications and the release business, I forgot to check this thread...I notice that in the development branch the event pushed is "unlockrecipe". Try that instead perhaps?

Whoops, sorry I've missed all this, between the broken notifications and the release business, I forgot to check this thread...I notice that in the development branch the event pushed is "unlockrecipe". Try that instead perhaps?

Both "unlockrecipe" and "techtreechange" should work, since in widgets/crafting.lua we have both the lines
self.inst:ListenForEvent("techtreechange", function(inst, data) self:UpdateRecipes() end, self.owner)
and
self.inst:ListenForEvent("unlockrecipe", function(inst, data) self:UpdateRecipes() end, self.owner)
Moreover, since that's the only place in the game code that makes use of both events, these approaches should have exactly the same effect. I just suggested "techtreechange" because it's a more direct analogue to the old "techlevelchange".

Thanks again [MENTION=44092]simplex[/MENTION]. Is this something I should have known? Were did you learn of these changes?

Since these changes are not really documented, it's perfectly understandable that you didn't know of them. I learned of them by reading the game code.

Jeez, just now want to update my character mods, I just start Don't starve and it instantly kick me out, then I download samplecharacter mod and see what is different, the bigportraits is the problem, I got it, start the game, and it works.Then I enable my character item mods, and it just kick me again, I just can't see / know what is error but I think it just the .tex again but what, then I download sample prefab, and I just don't know what is changed. Is there anybody already done this?

If you haven't yet, check out your log.txt file. It almost always points you to the trouble spot from a crash.

Jeez, just now want to update my character mods, I just start Don't starve and it instantly kick me out, then I download samplecharacter mod and see what is different, the bigportraits is the problem, I got it, start the game, and it works.Then I enable my character item mods, and it just kick me again, I just can't see / know what is error but I think it just the .tex again but what, then I download sample prefab, and I just don't know what is changed. Is there anybody already done this?

Hmmm, not working. It reads up to the listen event, but then nothing. (I get prints outs up to that point)Also, if I throw in 'inst.AnimState:Show("HEAD")' up front, Wolfgang's head shows on load, but as soon as I switch hats, it vanishes...

AddSimPostInit(function(inst)print "about to enter 'head' sim post init..."	if inst.prefab == "wolfgang" then	inst.AnimState:Show("HEAD") 	print "now IN 'head' sim post init..."		inst:ListenForEvent("equipped", function(inst, data)					if data.slot == GLOBAL.EQUIPSLOTS.HEAD then			print "now IN GLOBAL.EQUIPSLOTS.HEAD check..."				inst.AnimState:Show("HEAD")				print "head should be showing"			end		end)	endend)

Try this:

AddSimPostInit(function(inst)	if inst.prefab == "wolfgang" then		inst:ListenForEvent("equipped", function(inst, data)			if data.slot == GLOBAL.EQUIPSLOTS.HEAD then				inst.AnimState:Show("HEAD")			end		end)	endend)
I'm assuming you're still overriding the standard wolfgang prefab in your wolfgang classic mod. If not, change the name of the prefab accordingly.

Hmmm, not working. It reads up to the listen event, but then nothing. (I get prints outs up to that point)

Ouch, huge "duh!" moment for me. It's not the equipper that receives the "equipped" event, but the item that gets equipped. This should work:

AddComponentPostInit("equippable", function(Equippable, inst)	inst:ListenForEvent("equipped", function(inst, data)		if data.slot == GLOBAL.EQUIPSLOTS.HEAD and data.owner.prefab == "wolfgang" then			data.owner.AnimState:Show("HEAD")		end	end)end)

If you haven't yet, check out your log.txt file. It almost always points you to the trouble spot from a crash.

Thank you , [MENTION=10028]tehMugwump[/MENTION]I now can exactly know what is not working , thanks to you :)But now I got new problem-I have a custom recipetabs-I have a custom item in my custom recipetabs
E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(17,1)	error calling gamepostinit in mod BRSITEM: ...steamapps/common/dont_starve/data/scripts/recipe.lua:26: attempt to index field 'level' (a number value)LUA ERROR stack traceback:        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/recipe.lua(26,1) in function '_ctor'        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/class.lua(28,1) in function 'Recipe'        E:/Games/Steam/steamapps/common/dont_starve/data/../mods/BRSITEM/modmain.lua(148,1)        =(tail call) ?        =[C] in function 'xpcall'        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(15,1)        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(405,1) in function 'SetPostEnv'        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(562,1)
It seems there is a new way how to declare recipe ?So, How it works now?Thanks anyway :joyous: Edited by Lexicroft

Here you go. Look under 'Tech Trees'.

Thank you , [MENTION=10028]tehMugwump[/MENTION]

I now can exactly know what is not working , thanks to you :)

But now I got new problem

-I have a custom recipetabs

-I have a custom item in my custom recipetabs

E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(17,1)	error calling gamepostinit in mod BRSITEM: ...steamapps/common/dont_starve/data/scripts/recipe.lua:26: attempt to index field 'level' (a number value)LUA ERROR stack traceback:        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/recipe.lua(26,1) in function '_ctor'        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/class.lua(28,1) in function 'Recipe'        E:/Games/Steam/steamapps/common/dont_starve/data/../mods/BRSITEM/modmain.lua(148,1)        =(tail call) ?        =[C] in function 'xpcall'        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(15,1)        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mods.lua(405,1) in function 'SetPostEnv'        E:/Games/Steam/steamapps/common/dont_starve/data/scripts/mainfunctions.lua(562,1)
It seems there is a new way how to declare recipe ?

So, How it works now?

Thanks anyway :joyous:

How to remove recipe from recipe tab? Like I want to remove crock pot from recipe tab, so when the game starts there is no crock pot recipe.

I'm not sure you can remove a recipe, properly. But if not, you can hide it by attaching a filter to the crafting widget. In this scenario, a filter is just a function that will receive each recipe's name and return true or false. Check widgets/crafting.lua for details.

I'm not sure you can remove a recipe, properly. But if not, you can hide it by attaching a filter to the crafting widget. In this scenario, a filter is just a function that will receive each recipe's name and return true or false. Check widgets/crafting.lua for details.

There is some function in player_common.lua
        --give the default recipes        for k,v in pairs(Recipes) do            if v.level == 0 then				inst.components.builder:AddRecipe(v.name)			end        end
Maybe I could edit that with PrefabPostInit.

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