A programming language designed story-telling with strong programming capabilities in games.
Given an integer n, for every integer i <= n, the task is to print “FizzBuzz” if i is divisible by 3 and 5,
“Fizz” if i is divisible by 3, “Buzz” if i is divisible by 5 or i (as a string) if none of the conditions are true.
<?
for(local i = 0; i < n; i++) {
local result = ""
if(i % 3 == 0) {
result += "Fizz"
}
if(i % 5 == 0) {
result += "Buzz"
}
else if(result.length == 0) {
result = i
}
print(result + " ")
}
?>Simple dialogue script.
<entry id="hello" speaker="Traveller">
Hello potion seller, I am going into battle and I want your strongest potions.
<link target="too strong" />
</entry>
<entry id="too strong" speaker="Potion Seller">
My potions are too strong for you traveller.
<link target="going into battle" />
<link target="insult seller" />
</entry>
<entry id="going into battle" speaker="Traveller">
Please, potion seller. I'm going into battle and I need only your strongest potions.
<link target="you don't know" />
</entry>
<entry id="you don't know" speaker="Potion Seller">
You don't know what you ask for, Traveller, my strongest potions
will kill a dragon, let alone a man.
<link target="you don't know 2" />
</entry>
<entry id="you don't know 2" speaker="Potion Seller">
What you need is a seller that sells weaker potions because my
potions are too strong for you, Traveller.
<link target="insult seller" />
</entry>
<entry id="insult seller" speaker="Traveller">
Well, You've had your say, Potion Seller, and I'll have mine.
<link target="insult seller 2" />
</entry>
<entry id="insult seller 2" speaker="Traveller">
You're a rascal. A rascal with no respect for Knights.
No respect for <i>anything</i>.
<link target="final" />
</entry>
<entry id="final" speaker="Potion Seller">
Why respect Knights... When my potions can do anything
that you can.
</entry>Loading a story and procedurally iterating over entries.
This prints each entry that's progressing.
var story = new FableScript("FileName.f");
story.Progressed += (entry) =>
{
var tags = string.Join(", ", entry.Tags.Select(tag => $"{tag.Name}: {tag.Value}"));
Console.WriteLine($"{entry.Id}({tags}): {entry.Text}");
};
story.Finished += () =>
{
Consnole.WriteLine("FableScript story finished!");
};
story.Start();