Use ConfigParser library.

This commit is contained in:
Anna Rose 2025-02-08 21:04:28 -05:00
parent c75159f706
commit 9dcf923a49
2 changed files with 7 additions and 23 deletions

View File

@ -20,7 +20,11 @@ namespace IngameScript
{ {
_p = p; _p = p;
_hinge = hinge; _hinge = hinge;
parseConfig();
ConfigParser config = new ConfigParser(_hinge);
_openAngle = config.GetValue("OpenAngle", 90F);
_closedAngle = config.GetValue("ClosedAngle", 0F);
_velocity = config.GetValue("Velocity", 5F);
} }
// For these two functions, IMyMotorStator.Angle reports radians, but // For these two functions, IMyMotorStator.Angle reports radians, but
@ -52,28 +56,6 @@ namespace IngameScript
return Locked; return Locked;
} }
private void parseConfig()
{
string[] lines = _hinge.CustomData.Split('\n');
foreach (string line in lines)
{
string[] tokens = line.Split('=');
if (tokens.Length != 2) continue;
switch (tokens[0])
{
case "OpenAngle":
_openAngle = float.Parse(tokens[1]);
break;
case "ClosedAngle":
_closedAngle = float.Parse(tokens[1]);
break;
case "Velocity":
_velocity = float.Parse(tokens[1]);
break;
}
}
}
private float degToRad(float degrees) private float degToRad(float degrees)
{ {
return degrees * ((float)Math.PI / 180F); return degrees * ((float)Math.PI / 180F);

View File

@ -23,4 +23,6 @@
<AdditionalFiles Include="Instructions.readme" /> <AdditionalFiles Include="Instructions.readme" />
<AdditionalFiles Include="thumb.png" /> <AdditionalFiles Include="thumb.png" />
</ItemGroup> </ItemGroup>
<Import Project="..\Mixins\Console\Console.projitems" Label="shared" />
<Import Project="..\Mixins\ConfigParser\ConfigParser.projitems" Label="shared" />
</Project> </Project>