Space Engineers

Space Engineers

Taleden's Inventory Manager
Pitje 10 Jan, 2018 @ 9:10am
TIM Fixes and patches
Hi all,

it seems that unfortunately real life caught up with Taleden, so for now it falls to us, the community, to provide updates and fixes for common problems. This way, if somebody has a problem (usually in the comments), redirect them here.
Hopefully Taleden will have time again at some point, and maybe incorporate our work.

I hope this'll catch on and help some people. Feel free to ask questions!

Pitje

How this works
Let's say I have a new addition/fix. I'll post the old code next to the new code together with (approximate) line numbers and a few lines above and below the bit I changed. If you have your own additions, just post them below here. I'll try to incorporate them in here with your name.
All these patches will be sorted from bottom to top (!) so that linenumber should remain mostly correct when you apply them top to bottom.
Be carefull you don't miss any comma's, semicolons, quotes or brackets/braces etc. That said, copy-pasting might also give artefacts due to differences in line endings.

Script too complex/lagspikes
By [CB] Pitje
If TIM gives you Script too complex errors or lagspikes every time it runs, there are ways to fix it. The bottom line is that it's very expensive to split stacks and distribute them across multiple containers. So that's what you're aiming to avoid.
Trick 1) Give everything a priority, and use numbers like 100 and 1000 so that you can always put things in between later on. 2) Give things different priorities if they're dealing with the same items. So everything that takes steel plates should have a different priority. 3) Make sure there's enough space for all your items. Tag a LCD screen with [TIM DEBUG] to check this.
If you do this you'll probably end up with dedicated storage containers for all subtypes. So a container for iron ore, one for magnesium ore, a third one for iron ingots, etc. I've run this kind of setup with ~80 refineries, ~24 assemblers, and a LOT of storage containers without noticable issues.

No more timers
By [CB] Pitje

Old code, line ~1926:
public void Save() { } // Save() void Main(string argument) { // throttle interval if (numCalls > 0 & (sinceLast += Runtime.TimeSinceLastRun.TotalSeconds) < 0.5) return;

New code:
public void Save() { } // Save() void Main(string argument, UpdateType updateSource) { // throttle interval if (numCalls > 0 & (sinceLast += Runtime.TimeSinceLastRun.TotalSeconds) < 0.5) return;

Old code, line ~1882:
/* * MAIN */ public Program() { int ext; // parse stored data foreach (string line in Me.CustomData.Split(NEWLINE, REE)) {

New code:
/* * MAIN */ public Program() { int ext; Runtime.UpdateFrequency = UpdateFrequency.Update100; // parse stored data foreach (string line in Me.CustomData.Split(NEWLINE, REE)) {

Known issues:
You will no longer be able to pass arguments to TIM. Instead, you'll need to either hardcode them higher up in the script (line ~140), or do the following and put them in the Programmable Block's custom data field. The last solution was contributed by Gorea.

Old code, line ~1967
foreach (string arg in argument.Split(SPACE, REE)) {

New code
foreach (string arg in Me.CustomData.Split(NEWLINE, REE)) {

Old code, line ~2054
} else {

New code
} else if (arg.StartsWith("TIM_version", OIC)) { } else {

Canvas
By [CB] Pitje

Old code, line ~50:
/SteelPlate,150,40% /Superconductor,10,1% /Thrust,15,5%,,ThrustComponent GasContainerObject/ /HydrogenBottle

New code:
/SteelPlate,150,40% /Superconductor,10,1% /Thrust,15,5%,,ThrustComponent /Canvas,5,0.01% GasContainerObject/ /HydrogenBottle


Using Nanite Control Factory
By Sewer Rat

The length of the TIM script is almost maxed, I found a better solution for adding mods to the TIM script. I found the answer through experimenting.

Instead of using the standard TIM script, use this script and set your priority levels (the lower the whole number, the higher the priority 1-10)

Taleden's Inventory Manager Port Script

Example with quotas:
Nanite Control Factory [TIM Force:Component:P1:100]
Large Cargo Container [TIM Ammo:P10 Ingot:P10 Ore:P10 Component:P10 PhysicalGunObject:P10 Gas:P10]

* This example should automaticly enpty all items out of the storage of your Nanite Control Factory except for 100 of all components.
Last edited by Pitje; 13 Jan, 2018 @ 3:42am
< >
Showing 1-15 of 24 comments
Pitje 10 Jan, 2018 @ 9:12am 
I'm also hoping someone will be able to sticky this so we can reduce the clutter in the comments a bit.
In addition, if someone know how to integrate TIM with some common mods (I'm thinking nanitefactory and better ores/stones or something) please post it here; I'll put it up.
Pitje 10 Jan, 2018 @ 9:13am 
And I'll reserve a spot here in case we get a lot of contributions.
SewerRat5150 10 Jan, 2018 @ 11:47pm 
The length of the TIM script is almost maxed, I found a better solution for adding mods to the TIM script. I found the answer through experimenting.

Instead of using the standard TIM script, use this script and set your priority levels (the lower the whole number, the higher the priority 1-10)

Taleden's Inventory Manager Port Script

USING NANITE CONTROL FACTORY
Example with quotas:
Nanite Control Factory [TIM Force:Component:P1:100]
Large Cargo Container [TIM Ammo:P10 Ingot:P10 Ore:P10 Component:P10 PhysicalGunObject:P10 Gas:P10]

* This example should automaticly enpty all items out of the storage of your Nanite Control Factory except for 100 of all components.
Last edited by SewerRat5150; 10 Jan, 2018 @ 11:48pm
moon fangirl 12 Jan, 2018 @ 8:32am 
I was planning to make some changes and updates and possibly look at optimising a lot of the code. I have a program i've written that should remove the script length issue, allowing for us to write more code into it. My plan was to maybe set up a gist or full-on repo on GitHub and allow people to contribute to the script and be able to use the minimiser program.

An optimisation I was thinking to add was to remove the 'cycle' argument and do something similar to Automatic LCDs, which is to run every tick (or 10 or 100 which ever works best) and dynamically decide what and how much to run during that cycle, and if the instruction limit was getting to close put off the next cycles until the next run.

An example of the changes I have already done is the for loop at ~1967 where you replace
foreach (string arg in argument.Split(SPACE, REE)) {
with
foreach (string arg in Me.CustomData.Split(NEWLINE, REE)) {

and replace the code at ~2054
} else {
with
} else if (arg.StartsWith("TIM_version", OIC)) { } else {

These changes allow the run arguments to be added to the custom data instead, allowing them to be used.

If people think it's a good idea, I can set up a repo and add some guys from here as contributors to help manage. The minisier program can be found here[github.com] btw, and I plan to use a minimiser library to add proper name minimisation to the program, making the minimised code even smaller.
Last edited by moon fangirl; 12 Jan, 2018 @ 8:33am
Pitje 13 Jan, 2018 @ 3:47am 
@Sewer Rat: Thanks for your contribution :)
@Gorea: Thanks for your contribution, and excellent idea. Make it a full repo. I don't know C# myself, so I can't be the primary maintainer, but I'd be happy to help out. The optimisation you mentioned sounds amazing, and would solve a lot of problems. In addition, I would suggest moving the quota to the PB's custom data field, and remove all string formatting and LCD code from TIM; we should use e.g. Automatic LCDs 2 to display inventories instead. To top it off, it would free up some code space. Lastly, I would put off using minimisers to the last possible moment, it's yet another step in the dev cycle...
moon fangirl 13 Jan, 2018 @ 7:25am 
I'll set up the repo and post it here when done. I will work on some small optimisations initially, however I want to get to grips with the full code base first so it may take a little time for any major changes to happen.

As for the quota panels, that's a little easier said than done. It would mean that the custom data would be very cluttered with all the quotas, and I would like to not force a reliance on another script in order to use part of this one. Although, I would say that there are a lot of optimisations we can do currently, like move the quota definitions to the custom data of the LCD and forgo the complex parsing of the panel text. This means we can use a simpler parser and make the quota panels still work nicely.

That said, it wouldn't be a huge issue to use Automatic LCDs to display some things, since it would allow us to offload processing and code to a more dedicated script, however if we did this I would simplify the panel code and remove things like 'SPAN' so you can still use the panels without it, but then allow people to opt-into making TIM generate A-LCD commands to display on panels.

The problem with any quota panel changes, however, is that we should really allow for at least some support with the current version, so people can still use their quotas without having to re-write them all. I can think of 3 ways round this: firstly, we don't touch how qutoas are defined and parsed, just how LCDs are handled. Secondly, we could make it automatically convert from the old format to the new one (would require the version checking and could cause some issues). Lastly, I write a small web-app than allows you to paste in the old quotas and will output the new ones. (We can look at this in detail later)

Also, the minimisier stuff I mentioned since I was working on it anyway, and I've almost got TIM fully minimising properly (my parser seems to have a few slight issues with strings, but I'm working on it). So far, the minimiser library doesn't work with expression bodies (e.g. 'int f() => 1;') and has some issues with empty if statement blocks, however I can work around these (like not using expression bodies, shuffling if's etc.). This means that we can basically do minimisation from the get-go without much extra work.
moon fangirl 13 Jan, 2018 @ 11:05am 
For now I've done the changes in this discussion and I now have the item up on the workshop here. The repo is now up here[github.com] as well.

[CB]Pitje - if you have a GitHub account and you want to be added as a collaborator, I'll need you GitHub username
Kire Vien 8 May, 2018 @ 6:50am 
TIM keeps turning the conveyor off at the refineries and assemblers. how can i fix this
Last edited by Kire Vien; 8 May, 2018 @ 6:57am
FPC 8 May, 2018 @ 2:23pm 
This is intentional/working as intended. If you dont want TIM to touch them/manage them, Just leave out the TIM tag or add, if memory serves, something like {TIM EXEMPT]

TIM works in lieu of conveyor system. It will turn off reactor conveyor as well, and other managed blocks.
Kire Vien 10 May, 2018 @ 10:50am 
It is supposed to work with them, it keeps the ore and other things from getting prossed at the assemblies and refineries. As a result non of the millions of ores I mine are not being used
Last edited by Kire Vien; 10 May, 2018 @ 8:45pm
SewerRat5150 11 May, 2018 @ 3:30pm 
TIM will only place and pull from blocks that have storage capacity and have [TIM] in their name. Thus if you are putting all of your ore, ingots, components, ect. in a storage container and it does not have [TIM] in the name, then TIM will not touch it. Some of these questions are rudimentary, I would ask that before posting your questions in this chat, do a little homework and at least watch the two TIM Guides https://www.youtube.com/watch?v=htnJJ2SzvFE AND https://youtu.be/wKHZRqkY-ZE And READ https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=546909551 I am no expert when it comes to the TIM script, but I seem to be the only one answering these questions. The only difference between myself and those asking the questions is, I watched both videos and use the TIM Guide. I use the [TIM Force:object in my block naming (if needed if the block is from a mod), the priority setting, and Object Count.

Example:
Assembler [TIM AUTO]
Large Cargo Container [TIM Component:P8 Gas:P8 Ingot:P8 Ore:P8 PhysicalGunObject:P8]
Nanite Control Factory [TIM FORCE:Component:P8:100 Gas:0 Ingot:0 Ore:0 PhysicalGunObject:0]

This will empty the Nanite Control Factory of everything except 100 of every component and keep it at 100 components.
Last edited by SewerRat5150; 11 May, 2018 @ 4:00pm
HalberdGuard 21 Jun, 2018 @ 3:30pm 
Coming from complete inexperience: So I recently saw a defunct script that allowed antennas, sound blocks, and I think lights to react to cargo container fill levels. Adding that kind of functionality would be awesome, unless it simply won't fit of course. I have also looked more than once for a script that would allow actions (for example a timer block, or other blocks with actions) to be taken when certain amounts of items are reached. For me, I wanted to set up drones at automated mining outposts that would signal/launch/take other actions, when the outpost is close to capacity, low on ammo, or needs another resource such as uranium (although current designs use solar). Any chance?
Slimez 10 Jul, 2018 @ 6:08pm 
I also seem to be having problems with my refineries, and have spent 2 days going over everything, setting up tests, I have watched/read all three multiple times, I have checked the code, checked all tags, checked without other mods, it is not working
Slimez 10 Jul, 2018 @ 6:09pm 
Same problem as Kire vein, conveyors keep turning off
SewerRat5150 15 Jul, 2018 @ 1:06pm 
the conveyors are supposed to turn off, that is one of the ways that TIM controls inventory flow, and when it comes to inventory management, are you using the FORCE key word, as I have deminstraited in my examples?

If you missed it, you also will need the matrial, if you are using a modded resouce (Example: v2LiquidHydrogen or v2LiquidOxygen) in the inventory of one of your blocks that has storage capacity and is using the TIM tag, so TIM can recognize it. But that is also covered in the videos that I shared in a previous post.

And btw Slimez your comment about the conveyors turning off, was already responded to by:

Originally posted by FowlPlayChiken:
This is intentional/working as intended. If you dont want TIM to touch them/manage them, Just leave out the TIM tag or add, if memory serves, something like [TIM EXEMPT]

TIM works in lieu of conveyor system. It will turn off reactor conveyor as well, and other managed blocks.
Last edited by SewerRat5150; 15 Jul, 2018 @ 1:21pm
< >
Showing 1-15 of 24 comments
Per page: 1530 50