This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
makerimages's profile picture

Accessing Shell In An Api

Started by makerimages, 19 August 2013 - 02:34 AM
makerimages #1
Posted 19 August 2013 - 04:34 AM
Hi, quite a while ago I asked for some help. it turned out that APIS cant access shell for a shell.run, is there any way to work around this?
LBPHacker #2
Posted 19 August 2013 - 05:35 AM
Pass the shell table to the API - make the API store the reference of the shell table, and there you go, the API can call the functions in the shell table you gave it. I thought of something like this:
-- first lines of the API
local passedShell

function setShell(sl)
    passedShell = sl
end

-- * ...

function someFunctionThatUsesShell(...)
    passedShell.run(...)
end

Then the program which uses the API would look like this:
os.loadAPI("someapi")
someapi.setShell(shell)
someapi.someFunctionThatUsesShell("something")
makerimages #3
Posted 19 August 2013 - 11:25 AM
Will try.
Lyqyd #4
Posted 19 August 2013 - 02:49 PM
APIs can use os.run instead, but it's generally unnecessary to run files from an API.