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.

Game API Reference

The game API lives in the castle.game module. The Castle game API lets you navigate to or get information about other games on Castle.
Below you will see references to 'game URLs'. These are URLs such as 'https://castle.games/@bridgs/quickdraw-blackjack' which refer to a game registered on Castle, but could also be HTTPS URIs to raw Lua code or Castle Project Files on the web. You will also see references to 'game ids', which are unique strings that identify each game on Castle. Currently there is no user interface to get the game id of a game on Castle, but this may be added soon.

castle.game.load(gameIdOrUrl, params)

Ask Castle to load a different game. This closes the currently running game to load the other one. gameIdOrUrl (string) should identify the other game to navigate to, and can either be a URL or a game id. params should be a value to pass to the game being opened. params must have a value type as described in the storage API reference under "Keys and values". This value could itself be a table, allowing you to pass many values. The target game can retrieve params using castle.game.getInitialParams.

castle.game.getInitialParams()

Get the params passed to castle.game.load when loading this game. If no params was passed, or this game was simply opened by clicking on the game or on a post in Castle's user interface, returnsnil.

castle.game.getReferrer()

Get the game that used castle.game.load to load the current game. A table with the following keys about the referrer game is returned:
  • gameId (string): The game id.
  • owner (table): A table of data about the user that owns that game. Has the same format as returned by castle.user.getMe as described in the user API reference
  • title (string): The game title (as defined in the Castle Project File).
  • url (string): The game URL.
  • description (string): The game description (as defined in the Castle Project File).