NinHost

Script Language

Complete Command List - 13/01/2005


Basic Syntax

How to work with the language

Always include spaces after command names.

If a command specifies "Command X Y Number" you can either use "Command X Y Number" or "Command X,Y,Number". Commas and Spaces are interchangable

If you wish to use more than one command on a single line, use a colon : to seperate the commands.

When using If's, try not to use more than one then on a single line.
ie

If This = That then Dothis:If This < TheOther then Dothat

won't work
but

If This = That
  Dothis
  If This < TheOther then Dothat
endif

will work fine..

This will be tweaked later on, to make it work right, but in the meantime try not to do it, ok ;)



Always Include

Game Definition Commands

Levels Number
Number of levels defined below. Each level must have it's own Script, and be seperated by the Level command.

Game Text
Defines the name of the game.

Rule Text
The instructions that flash up onto the screen when the game begins.

Author Text
Your name goes here.

Visit Text
An extra line of text, May be used for anything, but generally used for holding websites to visit..

Beat Number
During certain modes, the player is asked to complete the same minigame over and over, getting faster and faster.. This number defines the number of wins that the player should attempt to reach.

Time Number
How many Frames the game should last.


Game Events

Specific things that should happen in a game.

Won True/False
Tells the program that the player has (or hasn't) Won the game.

Lost True/False
Tells the program that the player has (or hasn't) Lost the game.

(For Won and Lost you can alternatively use Win and Lose)

How these should be used.
Imagine a game of Space Invaders. If the player defeats the enemy, they've Won. If they die, they've Lost. If the time runs out, however, have they necessarily won, or lost. This will be defined in how you use these two commands.
If Lost is true, they lose a life.
If Won is true, they don't.
I haven't yet worked out what would happen if both are set, or if neither are. I'll probably be creating commands for those later.


Backgrounds

Commands for various Background styles

BackSolid R G B
Sets the background to a solid specified color.
Note that Back R G B also works fine.

More Background styles will appear soon.


Drawing

For basic Non-Sprite drawing.

Color R G B
Defines the color to be used for drawing.

Rect X Y Width Height
Creates a filled rectangle from X,Y with specified Width and Height

Oval X Y Width Height
Creates a filled oval from X,Y to Width,Height. (ie, not from center.. from corner to corner!)

Line X1 Y1 X2 Y2
Draws a line from point 1 to point 2.

Text X Y Text
Prints the specified text in a basic font. More text/string stuff will be coming later.


Loading Objects

Sprite loading

Sprite ObjectName ImageFilename
Loads in ImageFilename.bmp as a single image sprite. If ImageFilename.aml exists, it will load in the image as an animation, as specified in the .aml file.

And ObjectName
Copies the last loaded Sprite (and all it's current values) to a new object, rather than loading the image again.


Moving Objects

Shifting sprites around onscreen.

Position ObjectName X Y [Rotation] [Opacity] [ScaleX] [ScaleY] [Flip]
Sets up the sprite in it's start position. (for more info, see the rest of the commands.)
[?]s are un-necessary, but if you want to include [Opacity], you must include [Rotation] (and so on)

Move ObjectName RelativeX RelativeY
Moves the sprite on the screen, relative to it's current position. If you'd rather move it to a specific screen co-ordinate, place an A (for Absolute) at the start of the co-ordinate
Move Object 100 50 __ Shifts Object 100 pixels right, and 50 pixels down
Move Object A100 A50 __ Places object at screen coordinates 100,50

Rotate ObjectName RelativeAngle
Rotates the sprite clockwise. If you'd rather move it to a specific angle, use the A for Absolute values.

Flip ObjectName 1/0
Setting this to 1 will flip the sprite, left to right. This is useful if you draw all your sprites in one direction, and would like them to face the other direction without having to rotate them 180 degrees.

Scale ObjectName Width% Height%
Scales the sprite, Wide and High, where 100 is normal, 200 is double and 50 is half sized.

Opaque ObjectName Opacity
Sets how transparent a sprite is, where 0 is invisible, 125 is semi-transparent, and 255 is solid.


Animation

Animating sprites, based on .aml files.

Anim ObjectName Animation
If you've setup a .aml setting file for the sprite, you can use this to switch between the various Animations within the file.
Animate ObjectName
This flicks the animation of a sprite, one frame. If you don't use this, your animations won't animate.


Sound

All about sound and music.

Sample SampleName SampleFile DefaultPitch
Loads the file from the directory System/ (you must specify it's path from there) into the SampleName slot. The default pitch is only useful if you're going to be making music with the samples.
ie Sample Plink, Instruments/Plink.wav, 16000

Play SampleName Tune FramesPerNote
Plays Samplename to the tune provided. If you leave off Tune, and FramesPerNote, the engine will simply play the sound, as a sound effect.
For examples of how to use tunes, see the Making Music section

PlayStart SampleName Tune FramesPerNote
Works exactly the same way as Play, except it plays the sound/tune as soon as the game starts. You can use this for background tunes/sounds/etc.


Grids

The multipurpose 2 dimensional array.

LoadGrid
value,value,.....,value,value
value,value,.....,value,value
...
value,value,.....,value,value
value,value,.....,value,value
EndGrid

Loads the data between the lines into the Grid, where the top left value is 1,1 on the grid.

SetGrid Xpos Ypos Value
Sets a specific grid point to the value given.

DrawGrid ObjectName X Y
Draws the complete grid, using sprites in ObjectName, (with 1 being the first frame, and 0 being "draw nothing") starting at the given X + Y co-ordinates.
Using this function, you can easily create tile-based maps for your games.


Variables/Maths

Using Objects to store values

Instead of using normal Variables, and coping with names, and things, I decided to speed up the code by allowing each Object to hold 50 extra bits of information. These are held in Variable slots, numbered 1 thru 50.
The following commands allow you to access these values.

Preset ObjectName Variable# Value
Sets a object variable to a value, when loading the game. Useful for setting up speeds, points, and other settings.

Set ObjectName Variable# Value
Sets a object variable to a value, during the game.

Add ObjectName Variable# Value
Add value to an object variable.

Sub ObjectName Variable# Value
Subtracts value from an object variable.

Mult ObjectName Variable# Value
Multiplies Variable by Value

Div ObjectName Variable# Value
Divides Variable by Value


Events

Things to put in If's

If Value1 < Value2
Does the following, when Value1 is less than Value2.

If Value1 = Value2
Does the following, when Value1 is equal to Value2.

If Value1 > Value2
Does the following, when Value1 is more than Value2.

If ObjectName1 Collide ObjectName2
Does the following if the 2 sprites have collided onscreen. (Note, I kept typing collides instead of collide, so now Collides also works!)

If Chance A B
Does the following at random intervals with a chance of A in B of occuring.. ie if you want the event to happen randomly once in every 100 frames you would use "If Chance 1 100 then whatever"

If KeyDown KeyName/Value
Does the following if the key named is currently pressed. Keys are..
1 - Up
2 - Down
3 - Left
4 - Right
6 - A
5 - B
(You can use either their name "Up" or their value "1")

If KeyTap KeyName/Value
Does the following if the key named has been tapped. This counts "Pushed" only, not "Held Down", so you only get one event for every keypress.

If Won True/False
Does the following if Won has been set to True or False, as specified.

If Lost True/False
Does the following if Lost has been set to True or False, as specified.

(For Won and Lost you can alternatively use Win and Lose)


Extended Values

More Values

In places where values can be used (ie X Y Width Height Value Angle, etc) you can usually use one of the following.

Plain Numbers

#
For a plain number, just type in the plain number.

Absolute Numbers

A#
For Movement, and Rotation, you might want to specify exact screen locations, or angles. To do this, place an A (for Absolute) in front of the number..
(ie Move Object A100 A100 to move to 100,100 on the screen)

Random Numbers

RAND[First,Last]
This picks a random number between (and including) the first and last given values, and uses that, rather than a preset value.
First and Last may also be Extended Values (except for More Rand's.. That causes weird issues!)
(ie Move Object Rand[0,800] Rand[0,600] to move Object to a random place on the screen.)

Trigonometry

Sin[Angle,Multiplier]
Cos[Angle,Multiplier]
Tan[Angle,Multiplier]

The Trig functions are useful for angles, speeds, and more.
You use these as you normally would, except you include the multiplier inside the brackets.. Sin[Angle,1] would return a sin value between -1 and 1, Cos[Angle,-50] would return an inverted cos value, between -50 and 50
(ie Move Object Sin[45,4] Cos[45,4] would move the object at a 45 degree angle, with a speed of 4.. um.. pixels (except on a gradient, so it won't be exact pixels!!) !)

Grid Values

Grid[XPos,YPos]
Returns the value of a specified point on the grid.

Object Variables

@ObjectName-Variable
You can use this to retrieve values from objects. Each object can have 50 such variables set (numbered 0001 to 0050), and you can place any numbers you wish into them. Maybe you could set an objects speed. A players score.. Or any number of other things.
There are also several preset Variables, that you can also access.
PosX and PosY will give the values of the objects X and Y locations.
Rota will give the objects current angle.
(ie, if you first Set Object 0001 4 and Set Object 0002 4, using Move Object @Object-0001 @Object-0002 will move Object at a constant speed of 4 pixels right and 4 pixels down..)
(ie 2, using Move Object2 A@Object1-PosX A@Object1-PosY will move Object2 to Object1's location.)