Best way for script "ticking"?

Started by smoq2, February 03, 2015, 05:26:04 PM

Previous topic - Next topic

smoq2

What is the best way for a piece of code to run with each tick? I used this class:

    class MapComponent_AutoHaul : MapComponent
    {
public override void MapComponentOnGui()
        {
                 blah blah blah
         }
     }


But it seems to run only with newly created colonies. Any better suggestions?

skullywag

I dont know about best way but ive seen people spawn a hidden building on the map at gamestart and use the tick method on that...
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Wastelander

MapComponents have a  MapComponentTick() method. It ticks once per game tick.


smoq2

Thanks for the help!

Unfortunately, both of the methods ("hidden building" or MapComponent) work only with newly started colonies. I need something that will be compatible with old saves.

Rikiki

It is compatible if you follow the instructions provided in Haplo miscellaneous or Caveworld flora mod (read the "Compatibility" section).

smoq2

#6
Quote from: Rikiki on February 04, 2015, 08:23:12 AM
It is compatible if you follow the instructions provided in Haplo miscellaneous or Caveworld flora mod (read the "Compatibility" section).

Hah, yeah I thought as much that it's possible to edit a save file and force the script to run. That's not the most user-friendly solution though. As much as I know I can do it, I won't force or expect others to, thus I have to find some other method.

[EDIT]

I'm actually leaning towards the "Building" ticker from this tutorial. The problem with it, is that it doesn't seem to spawn on its own.