Draw a function?

So if I create an enemy as a text, how would I call that function so that it would draw in the main draw function?

-- Tables

T = { [1] = "hello", [3] = 2, [5] = 3 }

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
end

function enemy()
    text(""..T[2],WIDTH/2,HEIGHT/2)
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)

    -- This sets the line thickness
    strokeWidth(5)
    
    text(""..T[1],WIDTH/2,HEIGHT/2)
    -- Do your drawing here
    
    enemy:draw()
    
    
    
end
-- Tables

T = {"hello",2,3 }

function setup()
    print("Hello World!")
end

function enemy()
    text(""..T[2],WIDTH/2,HEIGHT/2-100)
end

function draw()
    background(40, 40, 50)
    text(""..T[1],WIDTH/2,HEIGHT/2)
    enemy()
end

@durnonimous You’re calling enemy:draw(), which is only possible if enemy is an instance of a class with a specified function called draw. Since you are not working with classes right now, just calling the function enemy() in the main draw() function suffices, like in Dave’s example.

If you wanna know how classes work, you should check out the Codea Wiki. It’s especially useful if you are planning on working with multiple enemies.

@Kjell, the formatting doesn’t work for me, where the code-in-one-line I can’t see the formatting