It looks like you're new here. If you want to get involved, click one of these buttons!
@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.
Comments
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 LuaThis means you can write your own support for game controllers, for example:
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)
https://developer.apple.com/documentation/technologies
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
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
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.
This crashes my iPhone:
~~~
uiVC = objc.cls.UIViewController()
rootVC = objc.cls.UIApplication:sharedApplication().keyWindow.rootViewController
rootVC:presentViewController_animated_completion_(uiVC, false, nil)
~~~
Hey @UberGoober! Thanks for testing out the feature
I'll see why the above code crashes and keep you updated.
@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.
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
objc.global.UIModalPresentationStyle.UIModalPresentationAutomatic
.I'll be looking into this for a future update
@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.
My app crashes consistently when returning to the editor after running ok-no idea why? Sent a crash log.
No, just my previously working code.
@dave1707 - couldn’t see you code working. Tried modifying to the code below but brightness didn’t seem to change ?. Do we need to init the calls in some way ?
All,
Had a funny recently on the forum. When I have created a new post and tapped post comment it seemed to hang up, a second tap on post comment shifted to a blank page with a new blank editing box at the top. Anyone else seen this?
p.s. that's on my iPad.
@Bri_G I loaded your version and when I changed the slider and tapped the screen, I could see the screen brighten or darken depending on the slider value.
@UberGoober I found at least two issues in our objc implementation which I'll be fixing shortly. In the meantime, you can try the following code:
@piinthesky I just checked out the logs, there is no crash stack which makes me concerned. Is it caused by a project small enough to share that we can use to reproduce?
@jfperusse oh right, duh, enums are just ints. Thanks for reminding me.
@UberGoober Finally managed to add a dynamically created UIView. Had to do various fixes so this will only be possible in the next beta version.
The new beta will also include a fix to prevent crashes when invoking a method with the wrong type of arguments, as well as some validation and error messages.
Here's the code I've been able to use on my iPad after the fixes:
@jfperusse i think the callback docs need fixing because it says to use prefixes like o for objects and b for bools but the example shows “objError” and “boolGranted”
also the classes that we can use should be listed somewhere, i already tried a couple that don’t exist, and using “UIScreen” for an example is confusing since there is no reference or search results for UIScreen in the technologies page of apple, you have to dig down to UIKit and then click Windows and Screens to find it
also, why not just remove underscores completely from the methods?
@piinthesky Would you be able to post the zip file here. I could try it to see if I get the same results on different iPads.
@skar that's my fault, the docs are correct (you only need a single character) but I prefer the readability of writing a short word that begins with that character (o = obj, b = bool, etc)
On methods with underscores, in Objective-C the colons (
:
) are part of the method name. SosetSpeed:withObject:
takes two arguments, and is distinct from the method namedsetSpeedwithObject
(no arguments). In order to represent this in Lua @jfperusse maps the colons to underscores@piinthesky you could email me (simeon@twolivesleft.com) and share it as a zip or iCloud link. If it has dependencies then I'd need to use those too
As for listing all possible classes, there would be too many, you do need to know what you're trying to implement, but we could actually list the included frameworks (UIKit, Game Controller, User Notification, etc.).
@jfperusse that code works a treat! This is so cool.
Also much thanks for the improved error handling.
The very first thing I thought of when I saw this was how I’ve wanted a gui to save and load files since forever, so after I got your example working I immediately tried to implement a document picker:
…needless to say, it didn’t work. I’m not sure if instantiating a C array for a parameter is possible, for one thing, but the initialization call itself doesn’t seem to be right either.
Is this possible?
@UberGoober You almost got it right! Try this:
OMG it works. I can see no further use for sliced bread!!
Okay so I would never have been able to figure this out on my own without two crucial pieces of information that imho need to be in the documentation:
alloc
pattern for accessing complex initializers. Imho this is really necessary to include as an example, because so many classes require it.Fyi I just learned that the init syntax I used has been deprecated.
This is the current way to do it:
…and it works, yay.
This seems very cool. Where are you folks learning how to use this stuff? We're gonna need lots of little examples.
@RonJeffries this requires some understanding of objective-c and the native iOS APIs. I too look forward to lots of cool little helper classes coming from this.
@Simeon in version 320 i don't crash returning to editor!
@piinthesky odd as I didn't fix anything in that build! But I did find the issue on my side when running your test project, and I was able to fix it more thoroughly for the next build