Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

Important Warning for block (script) mods!

Discussion in 'Modding' started by rexxar, May 30, 2017.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. rexxar Senior Engineer

    Messages:
    1,530
    In the upcoming major update, many blocks have been optimized. In most cases, this means their NeedsUpdate flags get added and removed on the fly. If you are not using the new GameLogicComponent system, your mod can start showing strange behavior when update flags go missing with no warning.

    I strongly encourage everyone who hasn't to update to the new system. Here's an excerpt from the post announcing the new system, to help you with the changeover:

    MyGameLogicComponent:
    First off, there's been some changes to MyGameLogicComponent. This is the class you inherit when you want to attach a script to an entity. Some of you have noticed that blocks randomly stop updating. This is because we are slowly optimizing block logic. When a block no longer needs to run, it simply turns off updates. This has caused no end of headaches for modders, so we've brought you a solution.

    Code:
    [MyEntityComponentDescriptor(Type, params string[])]
    is no longer valid. VS will warn you, the game will warn you, and there's a big fat nasty warning in the game log. Mods using this attribute constructor will continue working as-is in the old system. That means that your script will slowly, silently just stop working. To update to the new system, simply change to this:
    Code:
    [MyEntityComponentDescriptor(Type, bool, params string[])]
    The middle parameter is for EntityUpdate. If you set it to true, your script will use the old system. That means your script will run at the same time as the block's game logic. Use this if your code is timing sensitive. But do keep in mind if the block stops updating, your script will also stop.

    If you set EntityUpdate to false, you get the new system, which is where all the fun happens. The new system updates your script completely separately from the container entity. This means that your timing can be off. The entity's Update10 method can run on frame 1, but your Update10 might not run until frame 9.

    Also if you set EntityUpdate false, the script's NeesUpdate flag is decoupled from the entity's. You must set MyGameLogicComponet.NeedsUpdate, or your script will never run. You can do this in your Init method, as that will still be called, or you can set it outside your class from a session component or something.

    Be wary of the NeedsUpdate property. In your script, Entity.NeedsUpdate is very different from this.NeedsUpdate. You MUST set NeedsUpdate on the GameLogicComponent object, not the Entity.

    You can set NeedsUpdate on the entity, but it will not affect your script.
     
    Last edited: May 30, 2017
    • Like Like x 6
    • Informative Informative x 1
  2. Kane Junior Engineer

    Messages:
    570
    Thank you for always keeping up with API changes like this to give modders a headstart.
     
  3. Wellstat Apprentice Engineer

    Messages:
    212
    Recently after the multithread update, my mod (Guidance Block) behaves strangely;

    Originally, it turns off the merge block to detach missile and launch to target, which works fine. Now it still does the same on screen, but when the missile impacts the target, the missile explodes on the launcher itself. Seems like the missile grid is both homing to target and still on the launcher at the same time (also, smoke that follows the missile thruster via WorldMatrix appears to stay on the launcher)

    Is there any new procedures to follow, flags i have to set, like SetDirty or stuff like that to indicatr i made changes to a block? Or this is just a bug?
     
Thread Status:
This last post in this thread was made more than 31 days old.