Is it possible to export the name of the map I am playing...

Discuss anything ZDoom-related that doesn't fall into one of the other categories.

Is it possible to export the name of the map I am playing...

Postby yum13241 » Tue Jun 22, 2021 10:14 am

Real title:Is it possible to export the name of the map I am playing to a CVar?

So, sometimes I play through a bunch of maps in a bot DM, then I forget the name of the map I was playing, then I have to keep using map commands to switch maps until I find one i don't remember, which is annoying. Is there a way to save the map name in a CVAR, then just be able to type out sv_lastmap or something like that, then type map <value from sv_lastmap goes here> dm?
yum13241
 
Joined: 10 May 2021
Discord: yum13241#8226
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)

Re: Is it possible to export the name of the map I am playin

Postby Caligari87 » Tue Jun 22, 2021 4:40 pm

Yep! A small ZScript mod can certainly do that.

Note this isn't tested and probably won't work as-is, but the concept should look something like:

CVARINFO
Code: Select allExpand view
server string sv_lastmap;

MAPINFO
Code: Select allExpand view
GameInfo { AddEventHandler = "SaveLastLevel"; }

ZSCRIPT
Code: Select allExpand view
class SaveLastLevel : EventHandler {
  override void WorldLoaded(worldevent e) {
    CVar lastmap = CVar.FindCVar('sv_lastmap');
    lastmap.SetString(level.MapName);
  }

  override void OnRegister() {
    CVar lastmap = CVar.FindCVar('sv_lastmap');
    console.printf("Last played map was ... "..lastmap.GetString());
  }
}

Having this mod autoloaded should automatically save the current map lump name into a cvar every time you load into a new map. Ideally, this shouldn't conflict with anything at all, so you could set it up and forget about it.

Of course, starting a new game would instantly overwrite your sv_lastmap cvar, so check it first if you want to know! :laff:

EDIT: Added an OnRegister() override that prints the last played map to the console when the event handler is registered, so if you do accidentally start a new game you can just check the console.

8-)
User avatar
Caligari87
I'm just here for the community
User Accounts Assistant
 
Joined: 26 Feb 2004
Location: Salt Lake City, Utah, USA
Discord: Caligari87#3089

Re: Is it possible to export the name of the map I am playin

Postby yum13241 » Mon Jul 26, 2021 9:26 am

Caligari87 wrote:Yep! A small ZScript mod can certainly do that.

Note this isn't tested and probably won't work as-is, but the concept should look something like:

CVARINFO
Code: Select allExpand view
server string sv_lastmap;

MAPINFO
Code: Select allExpand view
GameInfo { AddEventHandler = "SaveLastLevel"; }

ZSCRIPT
Code: Select allExpand view
class SaveLastLevel : EventHandler {
  override void WorldLoaded(worldevent e) {
    CVar lastmap = CVar.FindCVar('sv_lastmap');
    lastmap.SetString(level.MapName);
  }

  override void OnRegister() {
    CVar lastmap = CVar.FindCVar('sv_lastmap');
    console.printf("Last played map was ... "..lastmap.GetString());
  }
}

Having this mod autoloaded should automatically save the current map lump name into a cvar every time you load into a new map. Ideally, this shouldn't conflict with anything at all, so you could set it up and forget about it.

Of course, starting a new game would instantly overwrite your sv_lastmap cvar, so check it first if you want to know! :laff:

EDIT: Added an OnRegister() override that prints the last played map to the console when the event handler is registered, so if you do accidentally start a new game you can just check the console.

8-)



Doesn't work, as expected.

Spoiler:


How do I fix this? I have zero ZScript experience.
yum13241
 
Joined: 10 May 2021
Discord: yum13241#8226
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)

Re: Is it possible to export the name of the map I am playin

Postby m8f » Mon Jul 26, 2021 11:55 am

Add
Code: Select allExpand view
version 4.6
to the beginning of ZSCRIPT lump.
User avatar
m8f
dreamer
 
 
 
Joined: 29 Dec 2017
Location: Siberia (UTC+7)
Discord: m8f#0629
Github ID: mmaulwurff
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit

Re: Is it possible to export the name of the map I am playin

Postby yum13241 » Mon Jul 26, 2021 2:07 pm

m8f wrote:Add
Code: Select allExpand view
version 4.6
to the beginning of ZSCRIPT lump.


now it loads, but typing sv_lastmap says that it's value is " ".
yum13241
 
Joined: 10 May 2021
Discord: yum13241#8226
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: Intel (Modern GZDoom)


Return to General

Who is online

Users browsing this forum: No registered users and 4 guests