Templates

I believe it has been already suggested many times before, but here are some good use of it. Instead of New Class and New Blank File we could have:

##New > Blank


##New > Empty Class

className = class()

function className:init(t)
    
end

##New > UI Class

className = class()

function className:init(t)
    self.pos = vec2(t.x, t.y)
    self.size = vec2(t.w, t.h)
    self.touching = false
end

function className:draw()
    fill(255)
    rect(self.pos.x, self.pos.y, self.size.x, self.size.y)
end

function className:touched(t)
    if self:isTouched(t) and t.state == BEGAN then
        self.touching = true
    else
        self.touching = false
    end
end

function className:isTouched(t)
    if t.pos.x > self.pos.x and t.pos.y > self.pos.y and self.pos.x + self.size.x > t.pos.x and self.pos.y + self.size.y > t.pos.y then
        return true
    end
    return false
end

##New > Empty Object

className = className or {}


##New > Comment

--[[
    * 
]]

##New > 2D Moveable Class

...

… and many more …

Aside of that, can we please save the tabulation based on the user choice. When you work with { … } comments it’s annoying that the indent always jumps back to 4 spaces, when you e.g. need 16.

What could be done is the user can create their own templates. Any name beginning with template, ie. template1, template 2, etc would show when a new project is created. The user could then select which one they want. They can fill in each template with the initial code they want.

@dave1707 - that’s just the suggestion we have already made. Not sure if it has been added to the todo list.

I was sure there was a template thing in Codea somewhere. Am I mistaken?

@RonJeffries - when you press on the + icon for a new file there is a selection box for file type, this includes new template. You can add files here which you can use as templates - so you can ‘roll your own’ as it were.

I have one with two tabs with my usual setup() conditions with a second tab for common utilities.

You can then load in your template on start up.

Forgot, if you press and hold onto a file the dialogue box that is generated includes a make-template option.

Oh in the new project. Right, thanks.