nerofootball.blogg.se

Space engineers programmable block as timer bock
Space engineers programmable block as timer bock




  1. Space engineers programmable block as timer bock update#
  2. Space engineers programmable block as timer bock code#

Runtime.UpdateFrequency &= ~UpdateFrequency.Update1 Runtime.UpdateFrequency = UpdateFrequency.None Runtime.UpdateFrequency |= UpdateFrequency.Once Runtime.UpdateFrequency |= UpdateFrequency.Update100 Runtime.UpdateFrequency |= UpdateFrequency.Update10 Runtime.UpdateFrequency |= UpdateFrequency.Update1 If ((ut & (UpdateType.Terminal | UpdateType.Trigger)) > 0) If ((ut & (UpdateType.Update1 | UpdateType.Update10 | UpdateType.Update100)) > 0)Įcho("Before=" + ()) Void Main(string argument, UpdateType ut)

Space engineers programmable block as timer bock update#

That should cover everything you need to know about the new update system! I'm super excited to see what you guys can do with it! With these issues in mind, please be careful about how often you modify your update frequency. This means there will be 19 ticks between the first and second run of your script!Īdditionally, setting the update frequency brings with it some internal overhead associated with the load balancer (I'm working on resolving this!). Your script is number 11 on the list, so the update looks like this:Īfter this update, PB number 10 removes itself from the update queue, bumping you up to #10, so the next update span looks like this: For example, imagine there are 12 programmable blocks scheduled to update every 10th tick. The 10 and 100 tick updates are not guaranteed to be exactly 10 or 100 ticks! The update system includes a load distribution element, which attempts to spread updates out over the selected timespan. You can also use updateSource.HasFlag(UpdateType.Update1), but this function is several orders of magnitude slower than using bitwise operations, so it's best to avoid it in your scripts. If((updateSource & (UpdateType.Update1 | UpdateType.Update10)) != 0)

space engineers programmable block as timer bock

If((updateSource & UpdateType.Update100) != 0)

space engineers programmable block as timer bock

You need to use bitwise operations again. Since this enum can have multiple values, you can't do simple comparison with =. In this case, the update is batched, and updateSource will have all three flags in it, and the script will be run only once, instead of three times. That is, if your script is set to update on 1, 10, and 100, there's a chance all three can run at the same time. This is because all the self-update sources are batched. Note that UpdateType is a Flags enum, meaning it can have multiple flags in one value. Like the string argument, this is optional and can be omitted (however, you cannot omit the string argument and have only the updateSource argument). / Script is updating once before the tick. / Script run by another programmable block. / Script run by antenna receiving a message. / Script run by a block such as timer, sensor. / Enum describes what source triggered the script to run. The updateSource argument will tell you *how* the script is being run. There's now a new argument on the Main method.

space engineers programmable block as timer bock

Space engineers programmable block as timer bock code#

This is useful when you want a one-shot update on the next tick, like initialization code or a function that should only run when triggered by an outside event. After this update, the Once flag is removed. This is a special flag which schedules your script for one bonus update on the next game tick. Of course, you can also do straight assignment as in the example constructor, if you want to completely overwrite the value, for instance if you want to stop all updating, you can assign Runtime.UpdateFrequency = UpdateFrequency.None which will remove all flags, and stop any future updating.Īlso of note is the UpdateFrequency.Once value. That should cover the basics of adding and removing flags from an enum. Runtime.UpdateFrequency &= ~UpdateFrequency.Update10 Runtime.UpdateFrequency |= UpdateFrequency.Update100 Runtime.UpdateFrequency = UpdateFrequency.Update1 | UpdateFrequency.Update10






Space engineers programmable block as timer bock