Help appriciated!
-Dapperwbs
how to i copy and paste it in? where would it be stored in the files of the mod?
os = os.pullEventRaw()
m = peripheral.wrap("left")
m.setTextColor(1)
m.setTextScale(1)
local w,h = m.getSize()
function printCen(y,s)
local x = math.floor((w - string.len(s)) /2)
local xm = math.floor((51- string.len(s)) /2)
m.setCursorPos(x,y)
term.setCursorPos(xm,y)
m.clearLine()
term.clearLine()
m.write(s)
print(s)
end
printCen(1,"MACRO OSX")
m.setCursorPos(1,4)
m.write("Loading")
term.clear()
term.setCursorPos(1,1)
print("MACRO OSX")
print("Loading")
sleep(5)
term.setCursorPos(17,15)
textutils.slowPrint("..................")
m.setBackgroundColor(3)
sleep(3)
m.clear()
term.clear()
local option = 1
function numSel()
local e,p = os
if e == "key" then
local key = p
if key == 119 then
if option < 4 then
option = option + 1
end
elseif key == 155 then
if option > 1 then
option = option - 1
end
end
end
end
function lineRemove()
m.clearLine(math.floor(h/2))
term.clearLine(math.floor(h/2))
m.clearLine(math.floor(h/2) + 1)
term.clearLine(math.floor(h/2) + 1)
m.clearLine(math.floor(h/2) + 2)
term.clearLine(math.floor(h/2) + 2)
m.clearLine(math.floor(h/2) + 3)
term.clearLine(math.floor(h/2) + 3)
end
printCen(1,"MACRO OSX Official")
sleep(2)
while true do
numSel()
lineRemove()
if option == 1 then
m.setTextColor(9)
term.setTextColor(9)
printCen(math.floor(h/2),"Command Promt")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 1,"Programs")
printCen(math.floor(h/2) + 2,"ShutDown")
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 2 then
printCen(math.floor(h/2),"Command Prompt")
m.setTextColor(9)
term.setTextColor(9)
printCen(math.floor(h/2) + 1,"Programs")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 2,"ShutDown")
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 3 then
printCen(math.floor(h/2),"Command Prompt")
printCen(math.floor(h/2) + 1,"Programs")
m.setTextColor(9)
term.setTextColor(9)
printCen(math.floor(h/2) + 2,"ShutDown")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 4 then
printCen(math.floor(h/2),"Command Prompt")
printCen(math.floor(h/2) + 1,"Programs")
printCen(math.floor(h/2) + 2,"ShutDown")
m.setTextColor(9)
term.setTextColor(9)
print(math.floor(h/2) + 3,"Uninstall")
m.setTextColor(1)
term.setTextColor(1)
end
end
print(math.floor(h/2) + 3,"Uninstall") --Edit D: should be printCen
I think that's a typo
m.setTextColor(9)
m.setBackgroundColor(3)
I thought only numbers that could be represented by 2^n, as well as 0, were valid? Maybe I'm wrong?
do
local nativeBlit = m.blit
m.blit = function(a, b, c)
term.setTextColor(colors.white)
term.setBackgroundColor(colors.black)
print("Blitting in 1s")
sleep(1)
if not pcall(nativeblit, a, b, c) then
term.setBackgroundColor(colors.black)
error("Blit error")
end
print("Blit success!")
end
And tell me the output
colors.white = 1
colors.orange = 2
colors.magenta = 4
colors.lightBlue = 8
colors.yellow = 16
colors.lime = 32
colors.pink = 64
colors.gray = 128
colors.lightGray = 256
colors.cyan = 512
colors.purple = 1024
colors.blue = 2048
colors.brown = 4096
colors.green = 8192
colors.red = 16384
colors.black = 32768
Using this color lookup, you can either type the number after the "=" or the word before the "="
term.setTextColor(colors.orange) --This is orange
term.setTextColor(2) --This is also orange
os = os.pullEventRaw("key")
os, key = os.pullEventRaw("key")
local e, p = os
local key = p
os.pullEvent = os.pullEventRaw
local function fWrapTerm(tOldTerm)
local tMyTerm = {}
for k, v in pairs(tOldTerm) do tMyTerm[k]=function(...)return v(table.unpack({...})) end end
tMyTerm.write = function(tText, bCentered)
if bCentered~=false then
local nX, nY = tOldTerm.getCursorPos()
local nL, nH = tOldTerm.getSize()
tOldTerm.setCursorPos(math.floor(nL/2-#tText/2), nY)
end
tOldTerm.write(tText)
end
tMyTerm.current = function()
return tMyTerm
end
return tMyTerm
end
local tMon = peripheral.wrap("left") or peripheral.find("monitor") or term.current() or error("NO MONITORS FOUND")
local tWrappedTerm = fWrapTerm(term.current())
local tWrappedMon = fWrapTerm(tMon)
local function fGeneralWrite(tText, bIsCentered)
tWrappedTerm.write(tText, bIsCentered)
tWrappedMon.write(tText, bIsCentered)
end
local function fResetTerm(term)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1, 1)
term.setCursorBlink(false)
end
local function fMenu(sHead, tMenu, tColors, tTerm)
fResetTerm(tTerm)
local tOldTerm = term.current()
term.redirect(tTerm)
local nL, nH = tTerm.getSize()
local nDown = 1
tTerm.setTextColor((tTerm.isColor() and colors.green) or colors.white)
if sHead then nDown = 2 + write(sHead) end
term.redirect(window.create(term.current(), 1, nDown, nL, nH-nDown+1, true))
nL, nH = term.getSize()
local nMinShow, nItem = 1, 1
while true do
term.clear()
term.setCursorPos(1, 1)
if nMinShow>nItem then nMinShow = nItem end
if (nMinShow+nH-2)<nItem then nMinShow = nMinShow+1 end
if (nItem == #tMenu) and nH < #tMenu then nMinShow = nItem-nH+1 end
for nI = nMinShow, nMinShow + nH-2 do
if tColors then term.setTextColor(tColors[nI] or colors.white) end
if nI == nItem then
term.setTextColor(colors.gray)
write(tMenu[nI])
if not (nI == #tMenu) then print() end
else
print(tMenu[nI] or "")
end
end
if nMinShow + (nH - 1) < #tMenu then
term.setCursorPos(1, nH)
term.setTextColor(colors.white)
term.write("[MORE OPTIONS BELOW]")
elseif nMinShow + (nH - 1) == #tMenu then
term.setCursorPos(1, nH)
if nItem == #tMenu then
term.setTextColor(colors.gray)
term.write(tMenu[#tMenu])
else
if tColors then term.setTextColor(tColors[#tMenu] or colors.white) end
term.write(tMenu[#tMenu])
end
end
term.setTextColor(colors.white)
local tEvent = {os.pullEvent("key")}
if (tEvent[2] == keys.down) and (nItem < #tMenu) then nItem = nItem + 1 end
if (tEvent[2] == keys.up) and (nItem > 1) then nItem = nItem - 1 end
if (tEvent[2] == keys.enter) then term.redirect(tOldTerm) return nItem end
os.queueEvent(os.pullEvent())
end
end
fResetTerm(term)
fResetTerm(tMon)
tMon.setTextScale(1)
tWrappedMon.write("MACRO OSX")
term.write("MACRO OSX\nLoading")
term.setCursorPos(17,15)
textutils.slowPrint("..................")
sleep(3)
fResetTerm(term)
fResetTerm(tMon)
fGeneralWrite("MACRO OSX Official")
sleep(2)
local opt
local function wrapMenu(myterm)
return function() opt = fMenu("MACRO OSX Official command prompt", {"Programs", "Power", "Uninstall"}, {nil, nil, colors.red}, myterm) end
end
parallel.waitForAny(wrapMenu(tWrappedTerm), wrapMenu(tWrappedMon))
if opt == 1 then
--Do something
elseif opt ==2 then
--Do something
elsif opt == 3 then
--Do something
end
m = peripheral.wrap("left")
m.setTextColor(1)
m.setTextScale(1)
local w,h = m.getSize()
function printCen(y,s)
local x = math.floor((w - string.len(s)) /2)
local xm = math.floor((51- string.len(s)) /2)
m.setCursorPos(x,y)
term.setCursorPos(xm,y)
m.clearLine()
term.clearLine()
m.write(s)
print(s)
end
printCen(1,"MACRO OSX")
m.setCursorPos(1,4)
m.write("Loading")
term.clear()
term.setCursorPos(1,1)
print("MACRO OSX")
print("Loading")
sleep(2)
term.setCursorPos(17,15)
textutils.slowPrint("..................")
m.setBackgroundColor(2)
sleep(3)
m.clear()
term.clear()
local option = 1
printCen(1,"MACRO OSX Official")
function numSel()
if e == "key" then
if key == keys.w then
if option < 4 then
option = option + 1
end
elseif key == keys.s then
if option > 1 then
option = option - 1
end
end
end
end
function lineRemove()
m.clearLine(math.floor(h/2))
term.clearLine(math.floor(h/2))
m.clearLine(math.floor(h/2) + 1)
term.clearLine(math.floor(h/2) + 1)
m.clearLine(math.floor(h/2) + 2)
term.clearLine(math.floor(h/2) + 2)
m.clearLine(math.floor(h/2) + 3)
term.clearLine(math.floor(h/2) + 3)
end
while true do
sleep(0.05)
local e,key = os.pullEvent("key")
numSel()
lineRemove()
if option == 1 then
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2),"Command Prompt")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 1,"Programs")
printCen(math.floor(h/2) + 2,"ShutDown")
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 2 then
printCen(math.floor(h/2),"Command Prompt")
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2) + 1,"Programs")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 2,"ShutDown")
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 3 then
printCen(math.floor(h/2),"Command Prompt")
printCen(math.floor(h/2) + 1,"Programs")
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2) + 2,"ShutDown")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 4 then
printCen(math.floor(h/2),"Command Prompt")
printCen(math.floor(h/2) + 1,"Programs")
printCen(math.floor(h/2) + 2,"ShutDown")
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2) + 3,"Uninstall")
m.setTextColor(1)
term.setTextColor(1)
end
end
alright i altered my code and cant seem to find the error with my key input once again any help?
m = peripheral.wrap("left")
m.setTextColor(1)
m.setTextScale(1)
local w,h = m.getSize()
function printCen(y,s)
local x = math.floor((w - string.len(s)) /2)
local xm = math.floor((51- string.len(s)) /2)
m.setCursorPos(x,y)
term.setCursorPos(xm,y)
m.clearLine()
term.clearLine()
m.write(s)
print(s)
end
printCen(1,"MACRO OSX")
m.setCursorPos(1,4)
m.write("Loading")
term.clear()
term.setCursorPos(1,1)
print("MACRO OSX")
print("Loading")
sleep(2)
term.setCursorPos(17,15)
textutils.slowPrint("..................")
m.setBackgroundColor(2)
sleep(3)
m.clear()
term.clear()
local option = 1
printCen(1,"MACRO OSX Official")
function numSel()
if e == "key" then
if key == keys.w then
if option < 4 then
option = option + 1
end
elseif key == keys.s then
if option > 1 then
option = option - 1
end
end
end
end
function lineRemove()
m.clearLine(math.floor(h/2))
term.clearLine(math.floor(h/2))
m.clearLine(math.floor(h/2) + 1)
term.clearLine(math.floor(h/2) + 1)
m.clearLine(math.floor(h/2) + 2)
term.clearLine(math.floor(h/2) + 2)
m.clearLine(math.floor(h/2) + 3)
term.clearLine(math.floor(h/2) + 3)
end
while true do
sleep(0.05)
local e,key = os.pullEvent("key")
numSel(e, key)
lineRemove()
if option == 1 then
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2),"Command Prompt")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 1,"Programs")
printCen(math.floor(h/2) + 2,"ShutDown")
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 2 then
printCen(math.floor(h/2),"Command Prompt")
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2) + 1,"Programs")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 2,"ShutDown")
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 3 then
printCen(math.floor(h/2),"Command Prompt")
printCen(math.floor(h/2) + 1,"Programs")
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2) + 2,"ShutDown")
m.setTextColor(1)
term.setTextColor(1)
printCen(math.floor(h/2) + 3,"Uninstall")
elseif option == 4 then
printCen(math.floor(h/2),"Command Prompt")
printCen(math.floor(h/2) + 1,"Programs")
printCen(math.floor(h/2) + 2,"ShutDown")
m.setTextColor(4)
term.setTextColor(4)
printCen(math.floor(h/2) + 3,"Uninstall")
m.setTextColor(1)
term.setTextColor(1)
end
end
nvm i got it THANK YOU SO MUCH guys for the help
function numSel(e,key)
if e == "key" then
if key == keys.w then
if option < 4 then
option = option + 1
end
elseif key == keys.s then
if option > 1 then
option = option - 1
end
end
end
end
it works but if i swap the + and -
function numSel(e,key)
if e == "key" then
if key == keys.w then
if option < 4 then
option = option - 1
end
elseif key == keys.s then
if option > 1 then
option = option + 1
end
end
end
end
it doesnt work any help?
os.pullEvent = os.pullEventRaw
local function fWrapTerm(tOldTerm)
local tMyTerm = {}
for k, v in pairs(tOldTerm) do tMyTerm[k]=function(...)return v(table.unpack({...})) end end
tMyTerm.write = function(tText, bCentered)
if bCentered~=false then
local nX, nY = tOldTerm.getCursorPos()
local nL, nH = tOldTerm.getSize()
tOldTerm.setCursorPos(math.floor(nL/2-#tText/2), nY)
end
tOldTerm.write(tText)
end
return tMyTerm
end
local tMon = peripheral.wrap("left") or peripheral.find("monitor") or term.current() or error("NO MONITORS FOUND")
local tWrappedTerm = fWrapTerm(term.current())
local tWrappedMon = fWrapTerm(tMon)
local function fGeneralWrite(tText, bIsCentered)
tWrappedTerm.write(tText, bIsCentered)
tWrappedMon.write(tText, bIsCentered)
end
local function fResetTerm(term)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
term.clear()
term.setCursorPos(1, 1)
term.setCursorBlink(false)
end
local cacheE = {""}
local function fMenu(sHead, tMenu, tColors, tTerm)
fResetTerm(tTerm)
local tOldTerm = term.current()
term.redirect(tTerm)
local nL, nH = tTerm.getSize()
local nDown = 1
tTerm.setTextColor((tTerm.isColor() and colors.green) or colors.white)
term.setCursorPos(math.floor(nL/2-#sHead/2), 1)
if sHead then nDown = 2 + write(sHead) end
nL, nH = term.getSize()
local nMinShow, nItem = 1, 1
local tMyWindow = fWrapTerm(window.create(term.current(), 1, nDown, nL, nH-nDown+1, true))
while true do
term.redirect(tMyWindow)
term.clear()
term.setCursorPos(1, 1)
if nMinShow>nItem then nMinShow = nItem end
if (nMinShow+nH-2)<nItem then nMinShow = nMinShow+1 end
if (nItem == #tMenu) and nH < #tMenu then nMinShow = nItem-nH+1 end
for nI = nMinShow, nMinShow + nH-2 do
if tColors then term.setTextColor(tColors[nI] or colors.white) end
if nI == nItem then
term.setTextColor(colors.gray)
if tMenu[nI] then
write(tMenu[nI])
end
if not (nI == #tMenu) then print() end
else
if tMenu[nI] then
print(tMenu[nI])
end
end
end
if nMinShow + (nH - 1) < #tMenu then
term.setCursorPos(1, nH)
term.setTextColor(colors.white)
term.write("[MORE OPTIONS BELOW]")
elseif nMinShow + (nH - 1) == #tMenu then
term.setCursorPos(1, nH)
if nItem == #tMenu then
term.setTextColor(colors.gray)
term.write(tMenu[#tMenu])
else
if tColors then term.setTextColor(tColors[#tMenu] or colors.white) end
term.write(tMenu[#tMenu])
end
end
term.setTextColor(colors.white)
local tEvent = {os.pullEvent("key")}
if (tEvent[2] == keys.down) and (nItem < #tMenu) then nItem = nItem + 1 end
if (tEvent[2] == keys.up) and (nItem > 1) then nItem = nItem - 1 end
if (tEvent[2] == keys.enter) then term.redirect(tOldTerm) return nItem end
end
end
fResetTerm(term)
fResetTerm(tMon)
tMon.setTextScale(1)
tWrappedMon.write("MACRO OSX")
term.write("MACRO OSX\nLoading")
term.setCursorPos(17,15)
textutils.slowPrint("..................")
sleep(3)
fResetTerm(term)
fResetTerm(tMon)
fGeneralWrite("MACRO OSX Official")
sleep(2)
local opt
local function wrapMenu(myterm)
return function() opt = fMenu("Command Prompt", {"Programs", "Power", "Uninstall"}, {nil, nil, colors.red}, myterm) end
end
parallel.waitForAny(wrapMenu(term.current()), wrapMenu(tMon))
if opt == 1 then
--Do something
elseif opt ==2 then
--Do something
elseif opt == 3 then
--Do something
end