Scrappy Device

Scrappy Device is a simple library for Solar2D that allows you to get info about the device your app is running on.

As with all my plugins it is free to use however if you find it useful, and are able to, I’d appreciate a coffee.

Image Credit: Digital devices by ProSymbols from the Noun Project.

Getting Started

In order to use the library you will need to include it in your project, to do so please see this guide.

API

Scrappy.Device:init( params )

Initiates the library.

params ( table ) – Parameters for the initiation.


Scrappy.Device:getPlatform()

Gets the simple tag for each platform.

returns – The name of the platform. Either ‘macos’, ‘win32’, ‘android’, ‘ios’, ‘tvos’, ‘winphone’, or ‘html5’.


Scrappy.Device:getEnvironment()

Gets the environment name.

returns – The name of the environment. Either ‘device’ or ‘simulator’.


Scrappy.Device:getModel()

Gets the model name.

returns – The name of the model.


Scrappy.Device:isReal()

Checks if the game is currently running on a physical device.

returns – True if it is, false otherwise.


Scrappy.Device:isSimulator()

Checks if the game is currently running in the simulator.

returns – True if it is, false otherwise.


Scrappy.Device:isTV()

Checks if the game is currently running on a TV based console.

returns – True if it is, false otherwise.


Scrappy.Device:isAppleTV()

Checks if the game is currently running on an AppleTV.

returns – True if it is, false otherwise.


Scrappy.Device:isAmazonTV()

Checks if the game is currently running on an Amazon FireTV.

returns – True if it is, false otherwise.


Scrappy.Device:isAndroidTV()

Checks if the game is currently running on an Android TV.

returns – True if it is, false otherwise.


Scrappy.Device:isIOS()

Checks if the game is currently running on an iOS device.

returns – True if it is, false otherwise.


Scrappy.Device:isAndroid()

Checks if the game is currently running on an Android device.

returns – True if it is, false otherwise.


Scrappy.Device:isOSX()

Checks if the game is currently running on an OSX device.

returns – True if it is, false otherwise.


Scrappy.Device:isWindows()

Checks if the game is currently running on a Windows device.

returns – True if it is, false otherwise.


Scrappy.Device:isLinux()

Checks if the game is currently running on a Linux device.

returns – True if it is, false otherwise.


Scrappy.Device:isKindle()

Checks if the game is currently running on an Amazon Kindle device.

returns – True if it is, false otherwise.


Scrappy.Device:isDesktop()

Checks if the game is currently running on a desktop.

returns – True if it is, false otherwise.


Scrappy.Device:isMobile()

Checks if the game is currently running on a mobile device.

returns – True if it is, false otherwise.


Scrappy.Device:isWeb()

Checks if the game is currently in a browser.

returns – True if it is, false otherwise.


Scrappy.Device:getTargetStore()

Gets the name of the store that the app was built for.

returns – The name of the store.


Scrappy.Device:destroy()

Destroys this library.


Examples

Thank the player

if Scrappy.Device:isIOS() then
	print( "Thank you random player for buying an expensive phone and then quibbling over spending pennies on an app!" )
elseif Scrappy.Device:isKindle() then
	print( "Thank you personally for being the one user that owns a Kindle Fire." )
elseif Scrappy.Device:isAndroid() then
	print( "Thank you random player for buying one of about a million different variants of Android phones, this will be fun to develop for!" )
end