From 91fda180de67168455d7574384e811f10c18d48b Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 29 Oct 2017 10:06:52 +0200 Subject: [PATCH] Added Wads.FindLump() to ZScript https://forum.zdoom.org/viewtopic.php?t=57814 --- src/w_wad.cpp | 10 ++++++++++ wadsrc/static/zscript/base.txt | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 773cd6673..495a98db3 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -1086,6 +1086,16 @@ int FWadCollection::FindLump (const char *name, int *lastlump, bool anyns) return -1; } +DEFINE_ACTION_FUNCTION(_Wads, FindLump) +{ + PARAM_PROLOGUE; + PARAM_STRING(name); + PARAM_INT_DEF(startlump); + PARAM_INT_DEF(ns); + const bool isLumpValid = startlump >= 0 && startlump < Wads.GetNumLumps(); + ACTION_RETURN_INT(isLumpValid ? Wads.FindLump(name, &startlump, 0 != ns) : -1); +} + //========================================================================== // // W_FindLumpMulti diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 877c42b2b..97a4d65a2 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -631,7 +631,14 @@ struct Wads ns_firstskin, } + enum FindLumpNamespace + { + GlobalNamespace = 0, + AnyNamespace = 1, + } + native static int CheckNumForName(string name, int ns, int wadnum = -1, bool exact = false); + native static int FindLump(string name, int startlump = 0, FindLumpNamespace ns = GlobalNamespace); } struct TerrainDef native