Help to download project from code.gamelet.com, edit/test in vscode and sync back to server.
You can download your CG project files to local and create a nice workspace of VSCode to develop locally.
Before creating the workspace, you need to download a token file in your project page.
- Open your project page on code.gamelet.com
- Open the "Project Info" panel from the right-side toolbar.
- Click the "Npm" button above the project code.
- Toggle the "Allow local dev with npm"
- Click the "Download dev-token" button to download
Make sure you have the token file in a proper folder, and the apps below are installed
- Install gamelet-cli
npm install -g gamelet-cli
- Create workspace of your project
Run the command in the folder of the token file:
gamelet download
Choose a token file when the command prompts you a list of choices. The command will create the workspace in a default folder that is named by the project code.
If custom folder of workspace is desired, use the flag --dir
// assign a custom folder
gamelet download --dir=testfolder
// assign a token file and a folder
gamelet download myProject.token --dir=testfolder
- Install npm packages
// enter the folder that is created from the above command
cd your-project-folder-just-created
// install packages
npm install
- Transpile and run a local server
// one line command
npm start
The command will transpile your typescripts and re-transpile when any file is changed. It also creates a local server so you can test the project at http://localhost:3000
- Test and Debug
Open the "Run and Debug" on the left-side-toolbar of your vscode, find and click the "Play Game" button to run the game. Change the button to "Test Module" to run the testbed.
- Sync the workspace from the CG project
After the workspace is built, you can run the below command to sync resources from your CG project on code.gamelet.com
// run the commands inside the workspace folder
// sync everything and merge sources from CG
gamelet merge
// sync only sources
gamelet merge --item=source
// sync only sources without git commit
gamelet merge --item=source --force
// sync only resources
gamelet merge --item=resource
// sync items and badges
gamelet merge --item=item,badge
/**
* available sync items are
* - source
* - resource
* - item
* - badge
* - score
*/
- Upload the sources back to CG
Once you are satisfied with the codes, you can upload the source back to the CG server. Before uploading, make sure you have merge the latest sources from server by running the command "gamelet merge".
// run the commands inside the workspace folder
// merge first
gamelet merge
// upload
gamelet upload