Codea 3.5 version (316)

@Simeon Not sure how long this has been happening, but when I tap on Do, then Assets I get the list of Assets.Tap the Project asset for that list. Tap the + on the Text line and create a new text file. Give it a name a tap Create. That file shows under Text. Tap on the pencil icon on the new text file. Nothing happens. To edit the text file, I have to add the line readText() in the project and then tap between the () to get to the list of files. From there I can tap the pencil icon to edit the file.

sort of related but i get a problem where the bottom panel covers the buttons on the bottom of the assets view

@Simeon - just loaded up 3.5 and tried to run CraftSceneInator() from @UberGoober. First thing I find 3.5 a little slow, and with CraftSceneInator() it throws up an initial error relating to the assert() command which carries a parameter in addition to the comment. Followed by an error relating to no Craft.scene available. Commenting out the assert line runs the code correctly. Also after restarting the Codea the speed of operation had increased and was smoother.

@Simeon - just loaded up WebRepo and crashed, sent a report. Re-ran after rebooting error attached as image.

@skar thanks for finding that!

@dave1707 hmm good find, will look into it

@Bri_G thank you for sending the report, 3.5 should be the same as 3.4.7 in terms of performance but I’ll keep an eye out

In build 316 there’s a new feature by @jfperusse that I’m pretty excited about

He added Lua bindings to the native iOS SDK, so you can access most APIs through objc in Lua

This means you can write your own support for game controllers, for example:

function setup()
    local controllers = objc.cls.GCController.controllers
    local count = #controllers

    if count > 0 then
        controller = controllers[1]
        gamepad = controller.extendedGamepad
        dpad = gamepad.dpad

        dpad.left.pressedChangedHandler = function(objButton, floatValue, boolPressed)
            -- Note the prefixes on the argument names
            -- these are necessary to tell the system how to map types into Lua
            print("left changed " .. boolPressed and "pressed" or "released")

        print(math.floor(controller.battery.batteryLevel * 100) .. "%")

Or you could make use of NSURLSession (and web sockets), send local notifications, there are thousands of APIs exposed through this feature.

These are documented here (use the Objective-C documentation where possible)

Only iOS frameworks are applicable, and not all frameworks are included yet, so if you have a request, let us know

Some frameworks will be inaccessible due to entitlements (CloudKit), and Swift-only frameworks can’t be bound automatically

@Simeon, That’s fantastic! I’ll certainly be taking a look into that.

@Simeon or anyone. Is the above code supposed to run on the iPad (or just a Mac) or is something else supposed to be included. count is 0 when I run it. Never did anything with Objective-C so I don’t know.

Hi @dave1707! Is your controller properly connected to your iPad? If so, please try simply launching your project again. I noticed that the controllers list is empty the very first time it is accessed. In my projects, I check the list again in draw() if I couldn’t find a controller yet. It should also be possible to use startWirelessControllerDiscoveryWithCompletionHandler but I have yet to try it out.

@jfperusse I guess that’s my problem, a controller. Nothing is connected to my iPad. I just write code to past the time, nothing major. So it will take awhile to figure out what can be done with the Objective-C stuff. I guess I’ll just wait for others to post examples.

@dave1707 At least that explains the count being 0 :smile:

If you want to try a simpler example, you can change your ipad brightness like so:

objc.cls.UIScreen.mainScreen.brightness = 0.5 -- a value between 0.0 and 1.0

Though I’m not sure what kind of game could use this as a feature :lol:

So here’s a simple example using the above code. Move the slider for a brightness value and tap the screen to apply it.

Just have to figure out where to find a simple list all the objc stuff.


function setup()

function draw()

function touched(t)
    if t.state==BEGAN then
    elseif t.state==ENDED then

Holy shamoley the objc bindings are so exciting!

This crashes my iPhone:

uiVC = objc.cls.UIViewController()
rootVC = objc.cls.UIApplication:sharedApplication().keyWindow.rootViewController
rootVC:presentViewController_animated_completion_(uiVC, false, nil)

Sorry for the momentary double-post, I was trying to get around the bug where code doesn’t format correctly when you enter a post on the iPhone.

@jfperusse the final line should probably be: rootVC.presentedViewController.presentedViewController:presentViewController_animated_completion_(uiVC, false, nil) (which still crashes)

Because presenting from the rootVC shouldn’t work anyway.

Hey @UberGoober! Thanks for testing out the feature :smile:

I’ll see why the above code crashes and keep you updated.

Is there a way to access objective-C global enums?

For example UIModalPresentationStyle?

There is no way at the moment to access global methods and enums as the C language does not have this level of runtime reflection. However, we think we might later be able to parse the different framework headers and expose those through new properties such as

I’ll be looking into this for a future update :wink:

@UberGoober I confirm that I can reproduce your crash. I’ll see if we can at least prevent the runtime from crashing, and also investigate what’s wrong with the call.

@jfperusse thanks, and thanks for all this, it’s great.

Enums are particularly needed because some classes can’t be instantiated without them.