ACS Get level name and level lump name

Moderator: GZDoom Developers

User avatar
Nash
 
 
Posts: 17484
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

ACS Get level name and level lump name

Post by Nash »

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!
User avatar
KeksDose
 
 
Posts: 596
Joined: Thu Jul 05, 2007 6:13 pm
Location: my laboratory

Re: ACS Get level name and level lump name

Post by KeksDose »

strParam appears to be able to do what you are requesting, doesn't it?

Code: Select all

str nicename = strParam(n:PRINTNAME_LEVELNAME);
str lumpname = strParam(n:PRINTNAME_LEVEL);
This only goes for the active map, though. I'm guessing your request goes for any level number?
User avatar
Nash
 
 
Posts: 17484
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ACS Get level name and level lump name

Post by Nash »

Ah, didn't know that was already readable but... I can't get it to work!

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);
    }
}
 
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

if (!StringCompare(lumpname, StrParam(s: "TITLEMAP")))
 
Gez
 
 
Posts: 17937
Joined: Fri Jul 06, 2007 3:22 pm

Re: ACS Get level name and level lump name

Post by Gez »

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.
User avatar
Nash
 
 
Posts: 17484
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia

Re: ACS Get level name and level lump name

Post by Nash »

Yeah! Honestly it still confuses me to this day, I don't think I can fully wrap my head around it.
User avatar
ibm5155
Posts: 1268
Joined: Wed Jul 20, 2011 4:24 pm

Re: ACS Get level name and level lump name

Post by ibm5155 »

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"
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm

Re: ACS Get level name and level lump name

Post by Xaser »

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.
User avatar
ibm5155
Posts: 1268
Joined: Wed Jul 20, 2011 4:24 pm

Re: ACS Get level name and level lump name

Post by ibm5155 »

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 :geek:

Return to “Closed Feature Suggestions [GZDoom]”