Baguette is an extremely light-weighted scripting language for conversation-based javascript game development.
install npm
sudo apt-get install npm
then install baguette
npm install -g baguette
Baguette contains two things: a compiler and a virtual machine.
Suppose we have a piece of baguette code like below:
function helloworld()
{
a = 1+ 2 * 3;
print("Hello World!");
print("a="+a);
return a;
}
We save it in helloworld.bag. Then we use the compiler - bcc, to compile it to baguette's inermediate code (.bic):
bcc helloworld.bag -o helloworld.bic
Baguette's virtual machine is baguette-vm.js. You can use it in any of your javascript project.
Let's run our code with node.js.
Create an npm project, and copy baguette-vm.js into the folder
mkdir baguette-helloworld
cd baguette-helloworld
npm init
cp {baguette-vm.js directory} .
Create a helloworld.js like below:
var fs = require('fs');
var BaguetteVM = require('.baguette-vm').BaguetteVM;
let gameStats = {
a: 1,
b: 2,
c: 3,
};
let gameFuncs = {
print: {
pauseAfterComplete: false,
funcImp: (text) => console.log(text),
}
};
let content = fs.readFileSync('helloworld.bic', 'utf8');
let baguetteVM = new BaguetteVM(content, gameStats, gameFuncs);
let result = baguetteVM.runFunc('helloworld');
Basically, to run a baguette virtual machine, you need three things - the code (.bic file), the environment variavbles, and the environment functions.
Environment variables are defined before running the vm. Because baguette cannot define local or global variables (yet), any variable used in the code must be defined as environment variables. This is also the way the vm interact with its host.
Environment functions are also functions defined in the host. They usually contains UI functions. Among all properties of a function, pauseAfterComplete means the vm stops after this function call. User must call vm.continue() to continue running the bic code. This is used in UI functions like showText, print, etc.
Finally, run the project:
node helloworld.js
And you get the output:
Hello World!
a=7
Explain how to run the automated tests for this system
Explain what these tests test and why
Give an example
Explain what these tests test and why
Give an example
Add additional notes about how to deploy this on a live system
- Dropwizard - The web framework used
- Maven - Dependency Management
- ROME - Used to generate RSS Feeds
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Billie Thompson - Initial work - PurpleBooth
See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
- Hat tip to anyone who's code was used
- Inspiration
- etc