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][Init, Action, Manual, Subentity]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][Init, Action, Manual, Subentity]Basic
Unsets a flag, if it was set earlier.
  • Arg 1: Flag name
FlagNext[1][Init, Action, Manual, Subentity]Basic
Raises a flag at the beginning of the next frame.
  • Arg 1: Flag name
UnflagNext[1][Init, Action, Manual, Subentity]Basic
Unsets a flag for the next frame, if it was set earlier with FlagNext.
  • Arg 1: Flag name
Set[2][Init, Action, Manual, Subentity]Basic
Sets a variable to a given integer value.
  • Arg 1: Variable name
  • Arg 2: Value
SetStr[2][Init, Action, Manual, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]Intermediate
Deletes the currently targetted entity at the beginning of the next frame.
GetCurrentEntityID[1][Init, Action, Manual, Subentity]Advanced
Write the current entity ID to a variable.
  • Arg 1: The variable to write the ID to
GetTargetEntityID[1][Init, Action, Manual, Subentity]Advanced
Write the target entity ID to a variable.
  • Arg 1: The variable to write the ID to
TargetEntityByID[1][Init, Action, Manual, Subentity]Advanced
Targets an entity using its ID
  • Arg 1: The ID of the entity to target
TargetEntitySelf[0][Init, Action, Manual, Subentity]Advanced
Targets the current entity (autotargetting).
TargetSave[0][Init, Action, Manual, Subentity]Advanced
Saves the target, which can then be recalled with TargetRecall at will. This is used at regular intervals and should represent your main target.
TargetRecall[0][Init, Action, Manual, Subentity]Advanced
Recalls a previously set target. This is used at regular intervals and should represent your main target.
CopyFromTarget[1, 2][Init, Action, Manual, Subentity]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
CopyFromTargetNow[1, 2][Init, Action, Manual, Subentity]Advanced
Copies a variable from the target entity. THIS WILL COPY THE VALUE IMMEDIATELY AND AS SUCH IS SUSCEPTIBLE TO ORDER EXECUTION BUGS.
  • Arg 1: Variable name on current entity
  • Arg 2: (Optional) Variable name on target entity
CopyToTarget[1, 2][Init, Action, Manual, Subentity]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, Subentity]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, Subentity]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, Subentity]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, Subentity]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.
_TargetSavedEID-1[]
Hold the current saved target EID, persistent over frames. Should represent the main target.

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, Subentity]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, Subentity]Basic
Executes another script/state. Script must be known at compile time.
  • Arg 1: Name of the state to call
CallParent[0][Init, Action, Reaction, Freeze, Manual, Subentity]Intermediate
Execute the same script on the parent skeleton.
CallFromMain[1][Init, Subentity, Manual]Basic
Executes another script/state from the main entity. Script must be known at compile time.
  • Arg 1: Name of the state to call
CallAfter[1][Init, Action, Reaction, Freeze, Manual, Subentity]Intermediate
Adds a static call at the end of the state.
  • Arg 1: 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[]
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.

Debug

Functions that help understanding what happens inside the code.

Functions

Log[1][Init, Action, Freeze, Manual, Subentity]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, Subentity]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, Subentity]Intermediate
Sets an amount of freeze frames to be effective immediately. Freeze only affects this entity
  • Arg 1: Amount of frames to wait
HaltFrames[1][Init, Action, Manual, Subentity]Intermediate
Sets an amount of freeze frames to be effective immediately. Halt stops time for everyone except this entity.
  • 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/examples/fighters/baston/Baston-25D.casp, res://castagne/examples/fighters/baston/Baston-2D.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/examples/stages/default-25d-stage/Default25DStage.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.
_HaltFrames0[]
Helper variable, counting the number of frames in halt phase remaining.
_CurrentEntityID0[]
Remembers the next ID for a new entity.
_EntitiesToInit[][]
List of entities to handle in the next Init Phase
_SubentitiesToInit[][]
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.
_ActiveFullEntities[][]
List of main entities that are executed each frame.
_ActiveSubentities[][]
List of subentities that are executed each frame.
_Player-1[]
_FighterID-1[]
_EID-1[]
_State[]
_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, audio, input, menus[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-editorres://castagne/modules/editor/CMEditor.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-functionsres://castagne/modules/general/CMFunctions.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-audiores://castagne/modules/general/CMAudio.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-attacksres://castagne/modules/attacks/CMAttacks.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-inputres://castagne/modules/general/CMInput.gd[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-menusres://castagne/modules/general/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-tmp[Hidden, ReloadFull, Expert]Expert
Standard Castagne Module. See the respective documentation for more info.
Modules-castagne-standardeditor, functions, audio, attacks, input, menus, flowgeneric, flowfighting, physics2d, graphics2d, graphics25d, graphics3d[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