Programmatic paradigm

I understand that Codea uses a state-machine paradigm. That solves as many programming issues as it creates, however. I am also looking at Python as a solution… But it’s… Python. :frowning:

Is it possible that Codea will ever be able to support a functional paradigm? Or, are the underpinnings so wrapped up in the current design as to make this impossible? Or, hopefully, I am just missing something and I can hide the whole draw() function?

interesting, I never knew you could do it that way. I thought [[ ]] was for strings and --[[ --]] was for comments

@JakAttak - I use it in all my projects, so yes.

@Zoyt, does that even work?

Haha. I never knew you could use --[[ and --]]. I always use --[[ ]]-- because of my OCD.

I was thinking, “I thought it had to have two brackets?”

–[[ :"> --]]

@Ignatz, those would need to be --[[ and --]]

@SkyTheCoder no problem. Soon, the question is going to be, Is he ever going to leave? >_>

You can also write to a code tab directly (you won’t see it untl the program end, though), with saveProjectTab.

If you surround the text with --[ (before) and --] (after), then it will be treated as comments, not code.

@syntonica Also, I forgot, but welcome to the Codea Forums!

@Ignatz Directly, parameter callbacks, draw, touched, collision, and orientationChanged are the only event triggers.

Setup is ran after every tab is loaded, but you don’t have to have the initialization code in it. If there is only the tab Main, then the initialization code can go at the bottom. If there are multiple tabs, it goes at the bottom of the last tab. With tabs (or without) it’s better to be in setup, but it doesn’t have to be.

Indirectly, you can also use tween.delay to set up a custom loop. I did this instead of draw for a more compact timer in my 50 line competition entry.

If you don’t use draw, you can still draw on the screen. You can draw it in setup (or floating) and remove the draw function completely and what you drew will stay there. You can also draw it in any event trigger, including touched, tween.delay, etc.

Awesome! Thank you! Now I kinda get what’s going on…

You don’t need a draw function at all, if you don’t want it. I often just use the setup function to do some work that doesn’t involve drawing.

But AFAIK, the draw function (along with the touched function) are the only event triggers, apart from parameters.

Understood, but is that console output only?

Bit late… You don’t need to put – after the closing ]] brackets, thats why it doesn’t make a difference :slight_smile:

@Luatee - Oooohhhh… I get it. =D> (sarcastically to me)