One of the big missing pieces to make the game truly playable (instead of just a prototype) is quest specific game logic.  Quests are defined by HeroScribe XML, which lacks quest text (including specific game rules).  Here’s an example of quest text from Quest 1 (from a PDF):


To allow custom maps, and to make the design cleaner, quest specific logic should be an extension to HeroScribe XML.  Luckily someone added a simple LuaMachine plugin for UE4 that makes it really easy to do this.  So I started integrating that.

For example, I have HQBase-01-TheTrial_US.xml which has a corresponding HQBase-01-TheTrial_US.lua.  At this point, there are no modifications to the XML file.  When the game opens quest foo.xml, it looks for an optional corresponding foo.lua.  Here is a simplified example:

local HeroScribeQuest = {}

function HeroScribeQuest.special_treasure(id)
    if (id == "LetterF") then
        quest_print("The weapons on this weapons rack are chipped, rusted, and broken.  There is nothing here that the Heroes would want.")
        return true
    return false

return HeroScribeQuest

special_treasure() is a callback from UE4, while print() is a call into UE4.  So this demonstrates two-way communication between UE4 and Lua.  If there’s no Lua file, no special_treasure() in the Lua file, or special_treasure() returns false, then the game draws a treasure card.

Typically when special_treasure() returns true, that means it also did something.  Typically that something is to display quest text using quest_print() which displays text using UMG.  And to give the hero an item (or gold).  For our first example, there is no item, so we just call quest_print():


special_treasure() takes argument id.  “LetterF” comes from standard HeroScribe XML test.xml.  When the game loads the XML, if it finds a letter in a room, it associates the room with that letter.  Then when a hero searches that room for treasure, the game passes that letter (eg “LetterF”) to special_treasure().  For testing, I used HeroScribe (Pem’s Fork) to add the letter F to the starting room:


This was all made possible (and easy) using the LuaMachine UE4 plugin.
> Contrary to the other Unreal Engine 4 Lua plugins, this one does not try to expose the Unreal Engine 4 api, but completely hides it exposing to the user/scripter only the features the developer decided to include (via Blueprints or C++).
> Currently Windows 64bit, Mac, Linux 64bit (both Runtime and Editor) , Android, iOS (Runtime only) are supported.
> Scripts can be cooked in the build or loaded at runtime from the filesystem

As described in the above quote, LuaMachine is exactly what I was looking for!