Castle
DownloadsGet the Castle client.Frequently Asked QuestionsLearn more about Castle.ExamplesUse this list of examples to bootstrap your game.Quick StartGet started in under 5 minutes.Creating an AccountWhy and how to create a Castle account.Make Your First GameFollow this small tutorial to get oriented with a basic workflow.Describe your Game with a Castle Project FileThis tutorial will provide an overview and motivation for a project file.Adding Games to your ProfileShare games you made by adding them to your profile on Castle.Hosting Your Own GamesLearn how to add games to Castle which are hosted on another service.Game Dimensions and ScalingChange the dimensions and scaling behavior of your Castle game.Manually Make a New Castle Game from ScratchAn educational resource for advanced usersCastle Project File ReferenceThe project file contains the title, description and other metadata about your game.User API ReferenceGet information about users playing your game.Post API ReferenceIntegrate with Castle's post system.Storage API ReferenceStore shared or per-user data in the cloud.Game API ReferenceNavigate to or get information about other games on Castle.UI API ReferenceDisplay user interface elements such as buttons and text boxes that allow users to interact with your game.System API ReferenceGet information about or perform activities relating to the system Castle is running on.Code Loading API ReferenceLow-level functionality for loading Lua code over the network.Community Reference LinksUseful community links for learning about Lua and LÖVE.

System API Reference

The system API lives in the castle.system module. The Castle sytem API lets you access information about or perform activities relating to the underlying system Castle is running on.

castle.system.isDesktop()

Returns true if running on a user's desktop (Windows or macOS) system, false otherwise.

castle.system.isRemoteServer()

Returns true if running on a Castle remote multiplayer server, false otherwise.

castle.system.setDimensions(width, height)

Set the expected dimensions of your game in LÖVE units. This is the same setting defined by the dimensions key in the Castle Project File, except you can set it dynamically through code. You can also call castle.system.setDimensions('full') to get the dimensions: full behavior. See Game Dimensions and Scaling for more information on how this setting affects your game.
Since this call updates the Castle UI layout to re-position your game, it is recommended to call this function at most once at the start of your game (in that case preferring to use the Castle Project File so settings take effect immediately on load), or only rarely afterward, say when the user changes a setting or other important events occur.

castle.system.setScalingModes(up, down)

Set the scaling mode for your game when it's not in dimensions: full mode. This is the same setting defined by theupscaling and downscaling keys respectively in the Castle Project File, except you can set them dynamically through code. Each of up and down can be 'on', 'step' or 'off'. You can also call this function with just one argument to set the same behavior for both upscaling and downscaling. See Game Dimensions and Scaling for more information on how this setting affects your game.
Since this call updates the Castle UI layout to re-position your game, it is recommended to call this function at most once at the start of your game (in that case preferring to use the Castle Project File so settings take effect immediately on load), or only rarely afterward, say when the user changes a setting or other important events occur.

castle.system.getGlobalScaling()

Returns a number which is the scaling factor of the user's system Castle is running on. This is equal to 1 on all systems other than Windows. On Windows this depends on the user's scale setting under "Display settings." It returns the fractional value corresponding to this percentage value. So, for example, if the user's setting is 125%, it returns 1.25.