Noita
A Lesson In Every Nugget
520憨批猪 Nov 1, 2021 @ 1:01am
About Crash in Debugg Model
Every time I try to pick up gold in debugg model, game crashes and displays "message handler function ''iten_pickup" is not defined in lua script"
It doesn't seem to have any effect in normal games,but,it is really annoying


I attempt to annotate all the code in game/gold_pickup.lua to avoid crash , but it is of no use.
so i decide to avoid this by using ModTextFileSetConten() and ModTextFileGetContent() instead of ModLuaFileAppend
,,and,,magically? it works.

code is below
--ModLuaFileAppend("data/scripts/items/gold_pickup.lua" , "mods/ALIEN/game/gold_pickup.lua")

ModTextFileSetContent("data/scripts/items/gold_pickup.lua",ModTextFileGetContent("data/scripts/items/gold_pickup.lua").."\n"..ModTextFileGetContent( "mods/ALIEN/game/gold_pickup.lua"))

完结,撒花
< >
Showing 1-2 of 2 comments
Kriby  [developer] Nov 5, 2021 @ 12:43pm 
I have seen this issue too in debug mode. I tried your fix but the issue did not go away for me. I have tried to fix this in the past, and I took another look at it now, unfortunately I can't see exactly what the problem is. I brought this up on the Noita Discord server and got this response:
Originally posted by Archaeopteryx:
if you're editing the gold pickup script, you get that error
it's a harmless error to gameplay
Originally posted by Horscht:
those errors happen anytime scripts get appended to that are event callbacks, so anything other than script_source_file

It doesn't seem that they know of a way to avoid this warning when changing the gold_pickup script. I agree that it is very annoying :( If I find a fix that resolves the issue on my end I will update the mod. Thank you very much for reporting the issue and taking time to try to find a solution!
520憨批猪 Nov 16, 2021 @ 5:26am 
How odd,,.
It did work on my computer,with no other mod , both in Chinese and English。
Just avoid
ModLuaFileAppend("data/scripts/items/gold_pickup.lua" ,...)
and it wont crash

and I tried another two ways to solve ,it might help you

The first is still based on "ModTextFileSetContent" and "ModTextFileGetContent"
Just insert the contents of dofile under the vanilla dofile
and the contents of your method into the vanilla method

For Example
--start
function doinsert(str1, str2, pos)
return str1:sub(1,pos)..str2..str1:sub(pos+1)
end

local content=ModTextFileGetContent("data/scripts/items/gold_pickup.lua")

local doinsert=function(findpos_str,insertcontent)

local insertion_point = (string.find(content,findpos_str) and
string.find(content,findpos_str)-1)--insert before it
if insertion_point then
content doinsert(content,insertcontent,insertion_point)
else Print("no Position of "..findpos_str)
end

end

doinsert("local.pos_x, pos_y",PutYourMethodWithNoHandlerHere)
doinsert("function.item_pickup",PutYourDofileHere)

--end
But this way is cumbersome and not convenient to debug.



The other way is to create a loop to detect changes in money

local comp= EntityGetFirstComponent(player_entity,"VariableStorageComponent",YourCompTag)
lastcheck_money = tonumber(ComponentGetValueInt(comp, "value_string"))
edit_component(player_entity, "WalletComponent", function(comp, vars)
now_money = ComponentGetValueInt(comp, "money")
end)
xp_Gain= math.max(now_money-lastcheck_money,0)
AddPlayerXP(xp_Gain)
if (PlayerShouldLevelUp()) then
PerformLevelUp()
end

you don't need to do it every fram,
I myself tried do it every 30 frams and I didn't feel any laggings.
but this makes you gain xp when pick Gold powder and
reduce the number of XP acquired when using project modifier --Gold to Strength


In,the end。。Thanks for your reply!I love your mod very much。:steamhappy:
< >
Showing 1-2 of 2 comments
Per page: 1530 50