Posted 01 January 2014 - 07:38 PM
Okay so I am making an OS: although I have a problem!
my os doesn't really do much on the homescreen… It waits for the character input but doesn't respond to rednet or the updating clock inputs. Help anyone??
My code for the homescreen is:
and the draw time function is:
my os doesn't really do much on the homescreen… It waits for the character input but doesn't respond to rednet or the updating clock inputs. Help anyone??
My code for the homescreen is:
function homeScreen() -- Finished
redMsgCount = 0
uapi.cs()
local feed = uapi.loadConfig("whatsnew")
-- Draw Instructions
uapi.drawBox(1, 51, 19, 1, " ", txtColour, bkgColour)
drawTime()
-- Draw time at bottom of screen
uapi.drawBox(1, 51, 18, 1, " ", txtColour, bkgColour)
uapi.printC("Rednet Messages Received: "..redMsgCount, 18, false, txtColour, bkgColour)
-- Create top banner
uapi.drawBox(1, 51, 1, 1, " ", txtColour, bkgColour)
uapi.printC("uOS -> Welcome "..username, 1, false, txtColour, bkgColour)
-- Draw options list
paintutils.drawLine(1,2,1,17,colours[bkgColour])
paintutils.drawLine(51,2,51,17,colours[bkgcolour])
uapi.printA("1. Main menu", 3, 3, false, txtColour, bkgColour)
uapi.printA("2. CraftOS Boot", 3, 5, false, txtColour, bkgColour)
-- Draw whastnew feed
-- FIX LATER
uapi.printA("Any bugs you may find, please report them!!", 5, 17, false, "white", "black")
if not modemSide == nil then -- Opens rednet
rednet.open(modemSide)
end
while true do -- Clock, Rednet, Char Events
local event, arg1, arg2, arg3, arg4, arg5 = os.pullEvent()
if event == "timer" and arg1 == timer then -- Timer Input
drawTime()
os.startTimer(1)
elseif event == "rednet" then -- Rednet messages
intSenderID = tostring(arg1)
strSerMessage = arg2
intDisTravelled = tostring(arg3)
strMessage = textutils.unserialize(strSerMessage)
if fs.exists("msgs/"..intSenderID) == true then -- deletes message from same sender if exists
fs.delete("msgs/"..intSenderID)
end
file = fs.open("msgs/"..intSenderID, "w")
file.writeLine("Sender ID: "..intSenderID)
file.writeLine("Distance: "..intDisTravelled.." blocks away")
file.write(strMessage)
file.close()
rednet.send(arg1, "Auto:R")
redMsgCount = tonumber(redMsgCount)
redMsgCount = redMsgCount + 1
redMsgCount = tostring(redMsgCount)
uapi.printC("Rednet Messages Received: "..redMsgCount, 18, false, txtColour, bkgColour)
elseif event == "char" then -- Actual User Input
if arg1 == "1" then
mainMenu()
elseif arg1 == "2" then
termBoot()
end
end
end
end
and the draw time function is:
function drawTime() -- Finished
worldTime = textutils.formatTime(os.time())
worldDate = os.day()
uapi.printC("World Time: "..worldTime.." Day: "..worldDate, 19, false, txtColour, bkgColour)
end