#Game crashing while controlling a structure from lua

1 messages · Page 1 of 1 (latest)

graceful wind
#

I have attached a zip of my mod folder including errorlogs and the log file for my mod. The purpose of this mod is to spawn in a blueprint/structure and then control that creation with lua. The way I accomplish this is by having distance sensors plugged into servos and guns and then lua applies a force onto a block in front of that distance sensor. At the current moment the mod is programmed to catch the player's key presses and press the corresponding buttons inside the creation.

This works as expected, pressing qwerasdzxciop keys control the creation from outside a seat, the next step is to create a lua script that uses these controls to try to kill the player. The problem I am running into is after controlling the creation for a couple of seconds the game will crash and there is no error in the log.

Can someone please look into this and let me know what I can change to prevent the crashing?

Thank you

eternal tulip
#

did i quick look and i don't see any blatant issue, it's yelling about a couple things:
1: the structure rotation (you set it to "tm.vector3.Create(0, 0, 0)" but it's not the rotation, it's where the build should point, aka like this it doesn't know where to point)
2: the concave rigid body being too complex (the game should handle this fine tho)
3: "KeyCode not found by name. Name: PeriodPeriod" not a clue what this si about, your key callbacks look totally normal

i'd say at least fix 1, you could try removing concave spawning for 2, tho i doubt that's the issue

graceful wind
#

I changed the line spawning in the creation to
tm.players.SpawnStructure(0, "controllableStructure", "mechStructureId", mechPosition, tm.vector3.Create(1, 0, 0)) I think this is what you mean, but it didn't seem to change anything

I am not sure what concave rigidbody it is talking about. The map does not have any objects in it besides the player spawn point. Does SpawnStructure() get treated in a similar way to SpawnCustomObjectRigidbody()? Because I assumed it would use the same sort of code as when the player spawns in one of their builds.

I have also noticed that loading in this mod seems to break build mode. Even if I am not near the spawned in creation I seem to get locked in place after pressing b and I can't do anything.

I might try to create a more simple build and see if it still has the crashing issue

eternal tulip
#

line 304, you have a spawnobjectconcave, i assumed it was that... tho as said before it should be handled

#

the fix for 1 was what i meant, but honestly i was doubtful about it being the fix, unity is probably smart enough to assume no rotation (tho if it worked it would have been less annoying)

graceful wind
graceful wind
#

I have to wonder if maybe part of the problem has to do with calling some function every frame. Like either Exists() or AddForce() is causing problems when called repeatedly. I know unity doesn't like it when you add forces in the regular update, but that probably isn't the issue. Also I just had the idea that maybe there's a memory leak in something I'm doing somethere. Besides that, I guess it will have to wait until tommorow 🙂

eternal tulip
#

The function in the update shouldn't give issues, I have a couple mods doing that and they are relatively stable (let's ignore missile mod)

#

For example one that does something similar to what you are trying to make works fine... Worked... Not sure if it still works, Devs might have changed something

graceful wind
left raptor
eternal tulip
#

The one with enemies is not on the workshop, will send once home

#

The others you can find where sebi said, but except the missile mod (which is hell to go through) the other don't do much addforce or similar

eternal tulip
left raptor
eternal tulip
#

That's the other one

left raptor
#

custom missiles mod is steam\steamapps\workshop\content\585420\3084520196

graceful wind
#

Oh I meant what is @eternal tulip's name on Steam? I don't know how to find their mods to even download them in the first place

#

I found it by searching for missile mod, I'm a doofus

eternal tulip
graceful wind
eternal tulip
#

Thanks :)

graceful wind
#

Quick update: After looking at Jess's enemy mod I had the random idea to comment out all the code related to the debug ui labels I had showing the state of all the keyboard buttons. So lines 82-94 and 365-377 are all commented out now. I was able to control the structure for about ten minutes with no crashing. Maybe it would have crashed if I played with it longer, who can say, but for now it seems as though the crashing error is resolved and I continue working on this project.

My guess? Updating a ui label every update was causing the crash. But I'm sure someone will soon comment "actually I have a mod that updates a thousand ui labels and I have no problem!" In which case, idk bro, programming is weird sometimes lol

#

I wanted to make the reproduction of this bug as concise as possible so I made a main.lua with just the label related code. It takes probably about five minutes but I was able to get the game to crash with just this code. I don't see a log for this mod specifically but I will include a fresh copy of my error logs in case that has something useful.

Thanks again for the help!

upbeat fractal
upbeat fractal
#

had to do it for the camera menu in the missile mod, since that started adding a big delay to the mod, maybe its sth similar

eternal tulip
left raptor