ComputerCraft Archive

compat

computer utility kepler155c github

Description

ComputerCraft OS

Installation

Copy one of these commands into your ComputerCraft terminal:

wget:wget https://raw.githubusercontent.com/kepler155c/opus/develop-1.8/sys/apps/compat.lua compat
Archive:wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-apps-compat compat
Quick Install: wget https://cc.shobie.xyz/cc/get/gh-kepler155c-opus-sys-apps-compat compat

Usage

Run: compat

Tags

none

Source

View Original Source

Code Preview

local Util = require('opus.util')

-- some programs expect to be run in the global scope
-- ie. busted, moonscript

-- create a new environment mimicing pure lua

local fs    = _G.fs
local shell = _ENV.shell

local env = Util.shallowCopy(_G)
Util.merge(env, _ENV)
env._G = env

env.arg = { ... }
env.arg[0] = shell.resolveProgram(table.remove(env.arg, 1) or error('file name is required'))

_G.requireInjector(env, fs.getDir(env.arg[0]))

local s, m = Util.run(env, env.arg[0], table.unpack(env.arg))

if not s then
    error(m, -1)
end