Recent site activity

Game Engine‎ > ‎

Scripting Engine

The scripting engine loads scripts from a MySQL database text field, which is encoded in JSON format.  The script is passed to TMJ through AJAX, where it is immediately executed on receipt.  The following are commands in the scripting language.

Choice {"text"} - pop up a dialog window with text / yes
'dialog', 'text': - pop up a dialog window with text / close the dialog window when blank
Fight [background] [enemy] - initiate a fight with a boss
Face {character} [up|down|left|right] - turn the character a given direction
FillStats [character] - recharge HP and MP, remove ailments
GetItem [item] - obtain an item
Link [level] [x] [y] {script} - jump to another level / run a script on another level
Map [map] [x] [y] [frames] - temporarily display the map at the given coordinates
Move {character} [x] [y] {absolute} - move the party / reposition the party
Overlay [fade-in] [sustain] [fade-out] ["text"] 
'repeat, 'times' - repeat the previous command a number of times
UseItem [item] - make use of an inventory item

Sample script from Teaser 3:

script = [
{'command':'start'},
{'command':'move', 'x':120, 'y':936, 'absolute':true},
{'command':'face', 'direction':'up'},
{'command':'dialog', 'text':'Welcome to the third teaser for The Mystical Journey'},
{'command':'repeat', 'times':60},
{'command':'dialog', 'text':'We are starting in the village of Bryn, which is where the final game will begin.'},
{'command':'repeat', 'times':80},
{'command':'dialog', 'text':'It looks like Jasper is already here for us. Let\'s try to get his attention.'},
{'command':'repeat', 'times':120},
{'command':'dialog', 'text':''},
{'command':'repeat', 'times':20},
{'command':'dialog', 'text':'Hey, Jasper.'},
{'command':'repeat', 'times':30},
{'command':'dialog', 'text':''},
{'command':'repeat', 'times':30},
{'command':'dialog', 'text':'JASPER!!'},
{'command':'repeat', 'times':5},
{'command':'gesture', 'gesture':3},
{'command':'repeat', 'times':10},
{'command':'gesture', 'gesture':0},
{'command':'repeat', 'times':10},
{'command':'gesture', 'gesture':1},
{'command':'repeat', 'times':10},
{'command':'gesture', 'gesture':2},
{'command':'repeat', 'times':10},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':10},
{'command':'dialog', 'text':'Thank you, Jasper. Now let\'s continue...'},
{'command':'repeat', 'times':40},
{'command':'gesture', 'gesture':0},
{'command':'repeat', 'times':3},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':17},
{'command':'dialog', 'text':'Jasper is the grandson of the mining foreman and becomes the first playable character. We will get to the circumstances of this in a moment.'},
{'command':'repeat', 'times':120},
{'command':'dialog', 'text':'For now, though, he will give us a tour of Bryn. Heroism will have to wait.'},
{'command':'repeat', 'times':80},
{'command':'dialog', 'text':''},
{'command':'repeat', 'times':20},
{'command':'face', 'direction':'up'},
{'command':'move', 'x':0, 'y':-2},
{'command':'repeat', 'times':113},
{'command':'move', 'x':120, 'y':530, 'absolute':true},
{'command':'dialog', 'text':'Rather than staring at Jasper\'s backside, we\'ve skipped to the entrance to the mine, which is north of Bryn.'},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':119},
{'command':'dialog', 'text':'Bryn\'s economy depends on export of valuable ores that are derived from the mine.'},
{'command':'repeat', 'times':100},
{'command':'dialog', 'text':'These ores can be used in alloys to create anything from weapons to machinery.'},
{'command':'repeat', 'times':100},
{'command':'face', 'direction':'up'},
{'command':'dialog', 'text':''},
{'command':'move', 'x':0, 'y':-2},
{'command':'repeat', 'times':53},
{'command':'move', 'x':0, 'y':0},
{'command':'dialog', 'text':'Here we are now at the mine entrance.'},
{'command':'repeat', 'times':80},
{'command':'dialog', 'text':''},
{'command':'face', 'direction':'left'},
{'command':'repeat', 'times':20},
{'command':'dialog', 'text':'Jasper, could you stop hitting on that girl? She looks busy.'},
{'command':'repeat', 'times':40},
{'command':'face', 'direction':'down'},
{'command':'gesture', 'gesture':2},
{'command':'repeat', 'times':10},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':10},
{'command':'dialog', 'text':''},
{'command':'repeat', 'times':20},
{'command':'dialog', 'text':'On that note, let\'s skip ahead to the mine itself.'},
{'command':'repeat', 'times':30},
{'command':'face', 'direction':'up'},
{'command':'repeat', 'times':30},
{'command':'move', 'x':120, 'y':230, 'absolute':true},
{'command':'dialog', 'text':''},
{'command':'repeat', 'times':30},
{'command':'face', 'direction':'down'},
{'command':'dialog', 'text':'Well, here we are in the mine where it all begins.'},
{'command':'repeat', 'times':60},
{'command':'dialog', 'text':'Late one night, Jasper\'s grandfather is working with the mining team, when a flash of light shoots by them.'},
{'command':'repeat', 'times':100},
{'command':'dialog', 'text':'A blast of energy erupts inside the mine, burning several workers to death. Jasper\'s grandfather barely survives.'},
{'command':'repeat', 'times':100},
{'command':'dialog', 'text':'What caused this? How does Jasper seek answers? It\'s best to not give away too much.'},
{'command':'repeat', 'times':100},
{'command':'dialog', 'text':'Let\'s see one more thing before concluding this teaser.'},
{'command':'repeat', 'times':60},
{'command':'face', 'direction':'left'},
{'command':'move', 'x':120, 'y':88, 'absolute':true},
{'command':'repeat', 'times':20},
{'command':'gesture', 'gesture':3},
{'command':'repeat', 'times':10},
{'command':'dialog', 'text':'I guess Jasper isn\'t ready for this yet. He needs some friends to help.'},
{'command':'repeat', 'times':60},
{'command':'dialog', 'text':'Well, Jasper, I guess we have to save something for Teaser 4.'},
{'command':'repeat', 'times':20},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':40},
{'command':'dialog', 'text':'What should we let the viewers do, then, Jasper?'},
{'command':'repeat', 'times':80},
{'command':'gesture', 'gesture':0},
{'command':'repeat', 'times':3},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':3},
{'command':'gesture', 'gesture':0},
{'command':'repeat', 'times':3},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':3},
{'command':'gesture', 'gesture':0},
{'command':'repeat', 'times':3},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':3},
{'command':'gesture', 'gesture':0},
{'command':'repeat', 'times':3},
{'command':'face', 'direction':'down'},
{'command':'repeat', 'times':3},
{'command':'dialog', 'text':'Sure, that\'s a great idea! Go ahead and test the controls.'},
{'command':'repeat', 'times':80},
{'command':'move', 'x':120, 'y':936, 'absolute':true},
{'command':'dialog', 'text':''},

];

Comments

Caleb Downs - Sep 22, 2010 7:09 PM

what language is it? the json one?... im trying to use whatever language it is in Notepad++...

Matthew Marshall - Sep 24, 2010 5:53 AM

Need some specifics! :O omgooooosh Dx

Daniel Gump - Sep 25, 2010 5:04 AM

The great unveiling of a sample script. :-D

Caleb Downs - Sep 25, 2010 11:38 AM

omg... thx

Caleb Downs - Sep 25, 2010 11:55 AM

how many frames are equal to one second?

Daniel Gump - Oct 4, 2010 5:11 PM

I try to keep it around 20fps, but it falls to 15fps when several objects are on the screen.

Matthew Marshall - Oct 18, 2010 5:37 AM

ahhh ok this helps a lot :D thanks