Having a problem getting settings from a cfg file.
Posted: Wed May 31, 2017 5:54 am
I have a static housing package originally written by Bishop. I recently added a seetings.cfg file to it to allow some flexibility for a server admin. So I took the settings.inc file Austin created and changed it to read my cfg file. By the way, it's a simple little include file that is very handy if I can figure out what I am doing wrong 
The file reports the following error:
Here is the settings.inc file:
Here is my test line that calls the uses the GetSettingsCfgElem function call in settings.inc:
And finally here is the settings.cfg file:
I have placed the settings.cfg file in \pkg\systems\staticHousing\config. the script doesn't find the setting. I even tried placing the settings.cfg file in the main staticHousing directory and still no go. As an additional note I tested another package that uses the settings.inc file and it cannot read from the config file associated with that package either. Note it apparently finds the file but cannot read the elements because it doesn't report being unable to open the file .
If you can help with this I would appreciate it.
The file reports the following error:
Code: Select all
syslog [pkg/systems/statichousing/textcmd/gm/staticdeed2.ecl]: Error::SH_GetSettingsCfgElem() - Unable to find elem [PriceEditable] ->Element not foundCode: Select all
//$Id: settings.inc 373 2006-06-17 18:27:33Z austinheilman $
/*===============================================================
* Current Version
* SETTINGS.INC - v1.0
* Updated 9/27/2005 2:54PM
*
* -- Revision v1.0 --
* Austin:
* Created include file
===============================================================*/
use uo;
use os;
use cfgfile;
/*
* SH_GetSettingsCfgFile(engine_name)
*
* Purpose
* Reads in :staticHousing:config/settings.cfg
*
* Parameters
*
* Return value
* A config file reference.
*
*/
function SH_GetSettingsCfgFile()
UnloadConfigFile(":staticHousing:settings");
var cfg := ReadConfigFile(":staticHousing:settings");
if ( cfg.errortext )
SysLog("Error::SH_GetSettingsCfgFile() - Unable to open [:staticHousing:settings.cfg] ->"+cfg.errortext);
endif
return cfg;
endfunction
/*
* SH_GetSettingsCfgElem(elem_name, cfg_file)
*
* Purpose
* Retrieves an elem from a config file.
*
* Parameters
* elem_name: A string matching the elem name to be retrieved.
* cfg_file: Optional parameter - reference to a config already read in by SH_GetSettingsCfgFile()
*
* Return value
* A config file elem reference.
*
*/
function SH_GetSettingsCfgElem(elem_name, byref cfg_file:=0)
if ( !cfg_file )
cfg_file := SH_GetSettingsCfgFile();
endif
var elem := cfg_file[elem_name];
if ( elem.errortext )
SysLog("Error::SH_GetSettingsCfgElem() - Unable to find elem ["+elem_name+"] ->"+elem.errortext);
endif
return elem;
endfunction
Code: Select all
SendSysMessage(who, SH_GetSettingsCfgElem("PriceEditable"));Code: Select all
# $Id: settings.cfg 620 2006-07-08 17:14:41Z Yukiko $
#
#
Elem Settings
{
// The following three (3) settings apply to the staticDeed script
// PriceEditable
// 0 - The price per square for a house is not changeable.
// 1 - The price per square for a house is changeable.
PriceEditable 1
// SecuresEditable
// 0 - The number of secures for a house are not changeable.
// 1 - The number of secures for a house are changeable.
SecuresEditable 1
// LockDownsEditable
// 0 - The number of lockdowns for a house are not changeable.
// 1 - The number of lockdowns for a house are changeable.
LockDownsEditable 0
}
If you can help with this I would appreciate it.