PTR Changelog 2017-02-21


  • Dev Team

    This post describes changes on the Public Test Realm. Estimated launch date is February 27.

    • Renamed RawMemory.requestSegments to RawMemory.setActiveSegments.
    • Now you can set data of segments that are not active on this tick. Just put a new property to RawMemory.segments object, and it will be saved automatically. The 10 segments per tick limit is still in place.

      RawMemory.setActiveSegments([0,1]);
      // next tick
      console.log(RawMemory.segments[0]); // -> segment #0
      console.log(RawMemory.segments[1]); // -> segment #1
      console.log(RawMemory.segments[99]); // -> undefined
      RawMemory.segments[99] = "somedata";
      // next tick
      console.log(RawMemory.segments[99]); // -> undefined
      RawMemory.setActiveSegments([0,1,99]);
      // next tick
      console.log(RawMemory.segments[99]); // -> "somedata"
      
    • Added segments viewing/editing GUI to the Memory editor tab (and corresponding HTTP endpoints).



    Tell us what do you think about these upcoming changes in the comments below!


  • Culture

    Amazing change. This makes the overhead for saving memory segments a lot smaller. Thanks for the incredible change. this allows me to have less active memory segments while still saving the data when something alters!

     

    If people are interested, I'm currently implementing an open-source library which abstracts this data away:

    ScreepsSegmentedMemory

    There's currently no code yet, but there is a description of what it will do. (It's partially implemented now, but non-functional yet).



  • Tested... formatting fail:

    I had several cases to try, but this is definitely the most consistent behavior: you cannot touch more than 10 segments at all.

    Important points to document:

    • You can set data of segments that are not active on this tick only if you have activated less than 10 memory segments.
    • If you attempt to write to more than 10 memory segments your tick will terminate and the requested memory transaction will be lost.

    Possible bug:

    _.range(10,20).forEach(i => delete RawMemory.segments[i]); RawMemory.segments[20] = "data3";
    // > data3
    console.log(RawMemory.segments[19], RawMemory.segments[20])
    // > data undefined

    Observation: deleting a member of RawMemory.segments has no effect and will prevent error checking. Any resulting error conditions will silently fail. 

     
     


  • How does setting the value of segments affect the 10 segments per tick limit? Can you assign values to as many segments as you want, but only read 10? Or combined can you only set/read 10 segments total per tick?



  • Helam - you can only ever touch 10 segments. It looks like I have a comment here that is shadowbanned because I was trying to edit it too much.

    • You can set data of segments that are not active on this tick only if you have activated less than 10 memory segments.
    • If you attempt to write to more than 10 memory segments your tick will terminate and the requested memory transaction will be lost.
    • deleting a member of RawMemory.segments has no effect and will prevent error checking. Any resulting error conditions will silently fail.