-
Notifications
You must be signed in to change notification settings - Fork 5
Extra Functionality
In addition to the exclamation mark (!) there is another symbol with special meaning in LuaPreprocess: the at sign (@). It's used as prefix for special preprocessor keywords that do different things.
@file
Inserts the path to the current file as a string literal.
print("Current file: "..@file)@insert name
This keyword inserts a resource as-is in-place before the metaprogram runs (the resource being a Lua string from somewhere).
By default, name is a path to a file to be inserted but this behavior can be changed by defining params.onInsert()
when calling processFile() or processString()
(or by handling the "insert" message in the message handler in the command line program).
-- script.lua
local one = 1
@insert "partialScript.lua"
print(one + two)
-- partialScript.lua
local two = !( 1+1 )The keyword can also appear in the metaprogram anywhere.
-- script.lua
!(
@insert "yellFunction.lua"
yell("aaargh")
)
local versionText = !( "Version: " .. @insert "appVersion.txt" )
print(versionText)
-- yellFunction.lua
local function yell(text)
print(text:upper().."!!!")
end
-- appVersion.txt
"1.2.3"@line
Inserts the current line number as an integer number literal.
print("Current line: "..@line)