Record the levelnum of previous map?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)

Record the levelnum of previous map?

Postby Jaxxoon R » Wed Nov 22, 2017 4:15 pm

I'm trying to store the levelnum of the map the player warped from so I can return to it at a later date. I've put this down so far in an acs library:


Code: Select allExpand view
int thepreviousmapyouwarpedfrom;

int thepreviousmapxpos;
int thepreviousmapypos;
int thepreviousmapzpos;

Script "RingWarp" (VOID)
{
   Delay(8);
   FadeRange(255,230,200,0.0,255,255,255,1.0,35.0);
   thepreviousmapyouwarpedfrom = GetLevelInfo(LEVELINFO_LEVELNUM);
   Delay(35);
   Teleport_NewMap(100,0,0);
}

Script "ReturntoPreviousMap" (VOID)
{
   Teleport_NewMap(thepreviousmapyouwarpedfrom,0,0);
}


The issue is that the levelnum isn't properly stored, so the player is instead warped to The Earth Base every time.
User avatar
Jaxxoon R
 
Joined: 04 May 2014

Re: Record the levelnum of previous map?

Postby gwHero » Wed Nov 22, 2017 4:23 pm

Try giving the variable world scope:

Code: Select allExpand view
world int thepreviousmapyouwarpedfrom;
User avatar
gwHero
Be your own Siddhartha
 
Joined: 08 May 2017
Location: The Netherlands
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: Intel with Vulkan Support

Re: Record the levelnum of previous map?

Postby Graf Zahl » Thu Nov 23, 2017 1:30 am

It needs to be global scope. World scope is per hub and will get lost as well.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Record the levelnum of previous map?

Postby Jaxxoon R » Thu Nov 23, 2017 11:18 am

Thanks for the help! It's reassuring to know this can be done. Unfortunately, I've never set up this kind of variable before. The compiler is telling me I'm missing an "index in world variable declaration", does this mean I have to create an array for it to work?
User avatar
Jaxxoon R
 
Joined: 04 May 2014

Re: Record the levelnum of previous map?

Postby Blue Shadow » Thu Nov 23, 2017 11:39 am

Jaxxoon R wrote:Unfortunately, I've never set up this kind of variable before. The compiler is telling me I'm missing an "index in world variable declaration", does this mean I have to create an array for it to work?

Time to learn, then.
User avatar
Blue Shadow
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Record the levelnum of previous map?

Postby Jaxxoon R » Thu Nov 23, 2017 11:57 am

Huh, I spent about an hour searching the wiki yesterday and somehow didn't find that. Thanks for the help!
User avatar
Jaxxoon R
 
Joined: 04 May 2014

Re: Record the levelnum of previous map?

Postby Graf Zahl » Thu Nov 23, 2017 2:01 pm

You would have found that page with both 'world variables' or 'global variables'.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Record the levelnum of previous map?

Postby Jaxxoon R » Thu Nov 23, 2017 3:13 pm

I wouldn't be surprised if I was just dumb and didn't notice it then. Should stop modding late at night since it leads to silly mistakes like this.
User avatar
Jaxxoon R
 
Joined: 04 May 2014


Return to Scripting

Who is online

Users browsing this forum: Ninlhil and 1 guest