CS shorthand for CraftStudioEdit

Rather than typing CraftStudio.Something all the time, starting with CraftStudio Beta, you can now use simply CS.Something, which saves on typing!


[table] CraftStudio.FindAsset( [string] fully-qualified asset name, [string] asset type="" )

Returns the specified asset (a sprite, model, model animation, map, tile set, scene, script or document).

The fully-qualified name of an asset looks like this: Characters/Enemies/Gobelin. It's the path from the root of the hierarchy to the asset, with folders separated by slashes.

You can optionally specify the type of asset you're looking for as a second parameter. This is useful when you have several assets with the same name but different types (most common case being having a Map and a Scene with the same name). Valid types are: Model, Map, TileSet, ModelAnimation, Scene, Sound, Script.


CraftStudio.LoadScene( [Scene] scene asset to load )

Schedules loading the specified scene after the current tick (1/60th of a second) has completed.

When the new scene is loaded, all of the current scene's game objects will be removed.

Calling this function doesn't immediately stops the calling function. As such, you might want to add a return statement afterwards.

You can use CraftStudio.FindAsset to get a scene asset to pass to CraftStudio.LoadScene.


[GameObject or nil] CraftStudio.AppendScene( [Scene] scene asset to append, [GameObject] parent=nil )

Appends the specified scene to the game by instantiating all of its game objects. Contrary to CraftStudio.LoadScene, this doesn't unload the current scene nor waits for the next tick: it happens right away.

You can optionally specify a parent game object which will be used as a root for adding all game objects.

You can use CraftStudio.FindAsset to get a scene asset to pass to CraftStudio.AppendScene. If there is a single root object in the specified scene, then this object is returned, otherwise the return value is nil.


[GameObject] CraftStudio.Instantiate( [string] name, [Scene] scene to instantiate, [GameObject] parent=nil )

Creates a new game object with the specified name and containing a copy of the specified scene inside. You can optionally specify a parent game object for the newly-created game object.

This is useful for inserting a "preset" object / prefab into a scene at runtime. For instance you could define a character made of multiple game objects and components in a separate scene and insert it into your level by calling CraftStudio.Instantiate.


[GameObject] CraftStudio.FindGameObject( [string] game object name )

Returns the first game object with the specified name, or nil if none is found.


[GameObject] CraftStudio.CreateGameObject( [string] name, [GameObject] parent=nil )

Creates a new empty game object with the specified name and returns it. You can optionally specify a parent game object for the newly-created game object.

Once your game object is created, you can add components to it with GameObject:CreateComponent and GameObject:CreateScriptedBehavior.


CraftStudio.Destroy( [table] game object or component or dynamically loaded asset )

Removes the specified game object (and all of its descendants) or the specified component from its game object.

You can also optionally specify a dynamically loaded asset for unloading (See Map.LoadFromPackage )



Quits the game at the end of the current frame.