Just ran into a situation where I need this. An ACS function that returns the level name, and the level lump name, as a string.
Currently hacking my way through this by assigning LevelNums to the levels in MAPINFO and just checking against that, but that won't work in the long run!
ACS Get level name and level lump name
Moderator: GZDoom Developers
-
-
- Posts: 17484
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
-
-
- Posts: 596
- Joined: Thu Jul 05, 2007 6:13 pm
- Location: my laboratory
Re: ACS Get level name and level lump name
strParam appears to be able to do what you are requesting, doesn't it?
This only goes for the active map, though. I'm guessing your request goes for any level number?
Code: Select all
str nicename = strParam(n:PRINTNAME_LEVELNAME);
str lumpname = strParam(n:PRINTNAME_LEVEL);
-
-
- Posts: 17484
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ACS Get level name and level lump name
Ah, didn't know that was already readable but... I can't get it to work!
EDIT: Nevermind, got it to work! Had to use a handy string compare function from ACSNet and change the condition to this:
Code: Select all
script "Script_StartGameInstance" Open
{
str lumpname = StrParam(n: PRINTNAME_LEVEL);
while (!GameInstanceCount)
{
if (lumpname != "TITLEMAP") // this condition is never met
{
ACS_NamedExecute("Script_WorldSetup", 0);
Delay(1); // wait 1 more tic to let the initialization complete
GameInstanceCount = 1;
}
Delay(1);
}
}
Code: Select all
if (!StringCompare(lumpname, StrParam(s: "TITLEMAP")))
-
-
- Posts: 17937
- Joined: Fri Jul 06, 2007 3:22 pm
Re: ACS Get level name and level lump name
The whole "strings are really integer indices to a string array" thing strikes again! I don't think any mathematical comparison of a StrParam with a constant would ever work as intended.
-
-
- Posts: 17484
- Joined: Mon Oct 27, 2003 12:07 am
- Location: Kuala Lumpur, Malaysia
Re: ACS Get level name and level lump name
Yeah! Honestly it still confuses me to this day, I don't think I can fully wrap my head around it.
-
- Posts: 1268
- Joined: Wed Jul 20, 2011 4:24 pm
Re: ACS Get level name and level lump name
the way zdoom string Works is really weird, a char atribute would be really welcome.
but from what I understand, is like each string is stored into a single global matrix pointer, so the given number will be just the position of the script on that vector
like
strings[0] = "YES";
strings[1] = "NO;
strings[2[] = "E1M1".
if I remember if you do something like x = string[0]+string[1], x would have the result "YESNO" and it would add a new pointer with the name "YESNO"
but from what I understand, is like each string is stored into a single global matrix pointer, so the given number will be just the position of the script on that vector
like
strings[0] = "YES";
strings[1] = "NO;
strings[2[] = "E1M1".
if I remember if you do something like x = string[0]+string[1], x would have the result "YESNO" and it would add a new pointer with the name "YESNO"
-
-
- Posts: 10774
- Joined: Sun Jul 20, 2003 12:15 pm
Re: ACS Get level name and level lump name
The issue is the opposite: Without use of StrParam, trying to do strings[0]+strings[1] in the example above would yield "E1M1", not "YESNO", because internally you're adding two integers together.
-
- Posts: 1268
- Joined: Wed Jul 20, 2011 4:24 pm
Re: ACS Get level name and level lump name
weird, I remember that doing that in skulltag would result in a yesno string, but if you subtract it, it would Always be " "
but, this is not skulltag
but, this is not skulltag
