This document will try to teach you
how to write and use LGS scripts.
LGS is a script language
writting for graphics.
It can be used for all kinds of things
like:
-Advanced skyboxes with animations etc etc.
-Rendering
characters. (with and without special transformations etc)
-Rendering
special effects and attacks.
-Gif-like Animations.
-Advanced
blending modes.
The major point of LGS is that it
allows you to be creative when it comes to graphics.
You dont have
to do the simple standard stuff anymore, do as you like: almost
anything is possible.
An example of an LGS script:
#texture data/graphics/deathball.tga .main :texture_set 0 :glColor4f 1.0,1.0,1.0,0.5 :sprite :invf Rotation :sprite :exit
The basic rules of LGS:
These are the rules that every LGS
script must follow:
Learn these well!
1: There are 3 types of
command's: LABELS, RUNTIME COMMANDS and PRE-LOAD COMMANDS
2:
LABELS always start with a dot! (.main is a label)
3: RUNTIME
COMMANDS always start with a “:” ( :sprite is a runtime
command)
4: PRELOAD COMMANDS always start with a “#” (
#texture is a preload command)
5: Lines that do not have a “.”
or a “#” or a “:” in front of it are
IGNORED!
6: There are only 2 data types: static data and
variables.
7: Variables can store both FLOATS and INTEGERS.
(FLOATS are numbers with a floating point in it: INTEGERS are
without!)
8: FLOATS must ALWAYS have a “.” in it!
(Don't write “1” but “1.0” when u use
floats!)
9: Every calculating command has 2 variants: 1 for
integer, and 1 for float! the one for floats has an “f”
at the end.
10: Every script must at least contain the label
“.main” and the command “:exit”
11: LGS
has many special variables for you that u can use in your
scripts.
12: LGS works a lot like ASM does.
13: You can define
your own variables.
Now lets look at our example again:
Here is the example again: after each command i will explain what it does:
#texture
data/graphics/deathball.tga
This command will load a texture:
in this case “data/graphics/deathball.tga” is
loaded.
.main
This label is important in every LGS
script: it tells the LBZ game where to start.
:texture_set
0
This command selects a texture: in this case the FIRST
texture loaded IN THIS SCRIPT!
:glColor4f 1.0,1.0,1.0,0.5
This
is an OPENGL command ported to LGS: it is used to specify a color
(RGBA)
The color set here is pure white: but since ALPHA blending
is on: it will be blended 50% with the background.
:sprite
This
command uses the CURRENT SETTINGS to draw 1 sprite. (this is blended
with the background.)
:invf Rotation
This command
inverts the parameter: in this case the special variable Rotation is
inverted. (90 will become -90 etc)
:sprite
You already
had this command.....
:exit
This one is pretty important
too: it EXITS LGS and returns to the game.
So that's the example script....
figured out what it actualy does yet?
SIMPLE! it draws the
DEATHBALL attack.
The sprite is loaded with the texture command is
drawn TWICE! but the rotation is inverted the second time.
With
blending on, this makes the ball look a lot more like it's made out
of energy.
From here on i will list all the possible command's and the special variables!
Special variables: These are sent into the script by the game.
Size : This contains the
current size of the sprite that must be drawn.
Texture :
This contains the current texture set by lbz.
Rotation :
This contains the current angle LBZ is going to draw at.
Facing
: This contains whether the engine is drawing left- or right-faced!
Offset_x : This contains the X position lbz is going to
draw at.
Offset_y : This contains the Y position lbz is
going to draw at. (a Z version should be added soon)
Player_health
: Contains the health of the player we are drawwing for.
Player_pl
: Powerlevel of the player.
Player_energy : Energy the
player has left.
Player_isssj : 1 when the player is ssj: 0
when he is not.
Player_ischatting : normaly this is 0: but
it's 1 when the player is chatting (multiplayer)
Player_drwsize
: The size of the player.
Player_isTK : 1 when the
player is using the TK move: 0 when he is not.
TimestampNormal
: This contains a special float u can use to make animations run with
the same speed all the time.
TimestampNoSlow : Same as
above: but the Normal version slows down when the game goes in
slowmotion: this one stays the same!
These are not all of the variables: but the list will be updated later. (The others are not yet important!)
The PRELOAD commands: These commands are executed only once when the script is loaded.
texture: Takes 1 argument: used
to load a TGA file into LGS.
define: Takes 1 argument:
defines a variable. (example “#define MYOWNVAR” makes a
new variable: MYOWNVAR)
model: Takes 1 argument: used to
load a MODEL into LGS.
include: Takes 1 argument: the
argument is included in the script: “#include
data/scripts/blah.lgs”.
The RUNTIME commands: These command's can be used in your
scripts.
Something about the order of the arguments: the go from
target value to source value....
This means that “:mov
BLAH1,BLAH2” will move BLAH2 to BLAH1!!! you could compare this
to BLAH1 = BLAH2
The list is made up of three things:
[command]/[float version(where available)] : [number of arguments] :
[Description]
Part 1: Basic calculation.
mov/ movf : 2 : “:mov b,a” moves a to b
inc/incf :
1 : “:inc a” increases a by 1.
dec/decf : 1 : “:dec
a” decreases a by 1.
mul/mulf : 2 : “:mul a,b”
multiply's a by b.
div/divf : 2 : “:div a,b” divides a
by b.
add/addf : 2 : “:add a,b” adds b to a.
sub/subf
: 2 : “:sub a,b” substracts b from a.
or : 2 : “:or
a,b” ORS a by b
and : 2 : “:and a,b” and a by
b
inv/infv : 1 : “:inv a” inverts a.
Part 2: Program control.
jmp : 1 : “:jmp .blah” jumpes to the .blah label.
ret
: 0 : “:ret” returns from a previous jump.
exit : 0 :
“:exit” exits LGS and returns to the game.
rep : 2 :
“:rep .blah,varB” jumps to .blah and decreases varB. when
“ret” is called: it will return to this command.
push:
1 : put sumthing on stack.
pop : 1 : get something out stack.
Part 3: comparisons.
These commands will test 2 values
and if the outcome is true: the next command is executed.
When the
outcome is NOT true: the next command will be skipped.
cmp : 2 : “:cmp a,b” The next command will be executed
when a is equal to b
smaller/smallerf : 2 : “:smaller a,b”
The next command will be executed when a is smaller then
b
bigger/biggerf: 2 :”:bigger a,b” The next command
will be executed when a is bigger then b
Part 4: LBZ graphic command's.
These
are command's that use the special variables to draw stuff.
texture_set : 1 : “:texture_set
0” Sets the texture to the first texture loaded in the
script.
sprite : 0 : “:sprite” Draws a sprite with the
current settings in the special variables.
setmodel: 1 :
“:setmodel 0” Sets the model to the first model loaded in
the script.
updatemodel: 0 : “:updatemodel” Generates
all the data needed for drawing the model.
drawmodel: 0 :
“:drawmodel” Draws the model: updatemodel must be called
at least once...
prn: 1 :”:prn 1” Prints data to
console: usefull for debugging.
Part 5: OpenGL commands:
It
is possible to use a few of the native opengl commands in lbz: they
work just like the normal versions.
(Search for a good manual on
opengl on the web to see what they do)
I will list the opengl
functions that are possible in lbz: you need to figure the rest out
yourself.
glColor4f,glVertex2f,glTexCoord2f,glTranslatef,glLoadIdentity,glRotatef,glBindTexture,glEnable,glDisable,glBlendFunc,glVertex3f