Argonium Posted April 5, 2019 Share Posted April 5, 2019 (edited) I want to make books more customizable: Number of birds, tentacles, sanity loss, etc... I can't understand why code crashing and freezing my game Any help would be helpful. Thanks! AddPrefabPostInit("book_tentacles", function(inst) inst.components.book.onread = function(inst, reader) local pt = reader:GetPosition() local numtentacles = 3 reader.components.sanity:DoDelta(-TUNING.SANITY_HUGE) reader:StartThread(function() for k = 1, numtentacles do local theta = math.random() * 2 * PI local radius = math.random(3, 8) local result_offset = FindValidPositionByFan(theta, radius, 12, function(offset) local pos = pt + offset --NOTE: The first search includes invisible entities return #TheSim:FindEntities(pos.x, 0, pos.z, 1, nil, { "INLIMBO", "FX" }) <= 0 and TheWorld.Map:IsPassableAtPoint(pos:Get()) and TheWorld.Map:IsDeployPointClear(pos, nil, 1) end) if result_offset ~= nil then local x, z = pt.x + result_offset.x, pt.z + result_offset.z local tentacle = SpawnPrefab("tentacle") tentacle.Transform:SetPosition(x, 0, z) tentacle.sg:GoToState("attack_pre") --need a better effect SpawnPrefab("splash_ocean").Transform:SetPosition(x, 0, z) ShakeAllCameras(CAMERASHAKE.FULL, .2, .02, .25, reader, 40) end Sleep(.33) end end) return true end end) Edited April 5, 2019 by Vlad Undying Link to comment Share on other sites More sharing options...
Ultroman Posted April 6, 2019 Share Posted April 6, 2019 It would help immensely to see your crash logs. If you don't know where to find those, take a look at the debugging part of my newcomer post. Link to comment Share on other sites More sharing options...
Argonium Posted April 7, 2019 Author Share Posted April 7, 2019 The main problem its just freeze without crash Link to comment Share on other sites More sharing options...
Ultroman Posted April 7, 2019 Share Posted April 7, 2019 It should still leave an error in your logs. Is this all the code you have in your mod? Link to comment Share on other sites More sharing options...
Argonium Posted April 8, 2019 Author Share Posted April 8, 2019 Yep, in my modmain Just stuck with this forever, doing something will result in standing and sound bugs Link to comment Share on other sites More sharing options...
Ultroman Posted April 8, 2019 Share Posted April 8, 2019 Really weird. I don't see anything wrong in your code, and it passes the syntax checks...must be something inside the loop. Have you tried commenting out each section, starting from the bottom? Like, comment out camera shake, comment out spawning waves, comment out spawning of tentacles. comment out calculating result_offset...etc. to see what makes it stop? I can't think of anything else, if you don't see any errors in your log files. Link to comment 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