Module echofile

set of functions for echoing files to things.

Uses a slightly hacked up version of f-strings for interpolation/templating

Info:

  • Copyright: 2021 Damian Monogue,2016 Hisham Muhammad (https://github.com/hishamhm/f-strings/blob/master/LICENSE)
  • License: MIT, see LICENSE.lua
  • Author: Damian Monogue

Functions

f(str) Takes a string and performs interpolation Uses {} as the delimiter.
aechoFile(window, filename) reads the contents of a file, converts it to decho and then dechos it
aechoFilef(window, filename) reads the contents of a file and then cechos it
cechoFile(window, filename) reads the contents of a file and then cechos it
cechoFilef(window, filename) reads the contents of a file, interpolates it as per echofile.f and then cechos it
dechoFile(window, filename) reads the contents of a file and then dechos it
dechoFilef(window, filename) reads the contents of a file, interpolates it as per echofile.f and then dechos it
hechoFile(window, filename) reads the contents of a file and then hechos it
hechoFilef(window, filename) reads the contents of a file, interpolates it as per echofile.f and then hechos it
echoFile(window, filename) reads the contents of a file, interpolates it as per echofile.f and then echos it
echoFilef(window, filename) reads the contents of a file, interpolates it as per echofile.f and then echos it
patchGeyser() Adds c/d/h/echoFile functions to Geyser miniconsole and userwindow objects
installGlobal() Installs c/d/h/echoFile and f to the global namespace, and adds functions to Geyser


Functions

f(str)
Takes a string and performs interpolation Uses {} as the delimiter. Expressions will be evaluated

Parameters:

  • str string: The string to interpolate

Usage:

    echofile = require("MDK.echofile")
    echofile.f("{1+1}") -- returns "2"
    local x = 4
    echofile.f"4+3 = {x+3}" -- returns "4+3 = 7"
aechoFile(window, filename)
reads the contents of a file, converts it to decho and then dechos it

Parameters:

  • window string: Optional window to cecho to
  • filename string: Full path to file

See also:

Usage:

    local ec = require("MDK.echofile")
    local cechoFile,f = ec.cechoFile, ec.f
    cechoFile("C:/path/to/file") -- windows1
    cechoFile("C:\\path\\to\\file") -- windows2
    cechoFile("/path/to/file") -- Linux/MacOS
    cechoFile("aMiniConsole", f"{getMudletHomeDir()}/myPkgName/helpfile") -- cecho a file from your pkg to a miniconsole
aechoFilef(window, filename)
reads the contents of a file and then cechos it

Parameters:

  • window string: Optional window to cecho to
  • filename string: Full path to file

See also:

Usage:

    local ec = require("MDK.echofile")
    local cechoFile,f = ec.cechoFile, ec.f
    cechoFile("C:/path/to/file") -- windows1
    cechoFile("C:\\path\\to\\file") -- windows2
    cechoFile("/path/to/file") -- Linux/MacOS
    cechoFile("aMiniConsole", f"{getMudletHomeDir()}/myPkgName/helpfile") -- cecho a file from your pkg to a miniconsole
cechoFile(window, filename)
reads the contents of a file and then cechos it

Parameters:

  • window string: Optional window to cecho to
  • filename string: Full path to file

See also:

Usage:

    local ec = require("MDK.echofile")
    local cechoFile,f = ec.cechoFile, ec.f
    cechoFile("C:/path/to/file") -- windows1
    cechoFile("C:\\path\\to\\file") -- windows2
    cechoFile("/path/to/file") -- Linux/MacOS
    cechoFile("aMiniConsole", f"{getMudletHomeDir()}/myPkgName/helpfile") -- cecho a file from your pkg to a miniconsole
cechoFilef(window, filename)
reads the contents of a file, interpolates it as per echofile.f and then cechos it

Parameters:

  • window string: Optional window to cecho to
  • filename string: Full path to file

See also:

Usage:

    local ec = require("MDK.echofile")
    local cechoFile,f = ec.cechoFile, ec.f
    cechoFile("C:/path/to/file") -- windows1
    cechoFile("C:\\path\\to\\file") -- windows2
    cechoFile("/path/to/file") -- Linux/MacOS
    cechoFile("aMiniConsole", f"{getMudletHomeDir()}/myPkgName/helpfile") -- cecho a file from your pkg to a miniconsole
dechoFile(window, filename)
reads the contents of a file and then dechos it

Parameters:

  • window string: Optional window to decho to
  • filename string: Full path to file

See also:

dechoFilef(window, filename)
reads the contents of a file, interpolates it as per echofile.f and then dechos it

Parameters:

  • window string: Optional window to decho to
  • filename string: Full path to file

See also:

hechoFile(window, filename)
reads the contents of a file and then hechos it

Parameters:

  • window string: Optional window to hecho to
  • filename string: Full path to file

See also:

hechoFilef(window, filename)
reads the contents of a file, interpolates it as per echofile.f and then hechos it

Parameters:

  • window string: Optional window to hecho to
  • filename string: Full path to file

See also:

echoFile(window, filename)
reads the contents of a file, interpolates it as per echofile.f and then echos it

Parameters:

  • window string: Optional window to echo to
  • filename string: Full path to file

See also:

echoFilef(window, filename)
reads the contents of a file, interpolates it as per echofile.f and then echos it

Parameters:

  • window string: Optional window to echo to
  • filename string: Full path to file

See also:

patchGeyser()
Adds c/d/h/echoFile functions to Geyser miniconsole and userwindow objects

Usage:

    require("MDK.echofile").patchGeyser()
    myMC = Geyser.MiniConsole:new({name = "myMC"})
    myMC:cechoFile(f"{getMudletHomeDir()}/helpfile")
installGlobal()
Installs c/d/h/echoFile and f to the global namespace, and adds functions to Geyser

Usage:

    require("MDK.echofile").installGlobal()
    f"{1+2}" -- returns "2"
    dechoFile(f"{getMudletHomeDir()}/fileWithDechoLines.txt")
    -- reads contents of fileWithDechoLines.txt from profile directory
    -- and dechos them to the main console
generated by LDoc 1.4.6 Last updated 2021-08-31 18:42:52