Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.

Commit 457af54

Browse files
committed
v1.0.1 - Minor Fix & Documentation
1 parent a2ad7e5 commit 457af54

4 files changed

Lines changed: 28 additions & 2 deletions

File tree

LethalDataAPI/LethalData.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public LethalData(string modName)
2323
public static void Save<T>(string key, T value)
2424
{
2525
string currentSave = Plugin.currentSave;
26+
if (string.IsNullOrEmpty(currentSave)) return;
2627
string _dir = Path.Combine(dir, currentSave + ".json");
2728

2829
Dictionary<string, object> currentData;
@@ -66,7 +67,7 @@ public static void Save<T>(string key, T value)
6667
return (T?)value;
6768
}
6869

69-
return (T?)(object)null;
70+
return default(T);
7071
}
7172
}
7273
}

LethalDataAPI/Plugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ void Awake()
2424
logger.LogWarning("LethalDataAPI Loaded!");
2525

2626
harmony.PatchAll(typeof(StartOfRoundPatch));
27+
28+
int test = LethalData.Load<int>("test");
2729
}
2830
}
2931
}

LethalDataAPI/PluginInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace LethalDataAPI
33
public class PluginInfo
44
{
55
public const string modName = "LethalDataAPI";
6-
public const string modVersion = "1.0.0";
6+
public const string modVersion = "1.0.1";
77
public const string modGUID = "Avocado.LethalDataAPI";
88
}
99
}

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# LethalDataAPI
2+
3+
### Important
4+
> You have to sync data yourself. It doesn't do it automatically.
5+
6+
### How To Use
7+
```csharp
8+
// This will prevent other mods data to be mixed in with your data.
9+
public static LethalData storage = new LethalData(modName);
10+
11+
private int exampleVariable
12+
13+
public void SaveData() {
14+
// Save(string key, T value)
15+
// The key has to be unique and it dosen't have to be the variable name.
16+
storage.Save("exampleVariable", exampleVariable);
17+
}
18+
19+
public void LoadData() {
20+
// Load<Type>(string key)
21+
exampleVariable = storage.Load<int>("exampleVariable");
22+
}
23+
```

0 commit comments

Comments
 (0)