summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2017-11-10 08:48:53 -0600
committer cracyc <cracyc@users.noreply.github.com>2017-11-10 08:48:53 -0600
commitec2685c66c1553be6835f06fc8f093261fb0a2c6 (patch)
treed13a2e2990669421c2acca54664a9e69dde38f1e
parent7741c94805a0bf1254103dcdcfdcdd5e91e2b87d (diff)
plugins/hiscore: add option to hiscore.ini to only_save_at_exit (nw)
-rw-r--r--plugins/hiscore/init.lua11
-rw-r--r--src/frontend/mame/luaengine.cpp8
2 files changed, 11 insertions, 8 deletions
diff --git a/plugins/hiscore/init.lua b/plugins/hiscore/init.lua
index cc3677a6d50..df998d70a7c 100644
--- a/plugins/hiscore/init.lua
+++ b/plugins/hiscore/init.lua
@@ -32,11 +32,12 @@ function hiscore.startplugin()
local scores_have_been_read = false;
local mem_check_passed = false;
local found_hiscore_entry = false;
+ local timed_save = true;
local positions = {};
-- Configuration file will be searched in the first path defined
-- in mame inipath option.
- local function read_config()
+ local function read_config()
if config_read then return true end;
local file = io.open( config_path, "r" );
if file then
@@ -45,9 +46,11 @@ function hiscore.startplugin()
local _conf = {}
for line in io.lines(config_path) do
token, value = string.match(line, '([^ ]+) ([^ ]+)');
- _conf[token] = lfs.env_replace(value);
+ _conf[token] = value;
end
- hiscore_path = _conf["hi_path"];
+ hiscore_path = lfs.env_replace(_conf["hi_path"] or hiscore_path);
+ timed_save = _conf["only_save_at_exit"] ~= "1"
+ print(timed_save)
-- hiscoredata_path = _conf["dat_path"]; -- don't know if I should do it, but wathever
return true
end
@@ -233,7 +236,7 @@ function hiscore.startplugin()
-- set up scores if they have been
init();
-- only allow save check to run when
- if mem_check_passed then
+ if mem_check_passed and timed_save then
-- The reason for this complicated mess is that
-- MAME does expose a hook for "exit". Once it does,
-- this should obviously just be done when the emulator
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 610b1947210..9d79d1f635d 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -828,7 +828,7 @@ void lua_engine::initialize()
[](emu_file &file, const char *path, u32 flags) { new (&file) emu_file(path, flags); },
[](emu_file &file, const char *mode) {
int flags = 0;
- for(int i = 0; i < 2; i++) // limit to three chars
+ for(int i = 0; i < 3 && mode[i]; i++) // limit to three chars
{
switch(mode[i])
{
@@ -847,7 +847,7 @@ void lua_engine::initialize()
},
[](emu_file &file, const char *path, const char* mode) {
int flags = 0;
- for(int i = 0; i < 2; i++) // limit to three chars
+ for(int i = 0; i < 3 && mode[i]; i++) // limit to three chars
{
switch(mode[i])
{
@@ -1587,8 +1587,8 @@ void lua_engine::initialize()
* input:code_name(code) - get code friendly name
* input:seq_from_tokens(tokens) - get input_seq for multiple space separated KEYCODE_* string tokens
* input:seq_pressed(seq) - get pressed state for input_seq
- * input:seq_to_token(seq) - get KEYCODE_* string tokens for seq
- * input:seq_to_name(seq) - get seq friendly name
+ * input:seq_to_tokens(seq) - get KEYCODE_* string tokens for seq
+ * input:seq_name(seq) - get seq friendly name
*/
sol().registry().new_usertype<input_manager>("input", "new", sol::no_constructor,