From 2f45218f70dfeaba25bcbd91f076d4e80ee1fcdb Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 29 Oct 2017 10:07:17 +0200 Subject: [PATCH] Added Wads.ReadLump() to ZScript https://forum.zdoom.org/viewtopic.php?t=57814 --- src/w_wad.cpp | 8 ++++++++ wadsrc/static/zscript/base.txt | 1 + 2 files changed, 9 insertions(+) diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 495a98db3..2c8213828 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -1290,6 +1290,14 @@ FMemLump FWadCollection::ReadLump (int lump) return FMemLump(FString(ELumpNum(lump))); } +DEFINE_ACTION_FUNCTION(_Wads, ReadLump) +{ + PARAM_PROLOGUE; + PARAM_INT(lump); + const bool isLumpValid = lump >= 0 && lump < Wads.GetNumLumps(); + ACTION_RETURN_STRING(isLumpValid ? Wads.ReadLump(lump).GetString() : FString()); +} + //========================================================================== // // OpenLumpNum diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 97a4d65a2..9c429fb4d 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -639,6 +639,7 @@ struct Wads 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); + native static string ReadLump(int lump); } struct TerrainDef native