mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 03:36:47 -04:00
moved post-library init code to extra file
This commit is contained in:
parent
7d4f4c46f3
commit
453be0f2f5
@ -227,8 +227,10 @@ sandbox = {
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Start of non-standard stuff.
|
-- Start of non-standard stuff.
|
||||||
|
|
||||||
address = os.address,
|
|
||||||
isRobot = os.isRobot,
|
isRobot = os.isRobot,
|
||||||
|
address = os.address,
|
||||||
|
romAddress = os.romAddress,
|
||||||
|
tmpAddress = os.tmpAddress,
|
||||||
freeMemory = os.freeMemory,
|
freeMemory = os.freeMemory,
|
||||||
totalMemory = os.totalMemory,
|
totalMemory = os.totalMemory,
|
||||||
uptime = os.uptime,
|
uptime = os.uptime,
|
||||||
@ -346,9 +348,7 @@ local function main()
|
|||||||
local buffer = ""
|
local buffer = ""
|
||||||
repeat
|
repeat
|
||||||
local data = rom.read(handle)
|
local data = rom.read(handle)
|
||||||
if data then
|
buffer = buffer .. (data or "")
|
||||||
buffer = buffer .. data
|
|
||||||
end
|
|
||||||
until not data
|
until not data
|
||||||
rom.close(handle)
|
rom.close(handle)
|
||||||
local program, reason = load(buffer, "=" .. file, "t", sandbox)
|
local program, reason = load(buffer, "=" .. file, "t", sandbox)
|
||||||
@ -357,10 +357,10 @@ local function main()
|
|||||||
if result[1] then
|
if result[1] then
|
||||||
return table.unpack(result, 2, result.n)
|
return table.unpack(result, 2, result.n)
|
||||||
else
|
else
|
||||||
error("error initializing lib: " .. result[2])
|
error(result[2])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
error("error loading lib: " .. reason)
|
error(reason)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -383,19 +383,7 @@ local function main()
|
|||||||
-- Yield once to get a memory baseline.
|
-- Yield once to get a memory baseline.
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
|
|
||||||
return coroutine.create(load(string.format([[
|
return coroutine.create(function() dofile("/init.lua") end)
|
||||||
fs.mount("%s", "/")
|
|
||||||
fs.mount("%s", "/tmp")
|
|
||||||
for c, t in component.list() do
|
|
||||||
os.pushSignal("component_added", c, t)
|
|
||||||
end
|
|
||||||
term.clear()
|
|
||||||
while true do
|
|
||||||
local result, reason = os.execute("/bin/sh -v")
|
|
||||||
if not result then
|
|
||||||
print(reason)
|
|
||||||
end
|
|
||||||
end]], os.romAddress(), os.tmpAddress()), "=init", "t", sandbox))
|
|
||||||
end
|
end
|
||||||
local co, args = bootstrap(), {n=0}
|
local co, args = bootstrap(), {n=0}
|
||||||
while true do
|
while true do
|
||||||
|
16
assets/opencomputers/lua/rom/init.lua
Normal file
16
assets/opencomputers/lua/rom/init.lua
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
fs.mount(os.romAddress(), "/")
|
||||||
|
fs.mount(os.tmpAddress(), "/tmp")
|
||||||
|
|
||||||
|
for c, t in component.list() do
|
||||||
|
os.pushSignal("component_added", c, t)
|
||||||
|
end
|
||||||
|
os.sleep(0.5) -- Allow signal processing by libraries.
|
||||||
|
|
||||||
|
term.clear()
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local result, reason = os.execute("/bin/sh -v")
|
||||||
|
if not result then
|
||||||
|
print(reason)
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user