Ok, first some comments on the code:
sm.clearScreen = function( par1, par2 ) -- sm is not defined
term.clear( 1 ) -- term.clear has no parameters
if par1 | par2 == nil then -- read below
term.setCursorPos( 1, 1 )
else
term.setCursorPos( par1, par2 )
end
end
test = "if you can read this message, the test has worked"
shell.run( "smAPI" ) -- you should use os.loadAPI
print( "testing" )
sleep(2)
sm.clearScreen()
print( test )
I'm not sure of what you tried to do here:
if par1 | par2 == nil then
I guess you want to check if both are nil, it should be:
if par1 == nil or par2 == nil then
To make an api, you need to create the api file with all the functions you want it to have, something like:
function a()
print("This is an api function")
end
function f(n)
rs.setOutput("left", false)
sleep(n)
rs.setOutput("left", true)
end
Everything you want to be in the api should be global, so don't use local on them (you can, and should, use it inside the functions and for things you don't want to be visible in the api).
Then, the program loads it with os.loadAPI, passing the path to the file as the argument:
os.loadAPI("testAPI")
Now the api should be loaded, and you can access it's functions and variables using it's name (the filename, without the full path):
testAPI.a()