Find out if device is 64 bit (for code optimisation on different devices)

I’ve found that my game which runs at 60 FPS on the iPad Air is much more sluggish on an iPhone 4S (averages around 45 FPS but frequently dives lower). So that got me thinking about implementing various optimisations (simpler lighting, smaller level sizes etc) if the code detects that it’s running on older hardware. You could create multiple levels for this, but I decided that perhaps the biggest step forward in performance was when the chips went 64-bit (the A7 chip in the iPad Air, iPhone 5S, iPad Mini 2). This code sets a device64bit flag to true if it is running on an A7 or newer device. I believe the iPad Pro reports itself as “iPad6,8”, so this code should work for all iPhones and iPads.

Edit: forgot about the poor iPod. Added.

    deviceType, deviceGen = deviceMetrics().platform:match("(%a+)(%d),%d$")
    deviceGen = tonumber(deviceGen)
    print(deviceType, deviceGen)
    if (deviceType == "iPad" and deviceGen >= 4) or ((deviceType == "iPhone" or deviceType=="iPod") and deviceGen >= 6) then device64bit = true end --if device is an iPad Air, iPad Mini 2, iPhone 5S or an iPod 6G (ie A7 chip) or newer, device64bit is set to true

nice work!