Classes and blank files

Hey, I’m new to Codea and I was wondering what are classes and blank files for? I know I can put more code on them but how would I be able to “link” that code with my main code and use it then. Are there any sites for tips and tutorials such as these? ( I checked the wiki, but most of the links are broken)

Thanks in advance.

Classes are identical to blank files except they include a basic class template using the name that you specify. This just saves you some typing if you intend to make a class.

All the code is executed when you press play — so your classes will be available to all your other files.

For example, if you create a class called MyClass, you can create an instance in your setup() function as follows:

function setup()
    foo = MyClass()

    -- Do things with foo... 
end

function draw()
    foo:draw()
end

@Simeon So if I have a different function setup in MyClass but in the main file I write foo = MyClass() it will run that setup? (same goes for draw?)

foo = MyClass() would make foo an instance of MyClass and run MyClass:init().

If you used foo:draw() after that, it would run the code in MyClass:draw()