Warioman Posted July 25, 2023 Share Posted July 25, 2023 I was testing my music mod by following a youtube tutorial but now upon death and fading out it crashes with this error. I tried fiddling with dynamic music.lua but I just ended up breaking it more. Youtube keeps deleting my comments when I tried messaging the video's creator. Rev. 562556 WIN32_STEAM WARNING! [string "../mods/workshop-3008939982/scripts/compone..."]:197: attempt to index local 'player' (a nil value) LUA ERROR stack traceback: ../mods/workshop-3008939982/scripts/components/dynamic music.lua:197 in (upvalue) IsOnLunarIsland (Lua) <196-199> ../mods/workshop-3008939982/scripts/components/dynamicmusic.lua:238 in (upvalue) StartBusy (Lua) <219-271> ../mods/workshop-3008939982/scripts/components/dynamicmusic.lua:424 in (upvalue) StopDanger (Lua) <407-427> ../mods/workshop-3008939982/scripts/components/dynamicmusic.lua:709 in (upvalue) StopSoundEmitter (Lua) <707-721> ../mods/workshop-3008939982/scripts/components/dynamicmusic.lua:746 in (local) fn (Lua) <742-748> scripts/entityscript.lua:1152 in (method) PushEvent (Lua) <1139-1166> scripts/prefabs/player_common.lua:696 in (upvalue) Deactivate Player (Lua) <681-698> scripts/prefabs/player_common.lua:1084 in (method) OnRemoveEntity (Lua) <1041-1086> This error may have occurred due to a mod you have enabled! dynamicmusic.lua Link to comment https://forums.kleientertainment.com/forums/topic/149846-mod-help-creating-music-mod-game-crashes-after-death/ Share on other sites More sharing options...
Merkyrrie Posted July 26, 2023 Share Posted July 26, 2023 When it fades out, the player no longer exists (becoming a nil value) It crashes when the code gets to line 197 and tries to index the given player variable, which at this point is nil. It can't look at the components of a nil variable and therefore crashes. To prevent this, in the return statement in IsOnLunarIsland prepend 'player ~= nil and' to it return player ~= nil and player.components.areaaware ~= nil and player.components.areaaware:CurrentlyInTag("lunacyarea") Link to comment https://forums.kleientertainment.com/forums/topic/149846-mod-help-creating-music-mod-game-crashes-after-death/#findComment-1654410 Share on other sites More sharing options...
Warioman Posted July 26, 2023 Author Share Posted July 26, 2023 Thanks!!! That fixed the crashing but do I need to do the same for these functions? line 191: local function IsInRuins(player) return player.components.areaaware ~= nil and player.components.areaaware:CurrentlyInTag("Nightmare") line 562: local function IsInRuins(player) return player.components.areaaware ~= nil and player.components.areaaware:CurrentlyInTag("Nightmare") line 567: local function IsOnLunarIsland(player) return player.components.areaaware ~= nil and player.components.areaaware:CurrentlyInTag("lunacyarea") Link to comment https://forums.kleientertainment.com/forums/topic/149846-mod-help-creating-music-mod-game-crashes-after-death/#findComment-1654674 Share on other sites More sharing options...
Merkyrrie Posted July 27, 2023 Share Posted July 27, 2023 7 hours ago, Warioman said: Thanks!!! That fixed the crashing but do I need to do the same for these functions? line 191: local function IsInRuins(player) return player.components.areaaware ~= nil and player.components.areaaware:CurrentlyInTag("Nightmare") line 562: local function IsInRuins(player) return player.components.areaaware ~= nil and player.components.areaaware:CurrentlyInTag("Nightmare") line 567: local function IsOnLunarIsland(player) return player.components.areaaware ~= nil and player.components.areaaware:CurrentlyInTag("lunacyarea") Possibly, yes. It doesn't hurt anything to add the check for each to make sure it will catch that problem each time Link to comment https://forums.kleientertainment.com/forums/topic/149846-mod-help-creating-music-mod-game-crashes-after-death/#findComment-1654742 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now