Here's my EventHandler code that reads in the lump and sets variables from it:
Code: Select all
class LiveTuningHandler : EventHandler
{
const ENABLE_LIVE_TUNE = 1; // set to 0 before release
const LIVE_TUNE_FILE = "testlump.txt"; // this works
// const LIVE_TUNE_FILE = "tuning.txt"; // this doesn't, WTF?!
double liveValue0;
double liveValue1;
double liveValue2;
double liveValue3;
override void WorldTick()
{
if ( !ENABLE_LIVE_TUNE )
return;
String lumpData = Wads.ReadLump(Wads.FindLump(LIVE_TUNE_FILE));
// split lump data into lines (assume unix style line breaks)
Array<String> lines;
lumpData.Split(lines, "\n", TOK_KEEPEMPTY);
// bail if we don't have enough lines to read from
if ( lines.Size() < 9 )
{
Console.Printf("%i lines in %s, expected 9!", lines.Size(), LIVE_TUNE_FILE);
return;
}
// hard-code line #s to read from; this is dev-only anyway
liveValue0 = lines[2].ToDouble();
liveValue1 = lines[4].ToDouble();
liveValue2 = lines[6].ToDouble();
liveValue3 = lines[8].ToDouble();
Console.Printf("%f, %f, %f, %f", liveValue0, liveValue1, liveValue2, liveValue3);
}
}
Code: Select all
// live tuning file - edit very carefully!
// liveValue0:
0.00008
// liveValue1:
314.777777
// liveValue2:
0451
// liveValue3:
1337
I've noticed some other quirks with how data comes through the read operation, but none of them as reproducible as that.
Has anyone tried anything like this before, and/or encountered strange or broken behavior with Wads.ReadLump?