Firetron’s ObjectArray

3 989 Views 4 Comments 4 years ago
  • Creates and returns an ObjectArray Class instance. It has less operations than a normal array, but it can store objects instead of just simple types and still be able to save and load (using its own methods). Up to 9 fields/properties are supported on the objects, and you must provide their names.

    • This topic was modified 3 years, 8 months ago by Firetron. Reason: Expanded command description
    • This topic was modified 3 years, 8 months ago by Firetron. Reason: Added methods Concat and GetAllFieldLists
    • This topic was modified 3 years, 8 months ago by Firetron. Reason: Renamed field lists to value lists
    • This topic was modified 3 years, 8 months ago by Firetron. Reason: Fixed the immutable operations
    • This topic was modified 3 years, 3 months ago by Firetron. Reason: Removed tip addresses
    HaasScript Code
    Sign in or Register to download for free
    • #1220
      Firetron
      Basic
      Up
      0
      Down
      ::

      Fixed some major typos.

      • This reply was modified 3 years, 8 months ago by Firetron.
    • #1224
      Firetron
      Basic
      Up
      1
      Down
      ::

      Here’s a simple test to prove it works:

      local objectArray = CC_ObjectArray('name,age')
      objectArray.Load('savedObjectArray')
      
      function Main ()
      
        local count = objectArray.Count()
      
        local object = {
          age  = 20 + count,
          name = 'Guy '..count,
        }
      
        objectArray.Add(object)
      
        objectArray.Save('savedObjectArray')
      
      end
      
      OptimizedForInterval(60, Main)
      
      Finalize(function ()
      
        local another = CC_ObjectArray('name,age')
      
        local object = {
          age  = 19,
          name = 'Me',
        }
      
        another.Add(object)
      
        local all = objectArray.GetAllValueLists()
      
        Log(all.valueList1)
        Log(all.valueList2)
      
        another.Concat(objectArray)
      
        local count = another.Count()
      
        Log('Count is '..count)
      
        for i = 1, count do
      
          local object = another.Get(i)
      
          Log(' ')
      
          Log('Age is '..object.age)
      
          Log('Name is '..object.name)
      
        end
      
      end)
      
      • This reply was modified 3 years, 8 months ago by Firetron.
      • This reply was modified 3 years, 8 months ago by Firetron.
      • This reply was modified 3 years, 8 months ago by Firetron. Reason: Updated to test methods Concat and GetAllFieldLists
      • This reply was modified 3 years, 8 months ago by Firetron. Reason: Renamed field lists to value lists
    • #1246
      Daniel
      Basic
      Up
      0
      Down
      ::

      Thanks Firetron for your help and scripts here. Could you help me with my script and strategy? Thanks Daniel

    • #1249
      Firetron
      Basic
      Up
      0
      Down
      ::

      Discord is better suited for that discussion.

Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free