Nycidian Posted November 3, 2013 Share Posted November 3, 2013 I'm currently trying to build a mod that auto populates a table of all the spawnable prefabs in the game but I can't seem to get a function working that will return a boolean value if the prefab is spawnable I based this off of the SpawnPrefabFromSim() function which seems to be able to check what I wantlocal function checkPrefab(prefab) if prefab == nil or prefab =="rubble" then return false end local inst = prefab.fn(TheSim) if inst ~= nil then return true else print( "Does not exist", name ) return false endendfor key,value in pairs(GLOBAL.Prefabs) do print(checkPrefab(value))endThis should return true or false as a list for each prefab but instead it crashes...data/scripts/components/named.lua:28: bad argument #1 to 'upper' (string expected, got nil)LUA ERROR stack traceback: =[C] in function 'upper'..data/scripts/components/named.lua(28,1) in function 'SetName'..data/scripts/prefabs/rubble.lua(72,1) in function 'common_fn'..data/scripts/prefabs/rubble.lua(81,1) in function 'fn'..data/../mods/n_tools/modmain.lua(402,1) in function 'checkPrefab'..data/../mods/n_tools/modmain.lua(428,1) in function 'wish'..data/../mods/n_tools/modmain.lua(557,1) in function 'onclick'..data/scripts/widgets/button.lua(37,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/screens/playerhud.lua(254,1) in function 'OnControl'..data/scripts/frontend.lua(105,1) in function 'OnControl'..data/scripts/input.lua(127,1) in function 'OnControl'..data/scripts/input.lua(301,1)Anyone have any suggestions? It would be much appreciated. Link to comment Share on other sites More sharing options...
Developer Cheerio Posted November 3, 2013 Developer Share Posted November 3, 2013 I'm currently trying to build a mod that auto populates a table of all the spawnable prefabs in the game but I can't seem to get a function working that will return a boolean value if the prefab is spawnable I based this off of the SpawnPrefabFromSim() function which seems to be able to check what I wantlocal function checkPrefab(prefab) if prefab == nil or prefab =="rubble" then return false end local inst = prefab.fn(TheSim) if inst ~= nil then return true else print( "Does not exist", name ) return false endendfor key,value in pairs(GLOBAL.Prefabs) do print(checkPrefab(value))endThis should return true or false as a list for each prefab but instead it crashes...data/scripts/components/named.lua:28: bad argument #1 to 'upper' (string expected, got nil)LUA ERROR stack traceback: =[C] in function 'upper'..data/scripts/components/named.lua(28,1) in function 'SetName'..data/scripts/prefabs/rubble.lua(72,1) in function 'common_fn'..data/scripts/prefabs/rubble.lua(81,1) in function 'fn'..data/../mods/n_tools/modmain.lua(402,1) in function 'checkPrefab'..data/../mods/n_tools/modmain.lua(428,1) in function 'wish'..data/../mods/n_tools/modmain.lua(557,1) in function 'onclick'..data/scripts/widgets/button.lua(37,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/widgets/widget.lua(112,1) in function 'OnControl'..data/scripts/screens/playerhud.lua(254,1) in function 'OnControl'..data/scripts/frontend.lua(105,1) in function 'OnControl'..data/scripts/input.lua(127,1) in function 'OnControl'..data/scripts/input.lua(301,1)Anyone have any suggestions? It would be much appreciated.Could you upload your whole mod for me to take a look? Link to comment Share on other sites More sharing options...
Nycidian Posted November 3, 2013 Author Share Posted November 3, 2013 Could you upload your whole mod for me to take a look? Here you go, n_tools_1.3_working.zip Edit: btw just noticed the or prefab =="rubble" in there, its not actually in the file that was something i was trying to fix the issue (it didn't work). Link to comment Share on other sites More sharing options...
Developer Cheerio Posted November 4, 2013 Developer Share Posted November 4, 2013 Here you go, n_tools_1.3_working.zip Edit: btw just noticed the or prefab =="rubble" in there, its not actually in the file that was something i was trying to fix the issue (it didn't work).The same error happens if you just try and spawn the prefab so I think you've just found a prefab that's actually broken and doesn't get used in the game. I think you'll just have to skip over it when iterating through the prefabs. Link to comment Share on other sites More sharing options...
Nycidian Posted November 4, 2013 Author Share Posted November 4, 2013 The same error happens if you just try and spawn the prefab so I think you've just found a prefab that's actually broken and doesn't get used in the game. I think you'll just have to skip over it when iterating through the prefabs.Before I reply let me say I appreciate the help. Alright I figured out that problem but ended up with another one which I again fixed and ended up with a final problem that I can't figure out here is the updated mod and the crash log. The game is completely crashing after successfully checking hundreds of prefabs I'm not sure why. n_tools_1.31_working.ziplog.txt Edit: NM, I figured out how to do it piece meal. Thanks for all of the help. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.