Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
I'm pretty sure I've seen someone post an example before, but I can't remember it, and searching the forums and the wiki didn't reveal anything... is this possible, or am I just imagining it? This is killing me! D:
(I am looking into creating conditions if the current map lump is "TITLEMAP", "MAP05", "CINEMAP", etc)
I think you can get the map number, but I don't think you can get the map name. That string isn't part of the compiled script, and therefore does not exist in ACS.
script SCRIPT_MAP_INIT(void) { if (mi_flags) terminate;
mi_mapname = "Demon's maw"; mi_flags |= MI_FLAG_NON0; // just to make sure it will always be true }
If you don't need any additional flags ever, you can use mi_flags as a plain boolean. The example above contains only boolean functionality. You call ACS_ExecuteWithResult(SCRIPT_MAP_INIT) from at least one script (in library) during the first tick, and you call at the beginning of all ENTER/OPEN scripts that depend on its values (during the first tick).
FDARI
Melbourne is actually pronounced Mel-Byn, as though it were a wizard.
Well, it seems there's no other way than to utilize a map's levelnum (I'll have to assign every map a levelnum) and just use what I have available from GetLevelInfo...
Warning: While integer equality (maplump == strIndex) guarantees string equality (because they're exactly the same value), the return value from strParam is never equal to any predefined string index. To compare strings reliably you will require a helper function (or you must put a lot of code somewhere).
function int str_equal(int str1, int str2) { if (str1 == str2) return true; // if you're unlikely to submit many equal integers you may skip this instruction, and always compare actual string data
int i = strlen(str1); if (i != strlen(str2)) return false;
while (i--) { if ( getChar(str1, i) != getChar(str2, i) ) return false; }
function int str_compare(int str1, int str2) { // 0: equal // >0: str1 sorts higher // <0: str2 sorts higher
int i, c, c2;
do { c = getChar(str1, i); c2 = getChar(str2, i); if (c != c2) return c - c2; i++; } while (c);
return 0; }
The above is untested but reasonably manageable code.
However, if you're only trying to identify the level, strings are not a shortcut. I'd just define/libdefine LEVEL_<name> <number> and check that. Much cheaper than the above hassle. Also, a bundle of defines can be used in a switch/case-statement as well as an if-statement.
...Like (very brief quasi-code)... switch (getLevelInfo....) { case LEVEL_COMPLEX: ... code ... break; case LEVEL_DEIMOS_PORT: ... code ... break; }
FDARI
Melbourne is actually pronounced Mel-Byn, as though it were a wizard.