makerimages, on 23 September 2013 - 12:34 PM, said:
-snip-
By the way, the Tutorials section is far from lacking of coroutine tutorials. True, there's less of them than of door locks, but one well made tutorial would be enough of those too.
Posted 23 September 2013 - 12:59 PM
makerimages, on 23 September 2013 - 12:34 PM, said:
Posted 24 September 2013 - 08:00 AM
programCache={}
routineCache={}
local xPos=0
local yPos=0
table.insert(programCache,function() shell.run("OSCore/desktop",xPos,yPos)end)
local routine=nil;
function startCoroutines()
for i=1, #programCache,1 do
routine=coroutine.create(programCache[i])
table.insert(routineCache,routine)
ok, err=coroutine.resume(routine)
end
end
function updateCoroutines()
for i=1, #routineCache,1 do
if coroutine.status(routineCache[i])=="suspended" then
ok, err=coroutine.resume(routineCache[i],xPos,yPos)
end
end
end
startCoroutines()
while true do
event, button, xPos, yPos = os.pullEvent("mouse_click")
updateCoroutines()
end
local tArgs = {...}
os.loadAPI("Apis/DesignUtil")
os.loadAPI("Apis/AccountSytem")
os.loadAPI("Apis/windowSystem")
DesignUtil.setDesign("whiteLightGray")
local background,topBar =DesignUtil.getDesign()
local showOS1Menu = false;
term.setTextColor(colors.gray)
if #tArgs<1 then
error("Desktop: expected mouse_click coordinates X and Y, but they were not given!")
end
function registerClickEvent(x,y)
if x >=0 and x <=1+3-1 and y >=0 and y <=1+1-1 then
showOS1Menu= not showOS1Menu
end
end
function printOS1Menu()
if showOS1Menu then
term.setBackgroundColor(colors.lightGray)
term.setCursorPos(1,2)
print("About this device")
term.setCursorPos(1,3)
print("Software update ")
term.setCursorPos(1,4)
print("Restart device ")
term.setCursorPos(1,5)
print("Shut down ")
end
end
while true do
paintutils.drawImage(background,1,1)
paintutils.drawImage(topBar,1,1)
printOS1Menu()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.lightGray)
print("O1|")
registerClickEvent(tonumber(tArgs[1]),tonumber(tArgs[2]))
sleep(1)
end
Posted 24 September 2013 - 08:45 AM
makerimages, on 24 September 2013 - 08:00 AM, said:
Posted 25 September 2013 - 08:23 AM
local window=nil;
function createWindow(title,x,y,w,h,closeable,text)
window=
{
titlew=title;
x=x;
y=y;
W=w;
H=h;
ca=closeable;
text=text;
}
return window
end
function drawWindow(windowp)
term.setCursorPos(window.x,window.y)
term.setBackgroundColor(colors.lightGray)
for i=0, windowp.W do
term.setCursorPos(windowp.x+i,windowp.y)
print(" ")
term.setCursorPos(windowp.x+i,windowp.y+windowp.H)
print(" ")
end
for j=0, windowp.H do
term.setCursorPos(windowp.x,windowp.y+j)
print(" ")
term.setCursorPos(windowp.x+windowp.W,windowp.y+j)
print(" ")
end
term.setCursorPos(windowp.x+windowp.W/2-string.len(windowp.titlew)/2,windowp.y)
term.setTextColor(colors.gray)
print(windowp.titlew)
if(windowp.ca) then
term.setBackgroundColor(colors.red)
term.setCursorPos(windowp.x+windowp.W+1,windowp.y)
print("X")
term.setBackgroundColor(colors.white)
end
term.setCursorPos(windowp.x+2,windowp.y+2)
for i in string.gmatch(windowp.text,"[^\n]+") do
print(i)
x,y=term.getCursorPos()
if i== " " then
term.setCursorPos(windowp.x+1,y)
end
end
end
programCache={}
routineCache={}
local evt={}
--table.insert(programCache,function() shell.run("OSCore/desktop")end)
local routine=nil;
os.queueEvent("abc", 6, "meow")
function startCoroutines()
for i=1, #programCache,1 do
routine=coroutine.create(programCache[i])
table.insert(routineCache,routine)
ok, err=coroutine.resume(routine,unpack(evt))
end
end
function updateCoroutines()
for i=1, #routineCache,1 do
if coroutine.status(routineCache[i])=="suspended" then
ok, err=coroutine.resume(routineCache[i],unpack(evt))
end
end
end
function addCoroutine(functionD)
table.insert(programCache,functionD)
startCoroutines()
updateCoroutines()
end
function removeCoroutine(functionD)
for k,v in ipairs(programCache) do
if v==functionD then
table.remove(programCache,k)
end
end
end
if loggedStatus then
addCoroutine(function() shell.run("OSCore/desktop")end)
end
while true do
evt={os.pullEvent()}
updateCoroutines()
end
os.loadAPI("Apis/DesignUtil")
os.loadAPI("Apis/AccountSytem")
os.loadAPI("Apis/windowSystem")
DesignUtil.setDesign("whiteLightGray")
local background,topBar =DesignUtil.getDesign()
local showOS1Menu = false;
term.setTextColor(colors.gray)
local OS1MenuB={
text="O1|";
x=1;
y=1;
W=3;
H=1;
}
local OS1MenuSelections=
{
s1Text="About this device";
s1X=1;
s1Y=2;
s1W=17;
s1H=1;
s2Text="Software update ";
s2X=1;
s2Y=3;
s2W=17;
s2H=1;
s3Text="Restart device ";
s3X=1;
s3Y=4;
s3W=17;
s3H=1;
s4Text="Shut down ";
s4X=1;
s4Y=5;
s4W=17;
s4H=1;
}
function registerClickEvent(x,y)
if x >=OS1MenuB.x and x <=OS1MenuB.x+OS1MenuB.W-1 and y >=OS1MenuB.y and y <=OS1MenuB.y+OS1MenuB.H-1 then
if showOS1Menu then
showOS1Menu=false
else
showOS1Menu=true
end
end
if x >=OS1MenuSelections.s1X and x <=OS1MenuSelections.s1X+OS1MenuSelections.s1W-1 and y >=OS1MenuSelections.s1Y and y <=OS1MenuSelections.s1Y+OS1MenuSelections.s1H-1 then
addCoroutine(function() shell.run("OSCore/aboutW.app")end)
print("added routine")
end
end
function printOS1Menu()
if showOS1Menu then
term.setBackgroundColor(colors.lightGray)
term.setCursorPos(OS1MenuSelections.s1X,OS1MenuSelections.s1Y)
print(OS1MenuSelections.s1Text)
term.setCursorPos(OS1MenuSelections.s2X,OS1MenuSelections.s2Y)
print(OS1MenuSelections.s2Text)
term.setCursorPos(OS1MenuSelections.s3X,OS1MenuSelections.s3Y)
print(OS1MenuSelections.s3Text)
term.setCursorPos(OS1MenuSelections.s3X,OS1MenuSelections.s3Y)
print(OS1MenuSelections.s3Text)
term.setCursorPos(OS1MenuSelections.s4X,OS1MenuSelections.s4Y)
print(OS1MenuSelections.s4Text)
end
end
while true do
local e = {os.pullEvent()}
paintutils.drawImage(background,1,1)
paintutils.drawImage(topBar,1,1)
term.setCursorPos(OS1MenuB.x,OS1MenuB.y)
term.setBackgroundColor(colors.lightGray)
print(OS1MenuB.text)
if e[1]=="mouse_click" then
registerClickEvent(e[3],e[4])
printOS1Menu()
end
end
os.loadAPI("Apis/windowSystem")
local afData = {}
local x,y=0;
function exit()
end
local SysU=
{
text="Software update";
x=22;
y=7;
W=15;
H=1;
}
function loadAbout()
local abF=fs.open("data/osInfo","r")
local line = abF.readLine()
repeat
table.insert(afData,line) -- Puts the value of the current line into the table we have.
line = abF.readLine() -- read the next line
until line == nil -- readLine() returns nil when the end of the file is reached.
abF.close() -- Close up the file ready for use again.
end
loadAbout()
function registerClick(xPos,yPos)
shell.run("OSCore/loginUtil")
if xPos==window.x+window.W+1 and yPos==window.y then
exit()
end
if xPos >= SysU.x and xPos <= SysU.x + SysU.W - 1 and yPos >= SysU.y and yPos <= SysU.y + SysU.H then
shell.run("OSCore/updateManager.app")
end
end
local window=windowSystem.createWindow("About this Device",21,3,18,13,true,"Version:"..afData[1].." \n \n \n System: "..afData[2])
while true do
local e = {os.pullEvent()}
windowSystem.drawWindow(window)
term.setBackgroundColor(colors.white)
if e[1]=="mouse_click" then
registerClick(e[3],e[4])
end
end
Posted 25 September 2013 - 08:38 AM
Posted 26 September 2013 - 07:18 AM
Posted 02 October 2013 - 09:23 AM
Posted 03 October 2013 - 07:05 AM
Posted 03 October 2013 - 08:36 AM
Posted 04 October 2013 - 12:13 AM
function removeCoroutine(functionD)
for k, v in ipairs(programCache) do
if v == functionD then
table.remove(programCache, k)
table.remove(routineCache, k)
end
end
end
wont work aswell
Posted 05 October 2013 - 08:18 AM
0 members, 1 guests, 0 anonymous users