This forum is locked and will eventually go offline. If you have feedback to share you can find us in our Discord channel "MythoLogic Interactive" https://discord.gg/nECKnbT7gk

Forum rules

IScriptStorage.TryGetStringArr() returns incorrect value when the array is empty between sessions

Here you can find all solved gameplay problems and bugs (beginning from Pre-Alpha 1.8.8).
Forum rules
By using the forum you agree to the following rules. For this forum you also need to follow these additional rules.
Locked
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

IScriptStorage.TryGetStringArr() returns incorrect value when the array is empty between sessions

Post by NearHuscarl » Wed Mar 11, 2020 3:45 pm

Store an empty array. Retrieved array is expected to be empty but have a single empty string element instead. Steps to reproduce:

- Open the Map Editor and paste this code

Code: Select all

public void OnStartup()
{
   Game.LocalStorage.SetItem("arr", new string[] {  });
}
- Restart and run this code instead

Code: Select all

public void OnStartup()
{
   string[] arr;
   Game.LocalStorage.TryGetItemStringArr("arr", out arr);
   Game.WriteToConsole(arr.Count().ToString()); // returns 1
}
NOTE: If I put it this way, it will work correctly

Code: Select all

public void OnStartup()
{
   Game.LocalStorage.SetItem("arr", new string[] {  });
   string[] arr;
   Game.LocalStorage.TryGetItemStringArr("arr", out arr);
   Game.WriteToConsole(arr.Count().ToString()); // returns 0
}
1 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1887
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 36

Post by Gurt » Sat Mar 21, 2020 5:52 pm

Fixed after v.1.3.4.
The saved local storage file for the script now has a way to store and read empty arrays.
0 x
Gurt

Locked