DROMED.CFG
can also be used.
LgScript reports a lot of status information to the monolog. These debugging messages can help you diagnose problems with your scripts. For instance, the print
statement displays its output on the monolog.
Enable the monolog by adding this line to your USER.CFG
1).
monolog monolog.txt
You may change the file name to whatever you like. More detailed instructions are provided with Public Scripts.
You can’t create new properties. So custom scripts use the Editor→Design Note property for parameters. Here’s how your Lua scripts can read the design note.
-- Save functions that will be used in this module local propsrv = lgs.PropertySrv local match = string.match local substr = string.sub local lc = string.lower -- Module begins here module"DesignNote" -- Parameter iterator local function iterparam(str) return function() local name, value, q -- Extract the name name, q, str = match(str, "%s*(%w+)%s*(=?)%s*(.*)") -- Nothing left to extract if not name then return nil end if q == '=' then -- There is a value q = substr(str,1,1) if (q == '"') or (q == "'") then -- Quoted string, local val str = substr(str,2) -- Loop the match to handle escaped quotes value = "" while true do val, str = match(str, "([^"..q.."]*)"..q.."(.*)") value = value..val if substr(val,-1) == '\\' then value = value..q else break end end else -- Unquoted string, ends at a quote or seperator value, str = match(str, "([^\"';]*)(.*)") end end -- Clean-up junk until the next parameter str = match(str, ".-;*(.*)") return name, value end end --[[ DesignNote.getparam(integer,string) -> string Returns the value of a parameter from the design note. System Shock 2 doesn't have the DesignNote property, so use "ObjList" instead. ]] function getparam(obj, param) if propsrv.Possessed(obj, "DesignNote") then local designnote = propsrv.Get(obj, "DesignNote") param = lc(param) for name, val in iterparam(designnote) do if lc(name) == param then return val end end end return nil end
If you save this in the lgscript
folder as designnote.lua
, then your script can use require"DesignNote". You then read the design note with DesignNote.getparam(script.objid,"my_param"). Remember to include the libraries in the lgscript
folder as well as the scripts in the scripts
folder with your fan-mission.
DROMED.CFG
can also be used.