Castagne Engine

Documentation (Dev Branch)

Castagne Engine

Getting Started

Editor

Gametypes

Intermediate

Making a Game

Pushing Castagne

Advanced

Modules

Core Reference

Contains the absolute core functions of the engine. This should be included in virtually all cases, and tends to be relied upon by the engine itself.

Variables

These functions are focused on basic variable and flag manipulation.

Functions

Flag[1][AllPhases, Init, Action, Reaction, Manual]Basic
Raises a flag. Flags are reset at the beginning of each frame and allow you to communicate easily between modules. Flags are tested with L branches.
  • Arg 1: Flag name
Unflag[1][AllPhases, Init, Action, Reaction, Manual]Basic
Unsets a flag, if it was set earlier.
  • Arg 1: Flag name
FlagNext[1][AllPhases, Init, Action, Reaction, Manual]Basic
Raises a flag at the beginning of the next frame.
  • Arg 1: Flag name
UnflagNext[1][AllPhases, Init, Action, Reaction, Manual]Basic
Unsets a flag for the next frame, if it was set earlier with FlagNext.
  • Arg 1: Flag name
Set[2][Init, Action, Manual]Basic
Sets a variable to a given integer value.
  • Arg 1: Variable name
  • Arg 2: Value
SetStr[2][Init, Action, Manual]Basic
Sets a variable to a given string (text) value.
  • Arg 1: Variable name
  • Arg 2: Value

Variables

_Flags[][ResetEachFrame]
The list of flags held by the entity
_FlagsNext[][]
The list of flags to be raised at the beginning of next frame.

Mathematics (Simple)

Basic mathematical functions.

Functions

Add[2, 3][Init, Action, Manual]Basic
Adds two numbers and stores it in the first variable or an optional third variable.
  • Arg 1: First number
  • Arg 2: Second number
  • Arg 3: (Optional) Destination Variable
Sub[2, 3][Init, Action, Manual]Basic
Substracts two numbers and stores it in the first variable or an optional third variable.
  • Arg 1: First number
  • Arg 2: Second number
  • Arg 3: (Optional) Destination Variable
Mul[2, 3][Init, Action, Manual]Basic
Multiplies two numbers and stores it in the first variable or an optional third variable.
  • Arg 1: First number
  • Arg 2: Second number
  • Arg 3: (Optional) Destination Variable
Div[2, 3][Init, Action, Manual]Basic
Divides two numbers and stores it in the first variable or an optional third variable.
  • Arg 1: First number
  • Arg 2: Second number
  • Arg 3: (Optional) Destination Variable
Mod[2, 3][Init, Action, Manual]Basic
Computes the remainder of the division between two numbers and stores it in the first variable or an optional third variable.
  • Arg 1: First number
  • Arg 2: Second number
  • Arg 3: (Optional) Destination Variable
Max[2, 3][Init, Action, Manual]Basic
Stores the bigger of the two numbers in the first variable or an optional third variable.
  • Arg 1: First number
  • Arg 2: Second number
  • Arg 3: (Optional) Destination Variable
Min[2, 3][Init, Action, Manual]Basic
Stores the smaller of the two numbers in the first variable or an optional third variable.
  • Arg 1: First number
  • Arg 2: Second number
  • Arg 3: (Optional) Destination Variable

Entities

These functions are focused on entity manipulation.

These functions work using a concept known as the Target Entity, which can be any other entity. This may be selected through the 'TargetEntity' family of functions.

This entity may then be used as a reference point for specific functions. Something to keep in mind is that the data gathered from the target entity like this will be from the end of last frame, while the data alteration directives will be effective at the end of the phase. In the case of targetting an entity currently being created, the values will be set just after creation, at the beginning of the next frame.

If several entities want to alter the same value on the same target entity, the behaviour should be considered undefined (but in practice, will use the one from the entity with the highest ID).

The target entity is reset at the beginning of each frame, to the current entity (it targets itself). This can be overriden by other modules (mainly, FlowFighting which will target the opponent if playing with two players)

Functions

CreateEntity[1][Init, Action, Manual]Intermediate
Creates a new entity at the beginning of the next frame, using the given entity name, and targets it. Also sets some parameters to make entity creation easier (position at root, copy facing)
  • Arg 1: Init Script
CreateEntityRaw[1][Init, Action, Manual]Intermediate
Creates a new entity at the beginning of the next frame, using the given entity name, and targets it.
  • Arg 1: Init Script
DestroyEntity[0][Init, Action, Manual]Intermediate
Deletes the currently targetted entity at the beginning of the next frame.
GetCurrentEntityID[1][Init, Action, Manual]Advanced
Write the current entity ID to a variable.
  • Arg 1: The variable to write the ID to
GetTargetEntityID[1][Init, Action, Manual]Advanced
Write the target entity ID to a variable.
  • Arg 1: The variable to write the ID to
TargetEntityByID[1][Init, Action, Manual]Advanced
Targets an entity using its ID
  • Arg 1: The ID of the entity to target
TargetEntitySelf[0][Init, Action, Manual]Advanced
Targets the current entity (autotargetting).
CopyFromTarget[1, 2][Init, Action, Manual]Intermediate
Copies a variable from the target entity. This will however copy the variable value from the end of the last frame.
  • Arg 1: Variable name on current entity
  • Arg 2: (Optional) Variable name on target entity
CopyToTarget[1, 2][Init, Action, Manual]Intermediate
Copies a variable to the target entity. This will be applied at the end of the phase, or at initialization for new entities.
  • Arg 1: Variable name on current entity
  • Arg 2: (Optional) Variable name on target entity
SetIntInTarget[2][Init, Action, Manual]Intermediate
Sets a variable in the target entity. This will be applied at the end of the phase, or at initialization for new entities.
  • Arg 1: Variable name on target entity
  • Arg 2: Variable Value
SetStrInTarget[2][Init, Action, Manual]Intermediate
Sets a variable in the target entity. This will be applied at the end of the phase, or at initialization for new entities.
  • Arg 1: Variable name on target entity
  • Arg 2: Variable Value
FlagInTarget[1][Init, Action, Manual]Intermediate
Sets a flag in the target. This will be applied at the end of the phase, but doesn't carry over to the next frame, meaning you'll most likely only access it in Reaction phase.
  • Arg 1: Flag Name
UnflagInTarget[1][Init, Action, Manual]Intermediate
Unsets a flag in the target. This will be applied at the end of the phase, but doesn't carry over to the next frame, meaning you'll most likely only access it in Reaction phase.
  • Arg 1: Flag Name

Variables

_CopyToBuffer[][]
Global buffer to hold the variables entities set to each other.
_FlagTargetBuffer[][ResetEachFrame]
Global buffer to hold the flags entities set to each other.
_TargetEID-1[ResetEachFrame]
Hold the current target EID, reset each frame.

States

Holds functions and variables pertaining to the states themselves. Handles transitions, and state calls.

Functions

Transition[0, 1, 2, 3][Init, Reaction, Manual]Basic
Changes the current script/state. If multiple changes are made in the same frame, the first one with the biggest priority wins. Changes from one state to itself are ignored, except if allowing self-transition in the arguments. The change is buffered and executed at the end of the transition phase or the init phase. Calling the function without arguments will cancel the transition.
  • Arg 1: State name
  • Arg 2: (Optional) Priority
  • Arg 3: (Optional) Allow self-transition
TransitionBuffer[0, 1, 2, 3][Init, Action, Reaction, Manual]Basic
Same as Transition, but also works during the action phase. This can make some code simpler, and is separated because some confusing logic may happen when buffering all the time.
  • Arg 1: State name
  • Arg 2: (Optional) Priority
  • Arg 3: (Optional) Allow self-transition
Call[1][Init, Action, Reaction, Freeze, Manual]Basic
Executes another script/state. When the script is known at compile time, it is inlined and thus doesn't slow down execution.
  • Arg 1: Name of the state to call
CallParent[1][Init, Action, Reaction, Freeze, Manual]Intermediate
Execute another script/state on the parent skeleton.
  • Arg 1: Name of the state to call.
ExecuteAfter[0, 1][Init, Action, Reaction, Freeze, Manual]Intermediate
Schedules a call to be executed after the current one has been done. These will be executed only once - ExecuteAfter calls inside an ExecuteAfter are ignored. Giving no arguments will cancel existing calls, if done before the end.
  • Arg 1: (Optional) Name of state to call

Variables

_StateInit-Main[NoInit]
The name of the current state
_StateTargetNull[ResetEachFrame]
The name of the state we want to transition to.
_StateFrameID0[ResetEachFrame]
The FrameID counted from when we transitionned into the state. (Starts at 1, 0 being the frame the transition is done in.)
_StateChangePriority-100000[ResetEachFrame]
Current priority for the state transition, given by Transition()
_StateStartFrame0[]
The FrameID the current state started in.
_CallParentLevel0[ResetEachFrame]
Helper variable for which level the CallParent function shall call to.
_ExecuteAfterCalls[][ResetEachFrame]
Hold the list of states that will be called after the main state, filled by ExecuteAfter()

Debug

Functions that help understanding what happens inside the code.

Functions

Log[1][Init, Action, Freeze, Manual]Basic
Writes a log to the console output during the Action phase.
  • Arg 1: Text to write
LogR[1][Reaction, Manual]Intermediate
Writes a log to the console output during the Reaction phase only.
  • Arg 1: Text to write
LogB[1][Init, Action, Reaction, Manual]Intermediate
Writes a log to the console output during the Init, Action, and Reaction phases.
  • Arg 1: Text to write

Engine Functions

Functions to control the engine flow.

Functions

FreezeFrames[1][Init, Action, Manual]Intermediate
Sets an amount of freeze frames to be effective immediately. Uses the max of the remaining frames and current frames.
  • Arg 1: Amount of frames to wait

Game Configuration

Configuration related to the game itself, including Characters and Stages.

Config

GameTitleUntitled Castagne Game[Basic]Basic
The name of the game.
GameVersionUnspecified Version[Basic]Basic
The version of the game, can be used to differenciate patches.
CharacterPathsres://castagne/example/fighter/baston/Baston.casp, res://castagne/example/fighter/baston/Baston2D.casp[Hidden]
The list of characters that can be loaded.
Skeletons[Hidden]
The list of skeletons that may be loaded. Used when the Skeleton parameter of a character is set to an int, or when none is given.
StagePathsres://castagne/example/stage/Stage.tscn[Intermediate]Intermediate
The list of stages that may be loaded.

Castagne Internals

Variables and configurations relating to the engine itself. Please be careful when changing these.

Config

CastagneVersionCastagne v0.53[Hidden, Reload, Advanced]Advanced
Internal version of the Castagne engine.
PathEngineres://castagne/engine/CastagneEngine.tscn[Expert]Expert
Filepath to the engine scene.
PathEditorres://castagne/editor/CastagneEditor.tscn[Expert]Expert
Filepath to the editor scene.
PathDevToolsres://castagne/devtools/DevTools.tscn[Expert]Expert
Filepath to the devtools scene.
PathMainMenures://castagne/menus/mainmenu/DefaultMainMenu.tscn[Advanced]Advanced
Filepath to the main menu scene.
PathCharacterSelectres://castagne/menus/characterselect/DefaultCharacterSelect.tscn[Advanced]Advanced
Filepath to the character select screen scene.
PathPostBattleres://castagne/menus/postbattle/DefaultPostBattle.tscn[Advanced]Advanced
Filepath to the post battle scene.
ConfigSkeleton[ReloadFull, Advanced]Advanced
Path to the config skeleton of this file. Used to build additively on top of a base config, which is done for the genre selection for instance.

Variables

_FrameID0[]
The number of game frames since the beginning of the match.
_TrueFrameID0[]
The number of actual frames since the beginning of the match.
_SkipFrameFalse[ResetEachFrame]
Tells the engine if it should do a skip loop.
_FrozenFrameFalse[ResetEachFrame]
Tells the engine if it should do a freeze loop
_SkipFrames0[]
Helper variable, counting the number of frames to skip remaining.
_FreezeFrames0[]
Helper variable, counting the number of frames in freeze remaining.
_CurrentEntityID0[]
Remembers the next ID for a new entity.
_EntitiesToInit[][]
List of entities to handle in the next Init Phase
_EntitiesToDestroy[][]
List of entities to destroy at the beginning of the next loop.
_ActiveEntities[][]
List of entities that are executed each frame.
_NbPlayers0[]
Remembers the amount of players.

Castagne Modules

Configurations relating to the module system of Castagne.

Config

Modulescoreset, physics, graphics, flow, user[Hidden, ReloadFull, Advanced]Advanced
List of modules to load for matches.
Modules-coreseteditor, functions, attacks, sound, input, menus, tmp[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-editorres://castagne/modules/castagne/CMEditor.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-functionsres://castagne/modules/coreset/CMFunctions.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-soundres://castagne/modules/coreset/CMSound.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-attacksres://castagne/modules/coreset/CMAttacks.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-inputres://castagne/modules/coreset/CMInput.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-menusres://castagne/modules/coreset/CMMenus.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-flowflowfighting[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-flowgenericres://castagne/modules/flow/CMFlow.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-flowfightingres://castagne/modules/flow/CMFlowFighting.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-flowuser[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-physicsphysics2d[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-physics2dres://castagne/modules/physics/CMPhysics2D.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-physicsuser[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-graphicsgraphics25d[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-graphics2dres://castagne/modules/graphics/CMGraphics2D.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-graphics25dres://castagne/modules/graphics/CMGraphics2HalfD.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-graphics3dres://castagne/modules/graphics/CMGraphics3D.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-graphicsuser[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-user[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-tmpui[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-uires://castagne/modules/ui/FightingUI.tscn[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-castagne-standardeditor, functions, sound, attacks, input, menus, flowgeneric, flowfighting, physics2d, graphics2d, graphics25d, graphics3d, ui[Hidden, Advanced]Advanced
List of the standard castagne modules, which are loaded automatically for documentation purposes

Castagne Starter

Data relating to the CastagneStarter system, which may start the editor or game depending on how the project is launched.

Config

Starter-Option0[Hidden, Advanced]Advanced
Remembers the option chosen in the starter.
Starter-Timer0[Intermediate]Intermediate
Time before a choice is made automatically, can be stopped with any keyboard input. Set to zero to skip the timer, or -1 to disable the time limit.
Starter-P10[Hidden, Advanced]Advanced
Obsolete
Starter-P20[Hidden, Advanced]Advanced
Obsolete