Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Meant to be ran on Resolution 80; 25
- local term = require("term")
- local process = require("process")
- local shell = require("shell")
- function shallowcopy(orig) --To copy tables
- local orig_type = type(orig)
- local copy
- if orig_type == 'table' then
- copy = {}
- for orig_key, orig_value in pairs(orig) do
- copy[orig_key] = orig_value
- end
- else
- copy = orig
- end
- return copy
- end
- function cusenv(newenv)
- setmetatable(newenv, { __index = env })
- --return newenv --It is probably for the good to keep it not working
- end
- local co1 = process.load("testing.lua", cusenv({ --Init our program 1
- msg = "Testing 1"
- }))
- local co2 = process.load("testing.lua", cusenv({ --Init our program 1
- msg = "Testing 2"
- }))
- local enforcments = {}
- enforcments[co1] = { -- Program 1 window width and heigth setup (Left half of the screen)
- w = 40,
- h = 20
- }
- enforcments[co2] = { -- Program 1 window offset, width and heigth setup (Rigth half of the screen)
- w = 40,
- h = 20,
- dx = 40,
- }
- -- Let's copy our main window
- process.list[co1].data.window = shallowcopy(term.internal.window())
- process.list[co2].data.window = shallowcopy(term.internal.window())
- while true do
- for k, v in pairs(enforcments) --Enforce window parameter enforcements
- for k2, v2 in pairs(v) do
- if process.list[k] then
- process.list[k].data.window[k2] = v2
- end
- end
- end
- for k, v in pairs(process.list) do --Execute coroutines
- coroutine.resume(k)
- end
- os.sleep(0.2) -- Slow down execution
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement