Merge branch 'Pyroxenium:master' into master
This commit is contained in:
@@ -11,7 +11,7 @@ local debugger = true
|
||||
|
||||
local projectDirectory = fs.getDir(table.pack(...)[2] or "")
|
||||
|
||||
local activeKey, frames, monFrames, variables, shedules = {}, {}, {}, {}, {}
|
||||
local activeKey, frames, monFrames, variables, schedules = {}, {}, {}, {}, {}
|
||||
local mainFrame, activeFrame, focusedObject, updaterActive
|
||||
|
||||
if not term.isColor or not term.isColor() then
|
||||
@@ -122,13 +122,13 @@ local basaltError = function(errMsg)
|
||||
baseTerm.setCursorPos(1,yPos+1)
|
||||
end
|
||||
|
||||
local function handleShedules(event, p1, p2, p3, p4)
|
||||
if(#shedules>0)then
|
||||
local function handleSchedules(event, p1, p2, p3, p4)
|
||||
if(#schedules>0)then
|
||||
local finished = {}
|
||||
for n=1,#shedules do
|
||||
if(shedules[n]~=nil)then
|
||||
if (coroutine.status(shedules[n]) == "suspended")then
|
||||
local ok, result = coroutine.resume(shedules[n], event, p1, p2, p3, p4)
|
||||
for n=1,#schedules do
|
||||
if(schedules[n]~=nil)then
|
||||
if (coroutine.status(schedules[n]) == "suspended")then
|
||||
local ok, result = coroutine.resume(schedules[n], event, p1, p2, p3, p4)
|
||||
if not(ok)then
|
||||
basaltError(result)
|
||||
end
|
||||
@@ -138,7 +138,7 @@ local function handleShedules(event, p1, p2, p3, p4)
|
||||
end
|
||||
end
|
||||
for n=1,#finished do
|
||||
table.remove(shedules, finished[n]-(n-1))
|
||||
table.remove(schedules, finished[n]-(n-1))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -197,7 +197,7 @@ local function basaltUpdateEvent(event, p1, p2, p3, p4)
|
||||
for _, v in pairs(frames) do
|
||||
v:eventHandler(event, p1, p2, p3, p4)
|
||||
end
|
||||
handleShedules(event, p1, p2, p3, p4)
|
||||
handleSchedules(event, p1, p2, p3, p4)
|
||||
drawFrames()
|
||||
end
|
||||
|
||||
@@ -272,13 +272,13 @@ basalt = {
|
||||
end
|
||||
end,
|
||||
|
||||
shedule = function(f)
|
||||
assert(f~="function", "Shedule needs a function in order to work!")
|
||||
schedule = function(f)
|
||||
assert(f~="function", "Schedule needs a function in order to work!")
|
||||
return function(...)
|
||||
local co = coroutine.create(f)
|
||||
local ok, result = coroutine.resume(co, ...)
|
||||
if(ok)then
|
||||
table.insert(shedules, co)
|
||||
table.insert(schedules, co)
|
||||
else
|
||||
basaltError(result)
|
||||
end
|
||||
|
||||
@@ -1062,7 +1062,7 @@ local animTime = 0.2
|
||||
local animFrames = 8
|
||||
|
||||
local function download(url, file)
|
||||
local httpReq = http.get(url, _G._GIT_API_KEY and {Authorization = token.." ".._G._GIT_API_KEY})
|
||||
local httpReq = http.get(url, _G._GIT_API_KEY and {Authorization = "token ".._G._GIT_API_KEY})
|
||||
if(httpReq~=nil)then
|
||||
local content = httpReq.readAll()
|
||||
if not content then
|
||||
@@ -1076,7 +1076,7 @@ end
|
||||
|
||||
local function createTree(page)
|
||||
local tree = {}
|
||||
local request = http.get(page, _G._GIT_API_KEY and {Authorization = basaltGithubToken.." ".._G._GIT_API_KEY})
|
||||
local request = http.get(page, _G._GIT_API_KEY and {Authorization = "token ".._G._GIT_API_KEY})
|
||||
if not(request)then return end
|
||||
for k,v in pairs(textutils.unserialiseJSON(request.readAll()).tree)do
|
||||
if(v.type=="blob")then
|
||||
|
||||
@@ -171,8 +171,8 @@ end)
|
||||
<button onClick="clickMe" text="Click me" />
|
||||
```
|
||||
|
||||
## basalt.shedule
|
||||
Shedules a function which gets called in a coroutine. After the coroutine is finished it will get destroyed immediatly. It's something like threads, but with some limits.
|
||||
## basalt.schedule
|
||||
Schedules a function which gets called in a coroutine. After the coroutine is finished it will get destroyed immediatly. It's something like threads, but with some limits.
|
||||
|
||||
#### Parameters:
|
||||
1. `function` a function which should get executed
|
||||
@@ -181,11 +181,11 @@ Shedules a function which gets called in a coroutine. After the coroutine is fin
|
||||
1. `function` it returns the function which you have to execute in order to start the coroutine
|
||||
|
||||
#### Usage:
|
||||
* Creates a shedule which switches the color between red and gray
|
||||
* Creates a schedule which switches the color between red and gray
|
||||
```lua
|
||||
local mainFrame = basalt.createFrame()
|
||||
local aButton = mainFrame:addButton():setText("Click me")
|
||||
aButton:onClick(basalt.shedule(function(self)
|
||||
aButton:onClick(basalt.schedule(function(self)
|
||||
self:setBackground(colors.red)
|
||||
os.sleep(0.1)
|
||||
self:setBackground(colors.gray)
|
||||
|
||||
Reference in New Issue
Block a user