From 9cc69e224f7a08c8d3e4acba65654704e60c5e32 Mon Sep 17 00:00:00 2001 From: ywang Date: Tue, 2 Feb 2021 19:49:02 +0100 Subject: Add command to view generated lua code; add unittests for repeating code --- advtrains/atc.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'advtrains/atc.lua') diff --git a/advtrains/atc.lua b/advtrains/atc.lua index 9f909c5..0005093 100644 --- a/advtrains/atc.lua +++ b/advtrains/atc.lua @@ -193,7 +193,19 @@ function atc.execute_atc_command(id, train) end end - +minetest.register_chatcommand("at_get_lua",{ + params = "", + description = "Compile the given ATC command into Lua code and show the given code", + privs = {train_admin = true}, + func = function(name, params) + local f, s = advtrains.atcjit.compile(params) + if not f then + return false, s or ("Unknown compilation error") + else + return true, s + end + end, +}) --move table to desired place advtrains.atc=atc -- cgit v1.2.3