Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: nims on Mon 06/04/2015 14:53:55

Title: MODULE: CharacterSelections
Post by: nims on Mon 06/04/2015 14:53:55
Use this script to allow the user to play with 12 (max) different characters.
You can add players that must be enabled later, and cannot used initially in the game.
Also you can share inventory items between all players.

Note: Make sure you have added the GUI "gCharacterSelection" to your game to allow the user to choose a new player.

This GUI is shown when you call:
Code (ags) Select
CS.ShowGui();
You can tie it to a button on your GUI.

The following code adds the players to your game:
Code (ags) Select

function initialize_world_selector() {
btnCharacterSelection.Visible=false;
    //Enable the starting players the player can choose
    CS.AddCharacter(1, 1, cPlayer1);
    CS.AddCharacter(2, 2, cPlayer2);
    CS.AddCharacter(3, 3, cPlayer3,false );
}


You have the following functions available:
Code (ags) Select

function AddCharacter(int aCharacterNumber, int aStartingRoom, Character *aPlayer, bool aEnabled =true); //This adds a player to the game
function EnableCharacter(int aCharacterNumber); //This enables the button to go to a world
function DisableCharacter(int aCharacterNumber); //This disables the button to go to a world
function SetAsPlayer(int aCharacterNumber); //This changes the current player
function ShowGui(); //This opens the character selection GUI
function AddSharedInventory(InventoryItem *aItemToAdd); //This adds an inventory item to all the players
function LoseSharedInventory(InventoryItem *aItemToAdd); //This loses an inventory item to all the players


Download the module here. (https://dl.dropboxusercontent.com/u/20918686/ags/CharacterSelections.zip)
Title: Re: MODULE: CharacterSelections
Post by: Mehrdad on Tue 07/04/2015 15:02:35
Great works;)