summaryrefslogtreecommitdiffstatshomepage
path: root/plugins
diff options
context:
space:
mode:
author cracyc <cracyc@users.noreply.github.com>2016-04-27 09:36:04 -0500
committer cracyc <cracyc@users.noreply.github.com>2016-04-27 09:37:23 -0500
commit29d7699569f10ce9077cfebe4e7045eb5226f4ff (patch)
tree2ebf8b1e369783c7f0abd43d9cea94ea5eb73f70 /plugins
parent7d635eec4bdb6cc94fded371375f0c2e27749858 (diff)
plugins/layout: layout embedded script helper plugin [Carl]
luaengine: callbacks for plugins (nw) rendlay: layout tag external handler support (nw) fidel_csc and mdndclab: example layout scripts (nw) -- Neither layout script is complete. The chess doesn't handle castling or en passant and the Dungeons and Dragons only does the walls.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/cheat/init.lua1
-rw-r--r--plugins/layout/init.lua50
-rw-r--r--plugins/layout/plugin.json10
3 files changed, 61 insertions, 0 deletions
diff --git a/plugins/cheat/init.lua b/plugins/cheat/init.lua
index e3e9740692e..0e5abf447ab 100644
--- a/plugins/cheat/init.lua
+++ b/plugins/cheat/init.lua
@@ -171,6 +171,7 @@ function cheat.startplugin()
frombcd = frombcd,
pairs = pairs,
ipairs = ipairs,
+ outputs = manager:machine():outputs(),
time = time,
table =
{ insert = table.insert,
diff --git a/plugins/layout/init.lua b/plugins/layout/init.lua
new file mode 100644
index 00000000000..fdac807b9b1
--- /dev/null
+++ b/plugins/layout/init.lua
@@ -0,0 +1,50 @@
+-- license:BSD-3-Clause
+-- copyright-holders:Carl
+-- Layout scripts should return a table and a string. The table can have two optional keys reset and frame
+-- which have functions for values called on reset and frame draw respectively and the string is a unique name.
+local exports = {}
+exports.name = "layout"
+exports.version = "0.0.1"
+exports.description = "Layout helper plugin"
+exports.license = "The BSD 3-Clause License"
+exports.author = { name = "Carl" }
+
+local layout = exports
+
+function layout.startplugin()
+ local scripts = {}
+ local function prepare_layout(script)
+ local env = { machine = manager:machine(), pairs = pairs, ipairs = ipairs,
+ table = { insert = table.insert, remove = table.remove } }
+ local script, err = load(script, script, "t", env)
+ if not script then
+ emu.print_verbose("error loading layout script " .. err)
+ return
+ end
+ local name
+ script, name = script()
+ scripts[name] = script
+ end
+
+ emu.register_callback(prepare_layout, "layout")
+ emu.register_frame(function()
+ if manager:machine().paused then
+ return
+ end
+ for num, scr in pairs(scripts) do
+ if scr.frame then
+ scr.frame()
+ end
+ end
+ end)
+ emu.register_start(function()
+ for num, scr in pairs(scripts) do
+ if scr.reset then
+ scr.reset()
+ end
+ end
+ end)
+ emu.register_stop(function() scripts = {} end)
+end
+
+return exports
diff --git a/plugins/layout/plugin.json b/plugins/layout/plugin.json
new file mode 100644
index 00000000000..e50da000893
--- /dev/null
+++ b/plugins/layout/plugin.json
@@ -0,0 +1,10 @@
+{
+ "plugin": {
+ "name": "layout",
+ "description": "Layout helper plugin",
+ "version": "0.0.1",
+ "author": "Carl",
+ "type": "plugin",
+ "start": "false"
+ }
+}