-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0_basic_jumpdrive_controll_pandorabox.lua
501 lines (443 loc) · 22.8 KB
/
0_basic_jumpdrive_controll_pandorabox.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
--[[
Basic Pandorabox tools
BUG:
- When a numerical value is contained in event.msg the LUAc run will fail! Resolve by checking for type "table" before probing keys!
- Current coordinates in LUAc doesn't reset when a jump was requested but not executed (e.g. obstructed, Refresh+Reset fixes the state)
TODO:
- Refreshing the touchscreen repaints the formspec fully. Make use of replacing GUI elements!
- Changing the radius does not adjust instant_jump distance (This may result in jump into itself)
- Changing instant_jump distance too small is actually set to the smallest possible but late for the GUI to always show that
- Unify usage of linebuffer
- Hardcoded textarea name "display" (cut in logging to prevent logging itself inflating string size) prevents more than one such textarea per page
]]
-- ########
-- Optimization
-- ########
local math, os, string, table = math, os, string, table
-- ########
-- Settings
-- ########
local permission = {authorised_users = {"FeXoR", "6r1d", "SX", "SwissalpS", "Huhhila", "BuckarooBanzai", "admin"}}
if mem.permission == nil then mem.permission = {ignore = false} end
permission.check = function(user)
if mem.permission.ignore == true then return true end
local is_allowed = false
for i, u in ipairs(permission.authorised_users) do
if user == u then
is_allowed = true
break
end
end
return is_allowed
end
local event_catcher = {touchscreen = {max_lines = 30}, monitor = {channel = "mon_ec"}}
if mem.events == nil then mem.events = {count = 0} end
local jumpdrive = {channel = "jumpdrive"}
if mem.linebuffer == nil then
mem.linebuffer = {}
if mem.linebuffer.jumpdrive == nil then mem.linebuffer.jumpdrive = {"Here the Jumpdrive's responses will be shown."} end
end
local quarries = {channel = "quarry"}
if mem.reset_quarries_on_jump == nil then mem.reset_quarries_on_jump = false end
local touchscreen = {
channel = "ts",
pages = {"Events", "Jumpdrive", "LUA Libs"},
update_pages = {},
permissions = {"Open", "Users", "Locked"},
linebuffer = {jumpdrive = {memory = mem.linebuffer.jumpdrive, max_lines = 30}}
}
if mem.page == nil then
mem.page = 1
table.insert(touchscreen.update_pages, 1, touchscreen.pages[mem.page])
end
if mem.ts_lock == nil then mem.ts_lock = 2 end
local breakers = {port = "b"}
if mem.instant_jump == nil then mem.instant_jump = {distance = 50} end
-- ########
-- Helper functions
-- ########
local character = {}
character.is_numeric = function (sChar)
if sChar:byte() >= 48 and sChar:byte() <= 57 then return true
else return false
end
end
local coordinates = {names = {"x", "y", "z"}}
-- TODO: Probably make more readable by by using character type definition with methods is_numeric and is_minus
function coordinates:to_table(sInput)
local tNumberList = {}
if type(sInput) == "string" then
local bContinuous = false
for nChar = 1, #sInput do
local nByte = sInput:byte(nChar)
-- A new numerical string starts - potentially - ignoring repetitions of "-"
if (bContinuous == false and (nByte == 45 or (nByte >= 48 and nByte <= 57))) or (nByte == 45 and sInput:byte(nChar-1) ~= 45) then
-- Override previous non valid numerical string "-"
if #tNumberList > 0 and tNumberList[#tNumberList] == "-" then tNumberList[#tNumberList] = string.char(nByte)
else table.insert(tNumberList, string.char(nByte))
end
bContinuous = true
elseif bContinuous and (nByte >= 48 and nByte <= 57) then
tNumberList[#tNumberList] = tostring(tNumberList[#tNumberList]) .. string.char(nByte)
elseif nByte ~= 45 then
bContinuous = false
end
end
-- Remove tailing non valid numerical string "-"
if tNumberList[#tNumberList] == "-" then tNumberList[#tNumberList] = nil end
end
local tOutput = {}
for i, name in ipairs(self.names) do
tOutput[name] = tonumber(tNumberList[i] or "0")
end
return tOutput
end
function coordinates:to_string(coordinate_table) return coordinate_table.x .. "," .. coordinate_table.y .. "," .. coordinate_table.z end
local function get_string(data, maxdepth)
local maxdepth = maxdepth or 3
if type(data) == "string" then return data
elseif type(data) == "table" and maxdepth > 0 then
local oString = "{"
for k, v in pairs(data) do
local val = v
if type(v) == "table" then val = get_string(val, maxdepth - 1) end
oString = oString .. tostring(k) .. "=" .. tostring(val) .. ", "
end
return string.sub(oString, 1, -3) .. "}"
else
return tostring(data)
end
return "Something went wrong!"
end
local function get_time_string(datetable)
local date_table = datetable or os.datetable()
local date_string = date_table.year .. "-" .. date_table.month .. "-" .. date_table.day
local time_string = date_table.hour .. ":" .. date_table.min .. ":" .. date_table.sec
return date_string .. "T" .. time_string
end
local function merge_shallow_tables(t1, t2)
local t3 = {}
for k, v in pairs(t1) do t3[k] = v end
for k, v in pairs(t2) do t3[k] = v end
return t3
end
local function add_line_to_buffer(linebuffer, message)
-- expects linebuffer to be an array with keys memory (link to line table in mem) and max_lines (integer)
if type(message) ~= "string" then message = get_string(message) end
table.insert(linebuffer.memory, 1, message)
while table.maxn(linebuffer.memory) > linebuffer.max_lines do table.remove(linebuffer.memory) end
end
local function touchscreen_add_line(msg)
table.insert(mem.event_catcher.touchscreen_line_table, 1, tostring(mem.events.count) .. ": " .. tostring(msg))
while table.maxn(mem.event_catcher.touchscreen_line_table) > event_catcher.touchscreen.max_lines do
table.remove(mem.event_catcher.touchscreen_line_table)
end
end
local function send_to_monitors(message)
-- Omitt appending it's own and other "display" type content to avoid doubling the output
if message ~= nil and message.msg ~= nil and message.msg.display ~= nil then message.msg.display = "<cut>" end
if message.channel then digiline_send(event_catcher.monitor.channel, message.channel)
elseif message.type then digiline_send(event_catcher.monitor.channel, message.type)
else digiline_send(event_catcher.monitor.channel, get_string(message, 1)) end
if message ~= nil and message.type == "interrupt" then message.time = get_time_string() end
touchscreen_add_line(get_string(message))
end
-- ########
-- Touchscreen
-- ########
local function update_page(page)
if touchscreen.pages[mem.page] == page then
local message = {
{command = "clear"},
-- BUG background9 needs to be before bgcolor
-- {command = "add", element = "background9", X = 0, Y = 0, W = 0, H = 0, image = "ui_formbg_9_sliced.png", auto_clip = true, middle = 16},
-- BUG focus doesn't seem to work at all: focus = "target"
{command = "set", width = 13, height = 10, no_prepend = true, real_coordinates = true},
{command = "add", element = "bgcolor", bgcolor = "#202040FF", fullscreen = "false", fbgcolor = "#10101040"},
{command = "add", element = "label", label = "Page:", X=0.2,Y=0.3},
{command = "add", element = "textlist", name = "page", listelements = touchscreen.pages, selected_id = mem.page, X=0.1,Y=0.5,W=1.5,H=7.7},
{command = "add", element = "label", label = "Lock:", X=0.2,Y=8.5},
{command = "add", element = "textlist", name = "lock", listelements = touchscreen.permissions, selected_id = mem.ts_lock, X=0.1,Y=8.7,W=1.5,H=1.2},
}
if page == "Events" then
table.insert(message, {command = "add", element = "textarea", name = "display", label = "Events:",
default = table.concat(mem.event_catcher.touchscreen_line_table, "\n"), X=1.5, Y=0.55, W=11.25, H=9.3})
elseif page == "Jumpdrive" then
table.insert(message, {command = "add", element = "button", name = "request_data", label = "Refresh", X=1.7,Y=0.25,W=1.2,H=0.5})
table.insert(message, {command = "add", element = "label", X=3.1, Y=0.5,
label = "Distance: " .. tostring(math.ceil(mem.jumpdrive.distance)) .. " | " ..
"EU needed: " .. tostring(math.ceil(mem.jumpdrive.power_req)) .. " stored: " .. tostring(math.ceil(mem.jumpdrive.powerstorage))
})
-- BUG The "H" parameter only shifts a field instead of resizing it. Best leave it out (same as H=0.8
-- BUG The "set" focus propperty doesn't seem to work. The first input field added get's the focus
table.insert(message, {command = "add", element = "field", name = "target",
label = "Target (Current: " .. coordinates:to_string(mem.jumpdrive.position) .. ")",
default = coordinates:to_string(mem.jumpdrive.target),
X=3.8, Y=1.8, W=4.5})
-- Needs to be behind (in GUI so in front in code) radius selection or that will be blocked by it's invisible label
table.insert(message, {command = "add", element = "textarea", name = "display", label = "The Jumpdrive says:",
default = table.concat(mem.linebuffer.jumpdrive, "\n"), X=1.6, Y=3.8, W=10.7, H=6})
table.insert(message, {command = "add", element = "label", label = "Radius", X=12,Y=3.7})
table.insert(message, {command = "add", element = "textlist", name = "radius",
listelements = {"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"},
selected_id = tonumber(mem.jumpdrive.radius), X=12.4,Y=3.85,W=0.5,H=6})
-- Message very long, split here
-- digiline_send(touchscreen.channel, message)
-- message = {}
-- BUG The "H" parameter only shifts a field instead of resizing it. Best leave it out (same as H=0.8
table.insert(message, {command = "add", element = "field", name = "jump_step_value", label = "Distance",
default = tostring(mem.instant_jump.distance), X=1.7, Y=1.8, W=1.1})
table.insert(message, {command = "add", element = "button", name = "jump_step_increase", label = "+", X=1.7,Y=1,W=1.1,H=0.5})
table.insert(message, {command = "add", element = "button", name = "jump_step_decrease", label = "-", X=1.7,Y=2.6,W=1.1,H=0.5})
--
table.insert(message, {command = "add", element = "button_exit", name = "xi", label = "E", X=3.8,Y=1,W=1.5,H=0.5})
table.insert(message, {command = "add", element = "button_exit", name = "xd", label = "W", X=3.8,Y=2.6,W=1.5,H=0.5})
table.insert(message, {command = "add", element = "button_exit", name = "yi", label = "^", X=5.3,Y=1,W=1.5,H=0.5})
table.insert(message, {command = "add", element = "button_exit", name = "yd", label = "v", X=5.3,Y=2.6,W=1.5,H=0.5})
table.insert(message, {command = "add", element = "button_exit", name = "zi", label = "N", X=6.8,Y=1,W=1.5,H=0.5})
table.insert(message, {command = "add", element = "button_exit", name = "zd", label = "S", X=6.8,Y=2.6,W=1.5,H=0.5})
table.insert(message, {command = "add", element = "button", name = "reset_target", label = "Reset", X=2.8,Y=1.8,W=1,H=0.8})
table.insert(message, {command = "add", element = "button", name = "set_target", label = "Set", X=8.3,Y=1.8,W=1,H=0.8})
table.insert(message, {command = "add", element = "button", name = "simulate", label = "Test", X=9.4,Y=1.8,W=1,H=0.8})
table.insert(message, {command = "add", element = "button_exit", name = "jump", label = "Jump", X=10.5,Y=1.8,W=1.5,H=0.8})
table.insert(message, {command = "add", element = "checkbox", name = "reset_quarries_on_jump", label = "Reset quarries on jump", selected = mem.reset_quarries_on_jump, X=8.5,Y=3})
else
table.insert(message, {command = "add", element = "label", label = "This page is not yet handled: " .. tostring(touchscreen.pages[mem.page]), X=4,Y=4})
end
digiline_send(touchscreen.channel, message)
end
end
-- Handle touchscreen messages
if event.type == "digiline" and event.channel == touchscreen.channel and event.msg then
if event.msg.page ~= nil then
local i_page = tonumber(string.sub(event.msg.page, 5))
if i_page ~= mem.page then
mem.page = i_page
table.insert(touchscreen.update_pages, 1, touchscreen.pages[mem.page])
end
elseif event.msg.lock ~= nil then
local i_lock = tonumber(string.sub(event.msg.lock, 5))
if permission.check(event.msg.clicker) then
if i_lock ~= mem.ts_lock then
mem.ts_lock = i_lock
if mem.ts_lock == 1 then
digiline_send(touchscreen.channel, {command = "unlock"})
mem.permission.ignore = true
elseif mem.ts_lock == 2 then
digiline_send(touchscreen.channel, {command = "unlock"})
mem.permission.ignore = false
elseif mem.ts_lock == 3 then
digiline_send(touchscreen.channel, {command = "lock"})
mem.permission.ignore = false
else send_to_monitors("Unhandled ts_lock value: " .. tostring(mem.ts_lock))
end
table.insert(touchscreen.update_pages, 1, touchscreen.pages[mem.page])
end
else
send_to_monitors("You can't unlock, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif touchscreen.pages[mem.page] == "Jumpdrive" then
local authorised = permission.check(event.msg.clicker)
local min_jump_step_value = 2 * mem.jumpdrive.radius + 1
if event.msg.jump_step_value ~= nil then
if tonumber(event.msg.jump_step_value) < min_jump_step_value then mem.instant_jump.distance = min_jump_step_value
else mem.instant_jump.distance = tonumber(event.msg.jump_step_value) end
if tonumber(event.msg.jump_step_value) ~= mem.instant_jump.distance then table.insert(touchscreen.update_pages, 1, "Jumpdrive") end
end
if event.msg.radius ~= nil then
if authorised then
mem.jumpdrive.radius = tonumber(string.sub(event.msg.radius, 5))
if event.msg.target ~= nil then
mem.jumpdrive.target = coordinates:to_table(event.msg.target)
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", r = mem.jumpdrive.radius, formupdate = true}, mem.jumpdrive.target))
else
digiline_send(jumpdrive.channel, {command = "set", r = mem.jumpdrive.radius, formupdate = true})
end
digiline_send(jumpdrive.channel, {command = "get"})
else
send_to_monitors("You can't change the radius, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.key_enter_field ~= nil then
if event.msg.key_enter_field == "target" then
mem.jumpdrive.target = coordinates:to_table(event.msg.target)
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "get"})
elseif event.msg.key_enter_field == "jump_step_value" then
table.insert(touchscreen.update_pages, 1, "Jumpdrive")
else send_to_monitors("Unknown key_enter_field: " .. tostring(event.msg.key_enter_field)) end
elseif event.msg.reset_target ~= nil then
digiline_send(jumpdrive.channel, {command = "reset"})
digiline_send(jumpdrive.channel, {command = "get"})
elseif event.msg.set_target ~= nil then
if event.msg.target ~= nil then
mem.jumpdrive.target = coordinates:to_table(event.msg.target)
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "get"})
end
elseif event.msg.request_data ~= nil then
mem.jumpdrive.target = coordinates:to_table(event.msg.target)
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "get"})
elseif event.msg.simulate ~= nil then
mem.jumpdrive.target = coordinates:to_table(event.msg.target)
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "simulate"})
elseif event.msg.jump ~= nil then
if authorised then
mem.jumpdrive.target = coordinates:to_table(event.msg.target)
-- mem.jumpdrive.target = mem.jumpdrive.position
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "jump"})
else
send_to_monitors("You can't jump, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.jump_step_increase ~= nil then
local target_jump_step_value = tonumber(event.msg.jump_step_value) + 1
if target_jump_step_value > min_jump_step_value then mem.instant_jump.distance = target_jump_step_value
else mem.instant_jump.distance = min_jump_step_value end
if mem.instant_jump.distance ~= tonumber(event.msg.jump_step_value) then table.insert(touchscreen.update_pages, 1, "Jumpdrive") end
elseif event.msg.jump_step_decrease ~= nil then
local target_jump_step_value = tonumber(event.msg.jump_step_value) - 1
if target_jump_step_value > min_jump_step_value then mem.instant_jump.distance = target_jump_step_value
else mem.instant_jump.distance = min_jump_step_value end
if mem.instant_jump.distance ~= tonumber(event.msg.jump_step_value) then table.insert(touchscreen.update_pages, 1, "Jumpdrive") end
elseif event.msg.xi ~= nil then
if authorised then
-- mem.jumpdrive.target = mem.jumpdrive.position
mem.jumpdrive.target.x = mem.jumpdrive.position.x + mem.instant_jump.distance
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "jump"})
else
send_to_monitors("You can't jump, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.xd ~= nil then
if authorised then
-- mem.jumpdrive.target = mem.jumpdrive.position
mem.jumpdrive.target.x = mem.jumpdrive.position.x - mem.instant_jump.distance
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "jump"})
else
send_to_monitors("You can't jump, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.yi ~= nil then
if authorised then
-- mem.jumpdrive.target = mem.jumpdrive.position
mem.jumpdrive.target.y = mem.jumpdrive.position.y + mem.instant_jump.distance
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "jump"})
else
send_to_monitors("You can't jump, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.yd ~= nil then
if authorised then
-- mem.jumpdrive.target = mem.jumpdrive.position
mem.jumpdrive.target.y = mem.jumpdrive.position.y - mem.instant_jump.distance
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "jump"})
else
send_to_monitors("You can't jump, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.zi ~= nil then
if authorised then
-- mem.jumpdrive.target = mem.jumpdrive.position
mem.jumpdrive.target.z = mem.jumpdrive.position.z + mem.instant_jump.distance
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "jump"})
else
send_to_monitors("You can't jump, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.zd ~= nil then
if authorised then
-- mem.jumpdrive.target = mem.jumpdrive.position
mem.jumpdrive.target.z = mem.jumpdrive.position.z - mem.instant_jump.distance
digiline_send(jumpdrive.channel, merge_shallow_tables({command = "set", formupdate = false}, mem.jumpdrive.target))
digiline_send(jumpdrive.channel, {command = "jump"})
else
send_to_monitors("You can't jump, " .. tostring(event.msg.clicker) .. " ;)")
end
elseif event.msg.reset_quarries_on_jump ~= nil then
if authorised then
-- mem.reset_quarries_on_jump = event.msg.reset_quarries_on_jump
if event.msg.reset_quarries_on_jump == "true" then mem.reset_quarries_on_jump = true
else mem.reset_quarries_on_jump = false
end
table.insert(touchscreen.update_pages, 1, "Jumpdrive")
else
send_to_monitors("You can't change this, " .. tostring(event.msg.clicker) .. " ;)")
end
end
end
end
-- ########
-- Jumpdrive
-- ########
if mem.jumpdrive == nil then
mem.jumpdrive = {radius = 1, power_req = 0, distance = 0, powerstorage = 0, position = {x=0,y=0,z=0}, target = {x=0,y=0,z=0}, success = false, msg = "", time = 0}
end
if event.type == "program" then digiline_send(jumpdrive.channel, {command = "get"}) end
if event.type == "digiline" and event.channel == jumpdrive.channel and event.msg then
local output = ""
local updated = {}
for k, v in pairs(event.msg) do
if mem.jumpdrive[k] ~= nil then
-- if mem.jumpdrive[k] ~= v then output = output .. " " .. tostring(k) .. ": " .. get_string(mem.jumpdrive[k]) .. " -> " .. get_string(v) end
mem.jumpdrive[k] = v
else
add_line_to_buffer(touchscreen.linebuffer.jumpdrive, "Unknown jumpdrive propperty: " .. get_string(k) .. ":" .. get_string(v))
end
end
if event.msg.success ~= nil then
if event.msg.success == true then
output = output .. " Success!"
if mem.reset_quarries_on_jump then digiline_send(quarries.channel, {command = "set", restart = true}) end
else output = output .. " Failure! (Best refresh and reset)"
end
end
if event.msg.msg then output = output .. " " .. event.msg.msg end
if event.msg.time then
output = output .. " Jumped (" .. tostring(event.msg.time) .. ")"
mem.jumpdrive.position = mem.jumpdrive.target
digiline_send(jumpdrive.channel, {command = "get"})
end
if output ~= nil then
if output ~= "" then add_line_to_buffer(touchscreen.linebuffer.jumpdrive, tostring(mem.events.count) .. ":" .. output) end
else
add_line_to_buffer(touchscreen.linebuffer.jumpdrive, tostring(mem.events.count) .. ":" .. "Output was nil!")
end
table.insert(touchscreen.update_pages, 1, "Jumpdrive")
end
-- ########
-- Event Catcher and update screens
-- ########
if mem.event_catcher == nil then
mem.event_catcher = {touchscreen_line_table = {"Initialized at " .. get_time_string() .. ", " .. _VERSION}}
end
send_to_monitors(event)
for i, page in ipairs(touchscreen.update_pages) do
if page == touchscreen.pages[mem.page] then
update_page(touchscreen.pages[mem.page])
break
end
end
mem.events.count = mem.events.count + 1
-- MIT License
--
-- Copyright (c) 2021 Florian Finke
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.