[Already In] ACS Get level name and level lump name

Moderator: GZDoom Developers

ACS Get level name and level lump name

Postby Nash » Thu Oct 08, 2015 1:03 pm

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
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ACS Get level name and level lump name

Postby KeksDose » Thu Oct 08, 2015 1:14 pm

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

Code: Select allExpand view
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
KeksDose
Praise Mima and the Moon
 
Joined: 06 Jul 2007

Re: ACS Get level name and level lump name

Postby Nash » Thu Oct 08, 2015 1:44 pm

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

Code: Select allExpand view

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 allExpand view
if (!StringCompare(lumpnameStrParam(s"TITLEMAP")))
 
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ACS Get level name and level lump name

Postby Gez » Thu Oct 08, 2015 2:13 pm

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.
Gez
 
 
 
Joined: 06 Jul 2007

Re: ACS Get level name and level lump name

Postby Nash » Thu Oct 08, 2015 2:29 pm

Yeah! Honestly it still confuses me to this day, I don't think I can fully wrap my head around it.
User avatar
Nash
 
 
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia
Github ID: nashmuhandes

Re: ACS Get level name and level lump name

Postby ibm5155 » Fri Oct 09, 2015 8:06 am

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
ibm5155
Just Spooky
 
Joined: 20 Jul 2011

Re: ACS Get level name and level lump name

Postby Xaser » Fri Oct 09, 2015 8:15 am

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
Xaser
anarchivist
 
 
 
Joined: 20 Jul 2003

Re: ACS Get level name and level lump name

Postby ibm5155 » Fri Oct 09, 2015 9:39 am

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:
User avatar
ibm5155
Just Spooky
 
Joined: 20 Jul 2011


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: MSN [Bot] and 2 guests