View difference between Paste ID: XFfaFjEA and 156Np04X
SHOW: | | - or go back to the newest paste.
1
local GUI = require("GUI")
2
local system = require("System")
3
local cryptKey = {1, 2, 3, 4, 5}
4
local departments = {"SD","ScD","MD","E&T","O5"}
5
local modemPort = 199
6
7-
local gui = require("gui")
7+
local adminCard = "admincard"
8
9
local showUUIDWarn = true
10-
writer = component.os_cardwriter
10+
11
 
12-
local myGui, cardStatusLabel, userList, userNameText, userLevelLabel, LevelUpButton, LevelDownButton
12+
13-
local cardBlockedYesButton, cardBlockedNoButton, userNewButton, userDeleteButton
13+
14
local event = require("event")
15-
local prgName = "Access System"
15+
16-
local version = "v0.1a"
16+
local uuid = require("uuid")
17
local fs = require("Filesystem")
18-
local modem = component.modem 
18+
local writer
19
 
20
----------
21
 
22
local workspace, window, menu
23
local cardStatusLabel, userList, userNameText, userLevelLabel, LevelUpButton, LevelDownButton, createAdminCardButton
24
local cardBlockedYesButton, userNewButton, userDeleteButton, userChangeUUIDButton, MTFYesButton, listPageLabel, listUpButton, listDownButton
25
local GOIYesButton, SecYesButton, userArmoryLabel, ArmoryUpButton, ArmoryDownButton, userUUIDLabel
26
local userDepLabel, DepUpButton, DepDownButton, IntYesButton, StaffYesButton
27
 
28
----------
29
 
30-
	if(i%4 == inc)then
30+
local prgName = "Security database"
31-
	  enc = enc .. convert(string.sub(str,i,i),k[inc+1],inv);
31+
local version = "v0.8"
32-
	  break;
32+
33-
	end
33+
local modem
34
 
35
local pageMult = 10
36
local listPageNumber = 0
37
local previousPage = 0
38
 
39
-----------
40
41
if component.isAvailable("os_cardwriter") then
42
    writer = component.os_cardwriter
43
else
44
    GUI.alert("This requires an Open Security card writer to run")
45
    return
46
end
47
if component.isAvailable("modem") then
48-
	s = string.format( "%q",s )
48+
    modem = component.modem
49-
	-- to replace
49+
else
50-
	s = string.gsub( s,"\\\n","\\n" )
50+
    GUI.alert("This requires a modem to run")
51-
	s = string.gsub( s,"\r","\\r" )
51+
    return
52-
	s = string.gsub( s,string.char(26),"\"..string.char(26)..\"" )
52+
53-
	return s
53+
54
-----------
55
 
56
local function convert( chars, dist, inv )
57-
	local charS,charE = "   ","\n"
57+
58-
	local file,err
58+
59-
	-- create a pseudo file that writes to a string and return the string
59+
60-
	if not filename then
60+
61-
		file =  { write = function( self,newstr ) self.str = self.str..newstr end, str = "" }
61+
62-
		charS,charE = "",""
62+
63-
	-- write table to tmpfile
63+
64-
	elseif filename == true or filename == 1 then
64+
65-
		charS,charE,file = "","",io.tmpfile()
65+
66-
	-- write table to file
66+
    if(i%4 == inc)then
67-
	-- use io.open here rather than io.output, since in windows when clicking on a file opened with io.output will create an error
67+
      enc = enc .. convert(string.sub(str,i,i),k[inc+1],inv);
68-
	else
68+
      break;
69-
		file,err = io.open( filename, "w" )
69+
70-
		if err then return _,err end
70+
71-
	end
71+
72-
	-- initiate variables for save procedure
72+
73-
	local tables,lookup = { tbl },{ [tbl] = 1 }
73+
74-
	file:write( "return {"..charE )
74+
75-
	for idx,t in ipairs( tables ) do
75+
76-
		if filename and filename ~= true and filename ~= 1 then
76+
77-
			file:write( "-- Table: {"..idx.."}"..charE )
77+
78-
		end
78+
79-
		file:write( "{"..charE )
79+
80-
		local thandled = {}
80+
81-
		for i,v in ipairs( t ) do
81+
82-
			thandled[i] = true
82+
83-
			-- escape functions and userdata
83+
84-
			if type( v ) ~= "userdata" then
84+
    s = string.format( "%q",s )
85-
				-- only handle value
85+
    -- to replace
86-
				if type( v ) == "table" then
86+
    s = string.gsub( s,"\\\n","\\n" )
87-
					if not lookup[v] then
87+
    s = string.gsub( s,"\r","\\r" )
88-
						table.insert( tables, v )
88+
    s = string.gsub( s,string.char(26),"\"..string.char(26)..\"" )
89-
						lookup[v] = #tables
89+
    return s
90-
					end
90+
91-
					file:write( charS.."{"..lookup[v].."},"..charE )
91+
92-
				elseif type( v ) == "function" then
92+
93-
					file:write( charS.."loadstring("..exportstring(string.dump( v )).."),"..charE )
93+
    local tableFile = fs.open(filename, "w")
94-
				else
94+
  	tableFile:write(ser.serialize(tbl))
95-
					local value =  ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
95+
  	tableFile:close()
96-
					file:write(  charS..value..","..charE )
96+
97-
				end
97+
98-
			end
98+
99-
		end
99+
100-
		for i,v in pairs( t ) do
100+
    local tableFile = fs.open(sfile, "r")
101-
			-- escape functions and userdata
101+
  	return ser.unserialize(tableFile:readAll())
102-
			if (not thandled[i]) and type( v ) ~= "userdata" then
102+
103-
				-- handle index
103+
104-
				if type( i ) == "table" then
104+
105-
					if not lookup[i] then
105+
106-
						table.insert( tables,i )
106+
107-
						lookup[i] = #tables
107+
108-
					end
108+
109-
					file:write( charS.."[{"..lookup[i].."}]=" )
109+
110-
				else
110+
111-
					local index = ( type( i ) == "string" and "["..exportstring( i ).."]" ) or string.format( "[%d]",i )
111+
112-
					file:write( charS..index.."=" )
112+
113-
				end
113+
114-
				-- handle value
114+
115-
				if type( v ) == "table" then
115+
116-
					if not lookup[v] then
116+
    if(i%4 == inc)then
117-
						table.insert( tables,v )
117+
      enc = enc .. convert(string.sub(str,i,i),k[inc+1],inv);
118-
						lookup[v] = #tables
118+
      break;
119-
					end
119+
120-
					file:write( "{"..lookup[v].."},"..charE )
120+
121-
				elseif type( v ) == "function" then
121+
122-
					file:write( "loadstring("..exportstring(string.dump( v )).."),"..charE )
122+
123-
				else
123+
124-
					local value =  ( type( v ) == "string" and exportstring( v ) ) or tostring( v )
124+
125-
					file:write( value..","..charE )
125+
126-
				end
126+
127-
			end
127+
128-
		end
128+
129-
		file:write( "},"..charE )
129+
130-
	end
130+
131-
	file:write( "}" )
131+
----------Callbacks
132-
	-- Return Values
132+
133-
	-- return stringtable from string
133+
134-
	if not filename then
134+
135-
		-- set marker for stringtable
135+
136-
		return file.str.."--|"
136+
137-
	-- return stringttable from file
137+
138-
	elseif filename == true or filename == 1 then
138+
139-
		file:seek ( "set" )
139+
140-
		-- no need to close file, it gets closed and removed automatically
140+
141-
		-- set marker for stringtable
141+
142-
		return file:read( "*a" ).."--|"
142+
  selectedId = userList.selectedItem
143-
	-- close file and return 1
143+
  userList:remove()
144-
	else
144+
  userList = window:addChild(GUI.list(4, 4, 58, 34, 3, 0, 0xE1E1E1, 0x4B4B4B, 0xD2D2D2, 0x4B4B4B, 0x3366CC, 0xFFFFFF, false)) 
145-
		file:close()
145+
  local temp = pageMult * listPageNumber
146-
		return 1
146+
  for i = temp + 1, temp + pageMult, 1 do
147-
	end
147+
  if (userTable[i] == nil) then
148
149
  else
150
    userList:addItem(userTable[i].name).onTouch = userListCallback
151
  end
152-
	local tables, err, _
152+
153-
	-- catch marker for stringtable
153+
154-
	if string.sub( sfile,-3,-1 ) == "--|" then
154+
155-
		tables,err = loadstring( sfile )
155+
  if (previousPage == listPageNumber) then
156-
	else
156+
  userList.selectedItem = selectedId
157-
		tables,err = loadfile( sfile )
157+
158-
	end
158+
  previousPage = listPageNumber
159-
	if err then return _,err
159+
160-
	end
160+
161-
	tables = tables()
161+
162-
	for idx = 1,#tables do
162+
163-
		local tolinkv,tolinki = {},{}
163+
164-
		for i,v in pairs( tables[idx] ) do
164+
165-
			if type( v ) == "table" and tables[v[1]] then
165+
    cardStatusLabel.text = "   Card present"
166-
				table.insert( tolinkv,{ i,tables[v[1]] } )
166+
167-
			end
167+
    cardStatusLabel.text = "     No card   "
168-
			if type( i ) == "table" and tables[i[1]] then
168+
169-
				table.insert( tolinki,{ i,tables[i[1]] } )
169+
170-
			end
170+
171-
		end
171+
function userListCallback()
172-
		-- link values, first due to possible changes of indices
172+
  selectedId = pageMult * listPageNumber + userList.selectedItem
173-
		for _,v in ipairs( tolinkv ) do
173+
  userNameText.text = userTable[selectedId].name
174-
			tables[idx][v[1]] = v[2]
174+
  userUUIDLabel.text = "UUID      : " .. userTable[selectedId].uuid
175-
		end
175+
  userLevelLabel.text = tostring(userTable[selectedId].level)
176-
		-- link indices
176+
  userArmoryLabel.text = tostring(userTable[selectedId].armory)
177-
		for _,v in ipairs( tolinki ) do
177+
  userDepLabel.text = departments[userTable[selectedId].department]
178-
			tables[idx][v[2]],tables[idx][v[1]] =  tables[idx][v[1]],nil
178+
  if userTable[selectedId].blocked == true then
179-
		end
179+
    cardBlockedYesButton.pressed = true
180-
	end
180+
181-
	return tables[1]
181+
    cardBlockedYesButton.pressed = false
182
  end
183
  cardBlockedYesButton.disabled = false
184
  if userTable[selectedId].mtf == true then
185
    MTFYesButton.pressed = true
186
  else
187
    MTFYesButton.pressed = false
188
  end
189
  MTFYesButton.disabled = false
190
  if userTable[selectedId].goi == true then
191
    GOIYesButton.pressed = true
192
  else
193
    GOIYesButton.pressed = false
194
  end
195
  GOIYesButton.disabled = false
196-
	if(i%4 == inc)then
196+
  if userTable[selectedId].sec == true then
197-
	  enc = enc .. convert(string.sub(str,i,i),k[inc+1],inv);
197+
    SecYesButton.pressed = true
198-
	  break;
198+
199-
	end
199+
    SecYesButton.pressed = false
200
  end
201
  SecYesButton.disabled = false
202
  if userTable[selectedId].int == true then
203
    IntYesButton.pressed = true
204
  else
205
    IntYesButton.pressed = false
206
  end
207
  IntYesButton.disabled = false
208
  if userTable[selectedId].staff == true then
209
    StaffYesButton.pressed = true
210
  else
211
    StaffYesButton.pressed = false
212-
function buttonCallback(guiID, id)
212+
213-
  local result = gui.getYesNo("", "Do you really want to exit?", "")
213+
  StaffYesButton.disabled = false
214-
  if result == true then
214+
215-
    gui.exit()
215+
  listPageLabel.text = tostring(listPageNumber + 1)
216
217
  LevelUpButton.disabled = false
218
  LevelDownButton.disabled = false
219
  ArmoryUpButton.disabled = false
220
  ArmoryDownButton.disabled = false
221-
    gui.setText(myGui, cardStatusLabel, "   Card present")
221+
  DepUpButton.disabled = false
222
  DepDownButton.disabled = false
223-
    gui.setText(myGui, cardStatusLabel, "     No card   ")
223+
  userNameText.disabled = false
224
end
225
 
226
function mtfUserCallback()
227-
function userListCallback(guiID, listID, selectedID, selectedText)
227+
  local selected = pageMult * listPageNumber + userList.selectedItem
228-
  gui.setText(myGui, userNameText, userTable[selectedID].name)
228+
  userTable[selected].mtf = MTFYesButton.pressed
229-
  gui.setText(myGui, userLevelLabel, tostring(userTable[selectedID].level))
229+
230-
  if userTable[selectedID].blocked == true then
230+
  userListCallback()
231-
    gui.setEnable(myGui, cardBlockedYesButton, false)
231+
232-
    gui.setEnable(myGui, cardBlockedNoButton, true)
232+
233
function goiUserCallback()
234-
    gui.setEnable(myGui, cardBlockedYesButton, true)
234+
  local selected = pageMult * listPageNumber + userList.selectedItem
235-
    gui.setEnable(myGui, cardBlockedNoButton, false)
235+
  userTable[selected].goi = GOIYesButton.pressed
236
  updateList()
237-
  gui.setEnable(myGui, LevelUpButton, true)
237+
  userListCallback()
238-
  gui.setEnable(myGui, LevelDownButton, true)
238+
239-
  gui.setEnable(myGui, userNameText, true)
239+
240
function secUserCallback()
241
  local selected = pageMult * listPageNumber + userList.selectedItem
242
  userTable[selected].sec = SecYesButton.pressed
243
  updateList()
244
  userListCallback()
245
end
246
 
247
function intUserCallback()
248
  local selected = pageMult * listPageNumber + userList.selectedItem
249
  userTable[selected].int = IntYesButton.pressed
250
  updateList()
251
  userListCallback()
252
end
253-
  gui.clearList(myGui, userList)
253+
254-
  for key,value in pairs(userTable) do
254+
function staffUserCallback()
255-
    gui.insertList(myGui, userList, value.name)
255+
  local selected = pageMult * listPageNumber + userList.selectedItem
256
  userTable[selected].staff = StaffYesButton.pressed
257
  updateList()
258
  userListCallback()
259
end
260
 
261-
function blockUserCallback(guiID, id)
261+
function blockUserCallback()
262-
  local selected = gui.getSelected(myGui, userList)
262+
  local selected = pageMult * listPageNumber + userList.selectedItem
263-
  userTable[selected].blocked = true
263+
  userTable[selected].blocked = cardBlockedYesButton.pressed
264
  updateList()
265-
  userListCallback(myGui, userList, selected)
265+
  userListCallback()
266
end
267
 
268-
function unblockUserCallback(guiID, id)
268+
function newUserCallback()
269-
  local selected = gui.getSelected(myGui, userList)
269+
  local tmpTable = {["name"] = "new", ["blocked"] = false, ["level"] = 1, ["date"] = os.date(), ["armory"] = 0, ["mtf"] = false, ["sec"] = false, ["int"] = false, ["staff"] = false, ["goi"] = false, ["department"] = 1, ["uuid"] = uuid.next()}
270-
  userTable[selected].blocked = false
270+
271
  updateList()
272-
  userListCallback(myGui, userList, selected)
272+
273
 
274
function deleteUserCallback()
275-
function newUserCallback(guiID, id)
275+
  local selected = pageMult * listPageNumber + userList.selectedItem
276-
  local tmpTable = {["name"] = "new", ["blocked"] = false, ["level"] = 1, ["date"] = os.date()}
276+
277
  updateList()
278
  userNameText.text = ""
279
  userLevelLabel.text = "#"
280
  userArmoryLabel.text = "#"
281-
function deleteUserCallback(guiID, id)
281+
  userDepLabel.text = "NAN"
282-
  local selected = gui.getSelected(myGui, userList)
282+
  LevelUpButton.disabled = true
283
  LevelDownButton.disabled = true
284
  ArmoryUpButton.disabled = true
285-
  gui.setText(myGui, userNameText, "")
285+
  ArmoryDownButton.disabled = true
286-
  gui.setText(myGui, userLevelLabel, "")
286+
  DepUpButton.disabled = true
287-
  gui.setEnable(myGui, cardBlockedYesButton, false)
287+
  DepDownButton.disabled = true
288-
  gui.setEnable(myGui, cardBlockedNoButton, false)
288+
  userNameText.disabled = true
289-
  gui.setEnable(myGui, LevelUpButton, false)
289+
  MTFYesButton.disabled = true
290-
  gui.setEnable(myGui, LevelDownButton, false)
290+
  GOIYesButton.disabled = true
291-
  gui.setEnable(myGui, userNameText, false)
291+
  SecYesButton.disabled = true
292
  IntYesButton.disabled = true
293
  StaffYesButton.disabled = true
294-
function writeCardCallback(guiID, id)
294+
295-
  local selected = gui.getSelected(myGui, userList)
295+
296-
  local data =  userTable[selected].date .. " " .. userTable[selected].name .. " " .. tostring(userTable[selected].level) .. " " .. tostring(userTable[selected].blocked)
296+
function changeUUID()
297
    if showUUIDWarn == true then
298-
  writer.write(crypted, "SECURITY", false)
298+
        showUUIDWarn = false
299
        GUI.alert("This will reset this user's uuid, rendering all cards linked to it useless. Use this if a card gets stolen or in another emergency. Use at own risk.")
300
    else
301-
function levelUpCallback(guiID, id)
301+
        local selected = pageMult * listPageNumber + userList.selectedItem
302-
  local selected = gui.getSelected(myGui, userList)
302+
        userTable[selected].uuid = uuid.next()
303
        updateList()
304
  		userListCallback()
305
    end
306
end
307-
  userListCallback(myGui, userList, selected)
307+
308
function writeCardCallback()
309
  local selected = pageMult * listPageNumber + userList.selectedItem
310-
function levelDownCallback(guiID, id)
310+
  local data =  userTable[selected].date .. " " .. userTable[selected].name .. " " .. userTable[selected].uuid
311-
  local selected = gui.getSelected(myGui, userList)
311+
312
  writer.write(crypted, userTable[selected].name .. "'s security pass", false, 0)
313
end
314
315
function writeAdminCardCallback()
316-
  userListCallback(myGui, userList, selected)
316+
  local data =  adminCard
317
  local crypted = crypt(data, cryptKey)
318
  writer.write(crypted, "ADMIN DIAGNOSTIC CARD", false, 14)
319-
function inputCallback(guiID, textID, text)
319+
320-
  local selected = gui.getSelected(myGui, userList)
320+
321-
  userTable[selected].name = text
321+
function levelUpCallback()
322
  local selected = pageMult * listPageNumber + userList.selectedItem
323-
  userListCallback(myGui, userList, selected)
323+
324
    userTable[selected].level = userTable[selected].level + 1
325
  end
326-
-- main gui setup
326+
327-
myGui = gui.newGui(2, 2, 78, 23, true)
327+
  userListCallback()
328-
button = gui.newButton(myGui, "center", 21, "exit", buttonCallback)
328+
329
 
330-
-- frame with user list
330+
function levelDownCallback()
331-
gui.newFrame(myGui, 1, 1, 30, 18)
331+
  local selected = pageMult * listPageNumber + userList.selectedItem
332-
userList = gui.newList(myGui, 2, 2, 28, 16, {}, userListCallback)
332+
333
    userTable[selected].level = userTable[selected].level - 1
334
  end
335
  updateList()
336
  userListCallback()
337
end
338
 
339-
-- user infos
339+
function armorUpCallback()
340-
gui.newLabel(myGui, 32, 6, "User name : ")
340+
  local selected = pageMult * listPageNumber + userList.selectedItem
341-
gui.newLabel(myGui, 32, 8, "Level     : ")
341+
  if userTable[selected].armory < 4 then
342-
gui.newLabel(myGui, 32, 10, "Blocked   : [yes] / [no]")
342+
    userTable[selected].armory = userTable[selected].armory + 1
343-
userNameText = gui.newText(myGui, 44, 6, 16, "", inputCallback)
343+
344-
userLevelLabel = gui.newLabel(myGui, 44, 8, "")
344+
345-
LevelUpButton = gui.newButton(myGui, 48, 8, "+", levelUpCallback)
345+
  userListCallback()
346-
LevelDownButton = gui.newButton(myGui, 52, 8, "-", levelDownCallback)
346+
347-
cardBlockedYesButton = gui.newButton(myGui, 44, 10, "yes", blockUserCallback)
347+
348-
cardBlockedNoButton = gui.newButton(myGui, 52, 10, "no", unblockUserCallback)
348+
function armorDownCallback()
349-
gui.setEnable(myGui, cardBlockedYesButton, false)
349+
  local selected = pageMult * listPageNumber + userList.selectedItem
350-
gui.setEnable(myGui, cardBlockedNoButton, false)
350+
  if userTable[selected].armory > 0 then
351-
gui.setEnable(myGui, LevelUpButton, false)
351+
    userTable[selected].armory = userTable[selected].armory - 1
352-
gui.setEnable(myGui, LevelDownButton, false)
352+
353-
gui.setEnable(myGui, userNameText, false)
353+
354
  userListCallback()
355-
gui.newHLine(myGui, 32, 12, 43)
355+
356-
userNewButton = gui.newButton(myGui, 2, 21, "new", newUserCallback)
356+
357-
userDeleteButton = gui.newButton(myGui, 9, 21, "delete", deleteUserCallback)
357+
function depUpCallback()
358
  local selected = pageMult * listPageNumber + userList.selectedItem
359-
-- frame with status of the writer
359+
  if userTable[selected].department < 5 then
360-
gui.newFrame(myGui, 57, 1, 19, 3, "Writer status")
360+
    userTable[selected].department = userTable[selected].department + 1
361-
cardStatusLabel = gui.newLabel(myGui, 58, 2, "     No card   ")
361+
362
  updateList()
363-
--updateServerButton = gui.newButton(myGui, 47, 21, "update server", updateServerCallback)
363+
  userListCallback()
364
end
365-
cardWriteButton = gui.newButton(myGui, 64, 21, "write card", writeCardCallback)
365+
366
function depDownCallback()
367
  local selected = pageMult * listPageNumber + userList.selectedItem
368-
gui.clearScreen()
368+
  if userTable[selected].department > 1 then
369-
gui.setTop(prgName .. " " .. version)
369+
    userTable[selected].department = userTable[selected].department - 1
370
  end
371-
event.listen("cardInsert", eventCallback)
371+
372-
event.listen("cardRemove", eventCallback)
372+
  userListCallback()
373-
while true do
373+
374-
  gui.runGui(myGui)
374+
375-
end
375+
function pageUpCallback()
376
  if listPageNumber < #userTable/pageMult - 1 then
377
    listPageNumber = listPageNumber + 1
378
  end
379
  updateList()
380
  userListCallback()
381
end
382
 
383
function pageDownCallback()
384
  if listPageNumber > 0 then
385
    listPageNumber = listPageNumber - 1
386
  end
387
  updateList()
388
  userListCallback()
389
end
390
 
391
function inputCallback()
392
  local selected = pageMult * listPageNumber + userList.selectedItem
393
  userTable[selected].name = userNameText.text
394
  updateList()
395
  userListCallback()
396
end
397
 
398
----------GUI SETUP
399
GUI.alert("NOTICE!!! I updated how the server saves users, so you will have to delete the userlist before opening the application! It is in the root folder. If you already did this or this is the first time opening this, you are alright.")
400
workspace, window, menu = system.addWindow(GUI.filledWindow(2,2,150,45,0xE1E1E1))
401
 
402
local layout = window:addChild(GUI.layout(1, 1, window.width, window.height, 1, 1))
403
 
404
local contextMenu = menu:addContextMenuItem("File")
405
contextMenu:addItem("Close").onTouch = function()
406
window:remove()
407
end
408
 
409
window:addChild(GUI.panel(3,3,60,36,0x6B6E74))
410
userList = window:addChild(GUI.list(4, 4, 58, 34, 3, 0, 0xE1E1E1, 0x4B4B4B, 0xD2D2D2, 0x4B4B4B, 0x3366CC, 0xFFFFFF, false))
411
userList:addItem("HELLO")
412
listPageNumber = 0
413
userTable = loadTable("userlist.txt")
414
if userTable == nil then
415
  userTable = {}
416
end
417
updateList()
418
 
419
--user infos
420
window:addChild(GUI.label(64,12,3,3,0x165FF2,"User name : "))
421
userUUIDLabel = window:addChild(GUI.label(64,14,3,3,0x165FF2,"UUID      : user not selected"))
422
window:addChild(GUI.label(64,16,3,3,0x165FF2,"Level     : "))
423
window:addChild(GUI.label(64,18,3,3,0x165FF2,"MTF       : "))
424
window:addChild(GUI.label(64,20,3,3,0x165FF2,"GOI       : "))
425
window:addChild(GUI.label(64,22,3,3,0x165FF2,"Security  : "))
426
window:addChild(GUI.label(64,24,3,3,0x165FF2,"Intercom  : "))
427
window:addChild(GUI.label(64,26,3,3,0x165FF2,"STAFF     : "))
428
window:addChild(GUI.label(64,28,3,3,0x165FF2,"ArmorLevel: "))
429
window:addChild(GUI.label(64,30,3,3,0x165FF2,"Department: "))
430
window:addChild(GUI.label(64,32,3,3,0x165FF2,"Blocked   : "))
431
432
listPageLabel = window:addChild(GUI.label(4,38,3,3,0x165FF2,tostring(listPageNumber + 1)))
433
listUpButton = window:addChild(GUI.button(8,38,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "+"))
434
listUpButton.onTouch = pageUpCallback
435
listDownButton = window:addChild(GUI.button(12,38,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "-"))
436
listDownButton.onTouch = pageDownCallback
437
438
userNameText = window:addChild(GUI.input(88,12,16,1, 0xEEEEEE, 0x555555, 0x999999, 0xFFFFFF, 0x2D2D2D, "", "input name"))
439
userNameText.onInputFinished = inputCallback
440
userLevelLabel = window:addChild(GUI.label(88,16,3,3,0x165FF2,"#"))
441
LevelUpButton = window:addChild(GUI.button(92,16,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "+"))
442
LevelUpButton.onTouch = levelUpCallback
443
LevelDownButton = window:addChild(GUI.button(96,16,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "-"))
444
LevelDownButton.onTouch = levelDownCallback
445
MTFYesButton = window:addChild(GUI.button(88,18,16,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "toggle"))
446
MTFYesButton.switchMode = true
447
MTFYesButton.onTouch = mtfUserCallback
448
GOIYesButton = window:addChild(GUI.button(88,20,16,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "toggle"))
449
GOIYesButton.switchMode = true
450
GOIYesButton.onTouch = goiUserCallback
451
SecYesButton = window:addChild(GUI.button(88,22,16,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "toggle"))
452
SecYesButton.switchMode = true
453
SecYesButton.onTouch = secUserCallback
454
IntYesButton = window:addChild(GUI.button(88,24,16,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "toggle"))
455
IntYesButton.switchMode = true
456
IntYesButton.onTouch = intUserCallback
457
StaffYesButton = window:addChild(GUI.button(88,26,16,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "toggle"))
458
StaffYesButton.switchMode = true
459
StaffYesButton.onTouch = staffUserCallback
460
userArmoryLabel= window:addChild(GUI.label(88,28,3,3,0x165FF2,"#"))
461
ArmoryUpButton = window:addChild(GUI.button(92,28,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "+"))
462
ArmoryUpButton.onTouch = armorUpCallback
463
ArmoryDownButton= window:addChild(GUI.button(96,28,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "-"))
464
ArmoryDownButton.onTouch = armorDownCallback
465
userDepLabel = window:addChild(GUI.label(88,30,3,3,0x165FF2,"NAN"))
466
DepUpButton = window:addChild(GUI.button(92,30,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "+"))
467
DepUpButton.onTouch = depUpCallback
468
DepDownButton = window:addChild(GUI.button(96,30,3,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "-"))
469
DepDownButton.onTouch = depDownCallback
470
cardBlockedYesButton = window:addChild(GUI.button(88,32,16,1, 0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "toggle"))
471
cardBlockedYesButton.switchMode = true
472
cardBlockedYesButton.onTouch = blockUserCallback
473
 
474
LevelUpButton.disabled = true
475
LevelDownButton.disabled = true
476
ArmoryUpButton.disabled = true
477
ArmoryDownButton.disabled = true
478
DepUpButton.disabled = true
479
DepDownButton.disabled = true
480
userNameText.disabled = true
481
MTFYesButton.disabled = true
482
GOIYesButton.disabled = true
483
SecYesButton.disabled = true
484
IntYesButton.disabled = true
485
StaffYesButton.disabled = true
486
cardBlockedYesButton.disabled = true
487
 
488
--Line and user buttons
489
 
490
window:addChild(GUI.panel(64,36,86,1,0x6B6E74))
491
userNewButton = window:addChild(GUI.button(4,42,16,1,0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "new"))
492
userNewButton.onTouch = newUserCallback
493
userDeleteButton = window:addChild(GUI.button(18,42,16,1,0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "delete")) 
494
userDeleteButton.onTouch = deleteUserCallback
495
userChangeUUIDButton = window:addChild(GUI.button(32,42,16,1,0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "reset uuid")) 
496
userChangeUUIDButton.onTouch = changeUUID
497
createAdminCardButton = window:addChild(GUI.button(46,42,16,1,0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "admin card")) 
498
createAdminCardButton.onTouch = writeAdminCardCallback
499
 
500
--CardWriter frame
501
 
502
window:addChild(GUI.panel(114, 2, 38, 6, 0x6B6E74))
503
cardStatusLabel = window:addChild(GUI.label(116, 4, 3,3,0x165FF2,"     No card   "))
504
 
505
--write card button
506
cardWriteButton = window:addChild(GUI.button(128,42,16,1,0xFFFFFF, 0x555555, 0x880000, 0xFFFFFF, "write")) 
507
cardWriteButton.onTouch = writeCardCallback 
508
 
509
event.addHandler(eventCallback)
510
 
511
workspace:draw()
512
workspace:start()
513