1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
//
// component.ss
// Basic Component usage
// Copyright 2018 Alexandre Martins <alemartf(at)gmail(dot)com>
//
// Object Parrot has two components:
// Blabber and Time Bomb.
object "Parrot"
{
blabber = spawn("Blabber");
bomb = spawn("Time Bomb");
state "main"
{
}
}
object "Blabber"
{
state "main"
{
if(timeout(2)) // blab every 2 seconds
state = "blab";
}
state "blab"
{
Console.print("Hello!");
state = "main";
}
}
object "Time Bomb"
{
state "main"
{
if(timeout(15)) // explode after 15 seconds
state = "explode";
}
state "explode"
{
Console.print("BOOOM!");
parent.destroy(); // destroy the parent object
Application.exit();
}
}
object "Application"
{
parrot = spawn("Parrot");
state "main"
{
}
}
|