I am new to Codea and just trying to get a few simple things going and having difficulties. I put together a small app that records the time when you tap the screen and then plots the data afterwards, very vanilla compared to some of the things I’ve seen on this forum. Here are some observations/questions:
- Touch events don’t have timestamps on them. In particular, I couldn’t tell how long I had touched the screen. MOVING wasn’t documented as working for stationary touches.
- There was no way to get the current date/time. (os.time provides this now?)
- writeProjectData is documented as able to save any value. No–it only saves a number or a string. I needed to save an array of strings. In general, de/serialization of any reasonable data structure should be possible. So I had to concatenate everything into a big string which will then need parsing.
Now I’m trying to display the data that was created.
- Parsing the string isn’t working. Maybe string.gmatch patterns don’t work like I expect? I thought the pattern “(%d-):(%d-),?” could get the time values out of a string like “2:30, 2:45, 2:55”, but only the minute is extracted from each of the 3 time values. With the “?” omitted, the minute and second values are extracted for the first 2 time values and the third is ignored. How do I write this pattern?
- The graph is a straight line representing an hour’s duration, with x’s plotted on it according to the minute and second values. It only needs to be plotted once. I tried to do the plot in the setup() routine but that failed in both versions 1.2 and 1.3 so I tried to do the plot once in the draw() routine, then set a flag so that when draw() is called again it immediately returns–since the picture area isn’t drawn on further, what’s plotted there should remain, right? What happens is that the plot appears for an instant then flickers out. I tried setting backingMode() but that made the plot not appear at all. At the moment I can’t get even a simple line with an “x” plotted on it to stay onscreen.
Request for new feature:
- When you return from executing your code, make the text cursor reappear in the location you left it–then one can start typing right away. As it is, one has to stop and touch the screen first to make the cursor reappear. (I’m using a Bluetooth keyboard.)
- There should be a link somewhere in the editor directly to the Lua manual.
- “Find/replace” command in the editor, both inside and between tabs. I have to copy tabs to another editor to do this now.
- Any chance of real de/serialization for the different read/writeXXXdata routines?
One final question for future reference:
How does one copy code into the forum, preferably without lots of escaping?