[Help] Programmable Block

Reddit is extremely horrible when it comes to quotes and code. The best you can do is use alternative sites like www.pastebin.com to dump your code there and link the URL here.

First of all this code makes no sense: int skipTick = 0; int delayTicks = 0; if(++skipTick < skipTicks) { return; } skipTick = 0;

Because every time you run the code, the skipTick will be initialized with 0 again as it is a local variable and thus it exits the main function through the return-call.
You should use the variable as static variable instead to solve that issue. The same goes for many other variables like the List<string> HangarDoors, delayTime, delayTicks and the prefixes. It sure makes no difference with your current value of skipTicks as that is only 1 and 0+1 is no longer < 1. But for a reliably working code you should fix that.

Same goes for firstRun which shoul be a static variable aswell. As local variable it gets set to true every time you run the code.

As for line breaks, /n is sufficient but /r/n doesnt cause issues afaik. So it is up to you if you want to use a standard you are used to or if you want to keep it shorter.

This is also not needed:
Group = GridTerminalSystem.BlockGroups
You can use GridTerminalSystem.BlockGroups perfectly fine anywhere where you used Group instead. It makes not noticeable difference except readability.

You did not check if timer in your error handling for the first run, though you assume it to be present later on.
Also all the blocks are fetched every tick over and over again. In my optionion it would be best to store them as static variable and only search them when they are null. Also throw an exception if they are null after trying to search for them. That would replace your "firstRun" initialisation.

As for your actual coding problem ... it seems that you try to assume that Group[i].Blocks would be the number of blocks. Though actually it is a List<IMyTerminalBlock> to which you need to apply .Count aswell.
So you need if Group[i].Blocks.Count instead.

I hope that solves your issue, which actually should be just a display issue.
If not, then you might have wrong names and thats it.

/r/spaceengineers Thread