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

An API onload detection question

Started by Termanater13, 28 December 2012 - 08:08 PM
Termanater13 #1
Posted 28 December 2012 - 09:08 PM
I'm looking for a way for a API to detect when the computer or turtle loads it. This way if something needs to happen for the API to be ready, an onload() function would make it ready.

I was thinking of using the following code:
local function onload()
-- some lines of code to be run
-- to set up API when its loaded
end
onload()

I just need to know if this would work I already know that the function created in this example cannot be ran outside of the API internally.
Edited on 28 December 2012 - 08:09 PM
remiX #2
Posted 28 December 2012 - 10:36 PM
Just have a

print("API loaded!")

at the top, it will print API Loaded! when it loads it.
Orwell #3
Posted 28 December 2012 - 11:22 PM
Remix is correct, but it's the exact same thing as the OP suggests. So yes, it would work.
Termanater13 #4
Posted 29 December 2012 - 05:50 AM
So anything not in a function would run on load but not any other time?
Lyqyd #5
Posted 29 December 2012 - 06:23 AM
Yep.