summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2012-08-09 08:27:47 +0200
committerJeija <norrepli@gmail.com>2012-08-09 08:27:47 +0200
commit72b00178f9ec35e407b45c357ed60711f09e4439 (patch)
treef41d1be9c2ab880bd5e6dd1947713acd54405c3e
parent89edd2ce63defdf15f0a75da9532e128bcd9ab95 (diff)
downloadmesecons-72b00178f9ec35e407b45c357ed60711f09e4439.tar
mesecons-72b00178f9ec35e407b45c357ed60711f09e4439.tar.gz
mesecons-72b00178f9ec35e407b45c357ed60711f09e4439.tar.bz2
mesecons-72b00178f9ec35e407b45c357ed60711f09e4439.tar.xz
mesecons-72b00178f9ec35e407b45c357ed60711f09e4439.zip
Enable commentaries in the Microcontroller by using :commentary
-rw-r--r--mesecons_microcontroller/init.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua
index 2ff6596..bb040f1 100644
--- a/mesecons_microcontroller/init.lua
+++ b/mesecons_microcontroller/init.lua
@@ -66,6 +66,7 @@ end
function update_yc(pos)
local meta = minetest.env:get_meta(pos)
local code = meta:get_string("code")
+ code = yc_code_remove_commentary(code)
code = string.gsub(code, " ", "") --Remove all spaces
code = string.gsub(code, " ", "") --Remove all tabs
if parse_yccode(code, pos) == nil then
@@ -75,6 +76,15 @@ function update_yc(pos)
end
end
+function yc_code_remove_commentary(code)
+ for i = 1, #code do
+ if code:sub(i, i) == ":" then
+ return code:sub(1, i-1)
+ end
+ end
+ return code
+end
+
function parse_yccode(code, pos)
local endi = 1
local L = yc_get_portstates(pos)