Skip to main content


Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Fat Cerberus

Libraries / Re: [Script] Scenario 2.1.1
Was the SpiderMonkey-specific trick my use of the "getter" syntax for the framerate property?  If so that was probably a wise move what with TurboSphere now using V8, and I believe that syntax is deprecated in newer versions of SpiderMonkey anyway.  I really wish JS had an elegant method of defining properties outside of an object literal...

Anyway, feel free to merge it, yeah.  I'm actually in the process of cleaning up Scenario's codebase right now, making the code easier to read.  Right now it's a bit of a mess as I did some odd stuff (not putting spaces between function arguments, etc.)
Feature suggestion: Ability to change the font for the script editor.  Right now it appears to be hard-coded to use 10-point Courier New, which is murder on the eyes on a 1920x1080 17" laptop display.  I tend to prefer 11- or 12-point Consolas on this screen, but unlike the official editor, Sphere Studio doesn't appear to allow changing it.  I'd also like the ability to change the tab size.  The default tab stop of 2 is far too small.
Libraries / Re: [Script] Scenario 2.1.1
Haha, thanks Radnen, I had no idea about the gist tag.  I was wondering why you guys wanted me to use Gist for this... now I know. :)
Scenario is a cutscene engine for Sphere which allows you to coordinate complex cutscenes and other actions (such as animations) using multiple timelines and cooperative multithreading.

The current version is Scenario 3.8.1, released on March 14, 2015.

Get the script:

  • Added support for minisphere's IsSkippedFrame.
  • Refactored entire codebase and added documentation comments for all methods and scenelets.
  • Fixed bugs when forking inside of a doWhile loop where instructions inside the loop could overwrite each others' state.
  • Changed doWhile and doIf to take a function (lambda) as argument. The function will be called at scene time and should return true or false to determine how to proceed.
  • Removed scenelets doUntil and set.
  • Hotfix for broken doIf and doUntil scenelets.
  • Hotfix release to fix call scenelet regression in 3.7.
  • Hotfix release to restore fork functionality which was completely broken in 3.7.
  • BREAKING CHANGE - Removed 'state' argument from all scenelet functions; scenelets should store state data using 'this' instead. Any custom scenelets will have to be rewritten.
  • New optional finish handler for scenelets, called immediately after the scenelet stops running (i.e. when its update function returns false).
  • Support for variables: Use set to set a variable; increment or decement to add or subtract 1 from its value, respectively. Variables can be accessed in scenelet code via scene.variables['var_name']
  • New control-flow commands: doIf, doWhile, doUntildoIf executes a block of commands only if a specified condition is met, the other two are similar but execute the same block repeatedly (loop) while or until the condition is met, respectively.
  • Renamed beginFork and endFork to fork and end, respectively.
  • New scene looping feature: Pass 'true' to the Scenario() constructor for an endlessly looping scene. This is useful for running looping animations in the background. Call Scenario.stop() if you need to break the loop.
  • New optional waitUntilDone argument for run() that mimics the old blocking behavior. Helpful for cutscenes.
  • Color mask for the fadeTo command is now shared by all scenes and persists after a scene ends. Don't forget to fade back in or the player won't be able to see anything!
  • Screen fades and camera manipulations are no longer reverted automatically at the end of a scene. This must now be done manually.
  • Running a scene no longer clears its command queue.  This lets you run the same scene more than once. Great for caching animation commands!
  • Sphere map engine is no longer required to be running to execute a scenario.
  • Running a scenario no longer detaches input automatically. If this is needed, you must detach and reattach the input yourself.
  • Added new commands marquee and tween. The latter is great for coordinating complex UI animations.
  • Removed unusable marquee command.
  • User is required to call Scenario.initialize before using the engine.
  • Calls to Scenario.update and Scenario.render must be added to the update and render scripts, respectively.
  • run() now returns immediately instead of running its own update loop. If your game relied on the old blocking behavior, you'll have to modify it.
  • New method: scene.isRunning checks whether the scene is still executing and returns true if it is, false if not.
  • Built-in commands now use seconds instead of milliseconds for duration.
  • Renamed 1 identifier:
    • checkInput -> getInput
  • Added support for cascaded command calls. This is the preferred method for scene composition now; examples updated accordingly.
  • Completed refactoring started in 3.0.
  • Major refactoring to make the codebase more readable and less bug-prone.
  • Renamed 4 identifiers:
    • defineAction -> defineCommand
    • walkPerson -> movePerson
    • execute -> run
    • handleInput -> checkInput

How to use Scenario:
First things first: The Sphere map engine must be running in order for Scenario to work. Then when you need a cutscene, you write something like this:
Code: (javascript) [Select]
new Scenario()
    .marquee("Chapter 13: Some Random Girl Blows Up")
    .movePerson("Katelyn", "north", 100, 2, true)
    .pause(2.0)  // 2-second delay
    .run(true);  // true to wait until scene finished, false to run in background

The real power of Scenario, however, lies in its forking feature, which enables multiple simultaneous timelines. For example, you can have the background music (or the screen!) fade in while other actions take place at the same time. As in this example:
Code: (javascript) [Select]
new Scenario()
    .fork()  // fork the timeline
        // we're fading in, so we specify a transparent color (alpha=0) to fade to
        .fadeTo(CreateColor(0, 0, 0, 0), 5.0)  // fade in over 5 seconds
    .end()  // end the fork block
    .marquee("Chapter 13: Some Random Girl Blows Up")
    .movePerson("Katelyn", "north", 100, 2, true)
    .synchronize()  // pause until all forks are finished - we want to make sure the fade-in has finished before she blows up!

Starting with version 3.7, Scenario also includes support for conditional execution and looping.
Code: (javascript) [Select]
// The following scene flashes the screen to white and back twice:
var flashes = 0;
new Scenario()
    .doWhile(function() { return flashes++ < 2; })  // 2 iterations
        .fadeTo(CreateColor(255, 255, 255, 255), 0.25)
        .fadeTo(CreateColor(0, 0, 0, 0), 0.25)
Spherical News / Re: Welcome Back!!!
Im using my iPhone at work right now, but later when I get home I'll pull out my laptop and put up the latest version of Scenario.  I don't remember if I've made any breaking changes since the last update, but probably.

Sorry I unceremoniously disappeared before, I'll try to stick around this time! :)
Engine Development / Re: TurboSphere
So I'm curious, is TurboSphere's ultimate goal to be a drop-in replacement for the current 1.x engine? That's the vibe I'm getting, but I want to make sure.

Oh, and I also have to ask: It won't go Turbo and deliberately introduce game-breaking glitches into my game out of jealousy, will it?
Spherical News / Re: Welcome Back!!!
Hey guys, this is Bruce, the guy that did Scenario. :-)  It's good to see Spherical is getting a fresh start!