@Logan: That literally is exactly what Kzer-Za is doing right now, just formatted differently. The question was how NOT to do that ("how do I do separate a list of values from the logic?"). Please have something of value to contribute when posting.
@ Kzer-Za: There's a couple things you can do.
If you
know the texture names will be consistent (WOOD1, WOOD2, etc) you can compare just the first part of the string. This is the simplest option, but the least flexible if texture names aren't rigidly enforced.
Code: Select all
if (TextureName.left(4) ~== "WOOD") // Do stuff
If the names are NOT going to be consistent like that, the other way is to use an array and loop through it until finding a match. This is a slightly more complex but also a bit more flexible option, as the array can be easily modified in some central place instead of fiddling with the
if conditional, and can be easily re-used in multiple places without copy-pasting the entire list.
Code: Select all
array<string> TextureList;
TextureList.push("WOOD1");
TextureList.push("WOOD2");
TextureList.push("WOOD3");
for (int i=0; i<TextureList.size(); i++) {
if (TextureName ~== TextureList[i]) // do stuff
}
You can either fill in the array by hand, OR fill it in automatically from the TEXTURES lump using
FindLump and
ReadLump. The latter is the most complicated but also correspondingly most robust if implemented well.
Unfortunately I barely understand how to use lump reading myself, so I'm providing only a brief overview here. The gist of it is that the
FindLump returns a lump number as an integer if it exists and matches the name provided. You may need to iterate over names if multiple lumps have the same name. Then
ReadLump(lumpnumber) returns a string containing the entire text of the lump. You need to process this with [wiki]String[/wiki] functions, most likely using
string.Split() to build an array of lines or other tokens and extract the strings you want from that, into your texture name array.
