Skip to content

Commit

Permalink
Scripting|Definitions: Added "On setup" script to Map Info
Browse files Browse the repository at this point in the history
The "On setup" script will be executed after the map has been fully set up.
  • Loading branch information
skyjake committed Nov 11, 2020
1 parent f04eb68 commit 902bb02
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doomsday/apps/client/src/world/base/clientserverworld.cpp
Expand Up @@ -31,7 +31,9 @@
#include <de/Error>
#include <de/Log>
#include <de/Scheduler>
#include <de/Script>
#include <de/ScriptSystem>
#include <de/Process>
#include <de/Time>
#include <doomsday/doomsdayapp.h>
#include <doomsday/console/cmd.h>
Expand Down Expand Up @@ -680,6 +682,15 @@ DENG2_PIMPL(ClientServerWorld)
}
}

// Script to run after setup.
if (const String onSetupSrc = mapInfo.gets("onSetup"))
{
Script script(onSetupSrc);
Process proc;
proc.run(script);
proc.execute();
}

// Reset world time.
time = 0;

Expand Down
1 change: 1 addition & 0 deletions doomsday/apps/libdoomsday/src/defs/dedparser.cpp
Expand Up @@ -2082,6 +2082,7 @@ DENG2_PIMPL(DEDParser)
RV_FLT("Ambient light", (*mi)["ambient"])
RV_FLT("Gravity", (*mi)["gravity"])
RV_STR("Execute", (*mi)["execute"])
RV_STR("On setup", (*mi)["onSetup"]) // script function
RV_STR("Sky", (*mi)["skyId"])
RV_FLT("Sky height", sky["height"])
RV_FLT("Horizon offset", sky["horizonOffset"])
Expand Down
1 change: 1 addition & 0 deletions doomsday/apps/libdoomsday/src/defs/mapinfo.cpp
Expand Up @@ -48,6 +48,7 @@ void MapInfo::resetToDefaults()
def().addNumber("gravity", 1);
def().addText ("skyId", "");
def().addText ("execute", "");
def().addText ("onSetup", "");
def().addText (QStringLiteral("intermissionBg"), "");

QScopedPointer<Record> sky(new Record);
Expand Down

0 comments on commit 902bb02

Please sign in to comment.