add extra pull event statements temporarily

This commit is contained in:
zontreck 2024-03-28 13:34:32 -07:00
parent a71fa2d012
commit 8e915b20c8
7 changed files with 72 additions and 50 deletions

View file

@ -132,7 +132,7 @@ function getStatus(choice,pass)
if attempts==0 then
lockout()
end
end
end
@ -152,7 +152,7 @@ end
function success()
shell.run("/fos/mainMenu")
end
end
--highlights part of an eString
@ -178,7 +178,13 @@ function eventListener(leftStr,rightStr,pass)
--addCustomStatus("P3"..tostring(p3))
drawStatus()
if ev=="key_up" then
if ev == "terminate" then
addCustomStatus("Unable to")
addCustomStatus("terminate")
addCustomStatus("program")
addCustomStatus(" ")
addCustomStatus("System locked")
elseif ev=="key_up" then
if inTable(p1,keys) and not onWord then
lowlight(cursorX,cursorY,selection)
elseif inTable(p1,keys) and onWord then
@ -189,6 +195,7 @@ function eventListener(leftStr,rightStr,pass)
end
end
if p1==265 and cursorY>lowerY then --up arrow
cursorY=cursorY-1
elseif p1==264 and cursorY<upperY then --down arrow
@ -211,7 +218,7 @@ function eventListener(leftStr,rightStr,pass)
getStatus(selection:upper(),pass:upper())
drawStatus()
drawAttempts(attempts)
if selection:upper()==pass:upper() then
if selection:upper()==pass:upper() then
success()
end
end
@ -253,7 +260,7 @@ function eventListener(leftStr,rightStr,pass)
end
end
end
if side=="left" then
charPos=math.floor(((cursorY-7)*10)+(cursorX-9)+1)
selection=string.sub(leftStr,charPos,charPos)
@ -261,7 +268,7 @@ function eventListener(leftStr,rightStr,pass)
charPos=math.floor(((cursorY-7)*10)+(cursorX-27)+1)
selection=string.sub(rightStr,charPos,charPos)
end
if isalpha(selection) and side=="left" then
selection = findWord(cursorX,cursorY,charPos,leftStr,side)
lightWord(selection,leftStr,side)
@ -310,31 +317,31 @@ function findWord(x,y,charPos,eString,side)
while isalpha(string.sub(eString:upper(),right+1,right+1)) do
right=right+1
end
--highlight the word
for i=left,right do
local x,y = posToCoords(i,side)
highlight(x,y,string.sub(eString:upper(),i,i))
end
return(string.sub(eString:upper(),left,right))
return(string.sub(eString:upper(),left,right))
end
function posToCoords(pos,side)
local x,y=0,0
if side=="left" then
if pos%10~=0 then
if pos%10~=0 then
x=pos%10+8
y=math.floor(pos/10)+7
else
else
x=10+8
y=math.floor(pos/10)+6
end
else
if pos%10~=0 then
if pos%10~=0 then
x=pos%10+26
y=math.floor(pos/10)+7
else
else
x=10+26
y=math.floor(pos/10)+6
end
@ -395,7 +402,7 @@ function drawHex(x,y)
for j=1,4 do hstring=hstring..randomHex() end
term.write(hstring)
y = y + 1
end
end
end
--returns string containing random nonletter characters
@ -409,14 +416,14 @@ function getEncoded(size,words)
local chance = 0
local encodedString=nonletter()
local lastIsWord=false
--fills encodedString with nonletter chars and words
repeat
step=step+1
chance = math.random(1,13)
chance = math.random(1,13)
if chance==6 and not onWord and not lastIsWord and totalWords<=8 then
local reps=0
repeat
repeat
if reps>20 then break end
curWord=words[math.random(1,#words)]
reps=reps+1
@ -428,10 +435,10 @@ function getEncoded(size,words)
encodedString=encodedString..string.sub(curWord,charIter,charIter)
charIter=charIter+1
if charIter>#curWord then
table.insert(usedWords,curWord)
table.insert(usedWords,curWord)
onWord=false
totalWords=totalWords+1
lastIsWord=true
lastIsWord=true
charIter=1
end
else
@ -457,7 +464,7 @@ function drawEncoded(x,y,rows,cols,eString,lightS,lightE)
for i=1,rows*cols do
term.setCursorPos(curX,curY)
term.write(string.sub(eString,i,i))
if i%cols==0 then
if i%cols==0 then
curY=curY+1
curX=x
else
@ -487,7 +494,7 @@ function nonletter()
']','|',',','\'','\"','}',
';',':','.','>','<','?'}
return(possible[math.random(1,#possible)])
end
end
--returns one valid hex num (random)
function randomHex()
@ -502,7 +509,7 @@ end
function commonLetters(s1,s2)
charsInCommon=0
local long,short=nil,nil
if string.len(s1:upper())>=string.len(s2:upper()) then long,short=s1:upper(),s2:upper()
if string.len(s1:upper())>=string.len(s2:upper()) then long,short=s1:upper(),s2:upper()
else long,short=s2:upper(),s1:upper() end
for i=1,#long do
if string.sub(long,i,i)==string.sub(short,i,i) then
@ -511,7 +518,7 @@ function commonLetters(s1,s2)
break
end
end
return charsInCommon
return charsInCommon
end
--clears a line from x,y till the end of the screen

View file

@ -21,7 +21,6 @@ function main()
writeSettings()
options = newSystemOptions
optionsScripts = newSystemOptsScripts
end
drawMenuOptions()
@ -31,19 +30,16 @@ function main()
end
function eventListener(index)
-- highlight(index)
highlight(index)
os.pullEventRaw()
-- No selection until first arrow key is pressed!
while true do
local event, keyCode, cursorX, cursorY = os.pullEventRaw()
local event, keyCode = os.pullEventRaw()
if event == "key_up" then
if keyCode == 265 then
if not selection then
selection = true
else
deselect(selectedIndex)
end
deselect(selectedIndex)
selectedIndex = selectedIndex - 1
if selectedIndex < 1 then
selectedIndex = 1
@ -51,11 +47,7 @@ function eventListener(index)
highlight(selectedIndex)
elseif keyCode == 264 then
if not selection then
selection = true
else
deselect(selectedIndex)
end
deselect(selectedIndex)
selectedIndex = selectedIndex + 1
if selectedIndex > #options then
selectedIndex = #options
@ -63,23 +55,27 @@ function eventListener(index)
highlight(selectedIndex)
elseif keyCode == 257 then
if selection then
flicker(selectedIndex)
sleep(1)
highlight(selectedIndex)
flicker(selectedIndex)
sleep(1)
highlight(selectedIndex)
-- Perform action
shell.run(optionsScripts[selectedIndex])
readSettings()
term.clear()
drawTitle()
drawMenuOptions()
-- Perform action
if optionsScripts[selectedIndex] == "*" then
-- This code reads a menu page and will load the menu
-- Menu location: /fosdata/menus/options[selectedIndex]
end
shell.run(optionsScripts[selectedIndex])
readSettings()
term.clear()
drawTitle()
drawMenuOptions()
os.pullEventRaw()
end
end

16
programs/setAdminPin.lua Normal file
View file

@ -0,0 +1,16 @@
require "settingsFile"
readSettings()
term.clear()
drawTitle()
term.setCursorPos(2, 6)
term.write("ENTER THE ADMIN PIN> ")
adminPin = read("*")
writeSettings()
term.setCursorPos(2,4)
term.clearLine()
term.write("ADMIN PIN UPDATED")

View file

@ -12,4 +12,5 @@ hostname = read()
writeSettings()
term.setCursorPos(2,4)
term.clearLine()
term.write("HOSTNAME UPDATED")

View file

@ -12,4 +12,5 @@ name = read()
writeSettings()
term.setCursorPos(2,4)
term.clearLine()
term.write("USER NAME UPDATED")

View file

@ -4,4 +4,5 @@ file.close()
term.setCursorPos(2,4)
term.clearLine()
term.write("SYSTEM SET TO ACTIVE")

View file

@ -1,4 +1,4 @@
local myVersion = "1.0.032824.0356"
local myVersion = "1.0.032824.1301"
function printVersion()
term.setCursorPos(2,18)