Codea 1.5.2 Beta

Btw, it would be great to be able to export / read images in the camera roll. I am sure you plan to do it ‘some day’, but how far below is it on your to-do list?

@Jmv38 I think I was able to fix the clip() issue. Let me know how the next build goes for you.

Great!

The priority after 1.5.2 is released will be to get custom sounds and music working (in a nice way).

Exporting to camera roll is easier than reading, but I’m still unsure what the API will look like. Apple is fairly strict about how the camera roll must be presented (it must be inside a UIPopoverController on iPad). This means that it would have to be presented from a screen-space coordinate, and would not respect any of Codea’s transformations. What we will probably end up doing is designing a modal UI from which the picker can be opened (something like the Icon selection interface in the Export Xcode feature).

Then maybe you could do a 2 steps implementation?
1/ saving (soon).
2/ reading (later when you have made up your mind on how to do it).
Saving would already be great and enable all kind of apps, specially for people who have the camera.

@Reefwing here’s an example of how to create a CodeaAddon

https://gist.github.com/TwoLivesLeft/5331422

I started tackling GameCenter and realise it’s actually a little complex for an example. In this case, I’ve made the addon a singleton — not always necessary. It exposes one function to Codea called GameCenterStart

While I was able to successfully test that the function was called, I wasn’t able to get it to work. I assume the app ID needs to be Game Center enabled, which I didn’t have time to do.

Thanks @Simeon - I’m not sure when you actually get a chance to sleep!

You should be able to sign into Game Center and authenticate the player whether your app is registered or not, you will then get an alert saying “This game is not recognised by Game Center.”

I’m having a crack at iAds and your example will assist with that. I will post the results here.

Regarding the photo picker, i think the way that icon selection works in project export is great.

Regarding sounds and music, couldn’t you use the add on functionality for this? Admittedly a native implementation would be nice.

thanks for built 7 @ Simeon : problem solved!
You know, some time i feel guilty because i paid 1.50 Euro for CODEA (in promo) and i get a support worth 25000 Euro/year (that is what it would cost me to get the same amount of support if Codea was one of the sofware i am paying external companies to developp at work…). I really appreciate. I hope you are doing (or will do) as well as you deserve to!

Too late for version 1.5.2 (on its way to the App Store), and perhaps already known, but the Video button does not appear to work as I would expect once the Replay button has been touched (at least, in standard screen mode and landscape orientation). The red border comes and goes, but nothing more happens.

That’s a pretty significant bug. Thanks for finding it @mpilgrem. I’ll resubmit if I manage to fix it today.

This is, I think, another bug - in the ‘type a command’ bar. Try entering the following sequence of commands, one after another:


return
return 1, 2, 3
return
return
return
return
return
return

Hi. Trying to use the addon system. Can I access the runtime header files somehow? I got stuck at trying to use createUIImageFromImage which is defined in image.h.

Hmm you should be able to forward declare (just to let the compiler know that it exists).

You can take some of the headers from the Codea-Runtime source and include the relevant bits in your addon. Let me know how this goes for you.

Accessing the built in Codea types (image, vec, and so on) through your exported functions is something I’d like to add.

I tried to cheat using void* pointers, but I just get “Undefined symbols” errors when trying to compile it. Will try a bit more

You’ll need to forward declare the types as well. For example:

struct image_type_t;

typedef enum PersistenceImageAlpha
{
    PersistenceImageAlphaPremultiply,
    PersistenceImageAlphaNoPremultiply,
} PersistenceImageAlpha;

UIImage* createUIImageFromImage(struct image_type_t* image, PersistenceImageAlpha alphaOption);

```

Ah, thanks for the help, was just trying something like it, but it don’t look like that in the runtime, now it seems to have a new argument. But I guess my error depends on that the createUIImageFromImage is not defined in a h-file, as in the current runtime. Or maybe I’m a newbie. :slight_smile:

Undefined symbols for architecture armv7:
  "createUIImageFromImage(image_type_t*, PersistenceImageAlpha)", referenced from:
      WriteToPhotoAlbumFunction(lua_State*) in WriteToPhotoAlbum.o
  "lua_pushcclosure(lua_State*, int (*)(lua_State*), int)", referenced from:
      -[WriteToPhotoAlbum codea:didCreateLuaState:] in WriteToPhotoAlbum.o
  "lua_setfield(lua_State*, int, char const*)", referenced from:
      -[WriteToPhotoAlbum codea:didCreateLuaState:] in WriteToPhotoAlbum.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m just trying a small example of saving an image to the photo album. Here is the mm file.

#import "WriteToPhotoAlbum.h"
#import "lua.h"
#import "image.h"

struct image_type_t;

typedef enum PersistenceImageAlpha
{
    PersistenceImageAlphaPremultiply,
    PersistenceImageAlphaNoPremultiply,
} PersistenceImageAlpha;

UIImage* createUIImageFromImage(struct image_type_t* image, PersistenceImageAlpha alphaOption);

static int WriteToPhotoAlbumFunction(struct lua_State *state);

@implementation WriteToPhotoAlbum

DEFINE_SHARED_INSTANCE_IMPL

- (void) codea:(CodeaViewController*)controller didCreateLuaState:(struct lua_State*)L
{
    NSLog(@"Register WriteToPhotoAlbum");
    lua_register(L, "saveToPhotoAlbum", WriteToPhotoAlbumFunction);
}
@end

static int WriteToPhotoAlbumFunction(struct lua_State *state) {
    image_type* imageType = checkimage(state, 2);
    UIImage* image = createUIImageFromImage(imageType, PersistenceImageAlphaNoPremultiply);
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
    return 0;
}

Ah, guess it should be extern “C”. Still have the issue with push_closure, but must have missed a h-file maybe. Edit: Got it working! Even popped up a dialog asking for access to the photo album. Was a bit confused that import only works if inside the extern statement.

#import "WriteToPhotoAlbum.h"

#ifdef __cplusplus
extern "C" {
#endif

#import "lua.h"
#import "lauxlib.h"

struct image_type_t;
struct image_type_t *checkimage(lua_State *L, int i);

typedef enum PersistenceImageAlpha
{
    PersistenceImageAlphaPremultiply,
    PersistenceImageAlphaNoPremultiply,
} PersistenceImageAlpha;

UIImage* createUIImageFromImage(struct image_type_t* image, PersistenceImageAlpha alphaOption);
    
#ifdef __cplusplus
}
#endif

static int WriteToPhotoAlbumFunction(struct lua_State *state);

@implementation WriteToPhotoAlbum

DEFINE_SHARED_INSTANCE_IMPL

- (void) codea:(CodeaViewController*)controller didCreateLuaState:(struct lua_State*)L
{
    NSLog(@"Register WriteToPhotoAlbum");
    lua_register(L, "saveToPhotoAlbum", WriteToPhotoAlbumFunction);
}
@end

static int WriteToPhotoAlbumFunction(struct lua_State *state) {
    struct image_type_t* imageType = checkimage(state, 1);
    UIImage* image = createUIImageFromImage(imageType, PersistenceImageAlphaPremultiply);
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
    return 0;
}

Haven’t figured out what the PersistenceImageAlpha does :). My transparent image gets a white background instead. Really nice to get it working :slight_smile:

@tnlogy good to know you got it working!

Sorry about the lack of headers, eventually I’d like to make this stuff a lot more developer friendly.

I guess it’s most confusing when the old headers are not the same as the new. If they would be published somewhere it would be a bit easier. :slight_smile:

Good work with the API, will try it out a bit more.

I added a facebook share function as well, making the name of my addon a bit forced. Working fine!

https://gist.github.com/tnlogy/5371725

Would it be possible to access the camera stream? Would like to try using the CIDetector, but maybe it’s about just as fast calling my function from the draw method.

http://developer.apple.com/library/ios/#documentation/CoreImage/Reference/CIDetector_Ref/Reference/Reference.html