2007.12.23, 03:43 PM
This is a basic scripting tutorial for anyone who wants to learn.
Basics
This section teaches what the basic commands do.
Okay, so what does that mean?
It means this
If question then do something.
So, an example script would be:
Note that == checks for equality, but = sets the variable.
Strings, Integers, And Booleans
This section teaches what strings integers and booleans are
Else and Simplifications
This section is somewhat advanced compared to the first section, read this after you understand the basics.
This says "If a is true make b 2000, otherwise set b to 3000".
Functions and Calling them
This section is about functions and calling them.
API
api stands for application programming interface, it's what does anything to the game
Api are things like
they do stuff to the game, anything, from moving models (obj.motionVector.go()
to putting text on the screen (iface.text.set(Text Name,'text here')).
API can be found in the documentation, click on the scripting section then look at all the sections (obj, modle, iface). Api works like this:
So, if you clicked the obj section
then scrolled down to motionvector
(capitalazation counts)
then found turnToObject
then checked the parameters (not all API have parameters)
(Object IDs can be found using various APIs)
When naming a function, you put the section of the API you need to load in the name
.
Other Stuff
Theres alot more you can learn
Dim3 scripts always start at the function called "event".
There are other commands like if, (while, for) but if you feel you want to become more advanced google them (I'm a very good programmer but I rarely use those commands, you probably won't need them in dim3 unless your making very complicated scripts).
Appling this knowledge
I reccomend starting out by modifieng the demo scripts, then when you feel you get it starting your own scripts
.
And
Theres also an or,
JAVA AND JAVASCRIPT ARE 2 DIFFERENT THINGS, dim3 using javascript.
For more info try the w3 schools site: http://www.w3schools.com/js/default.asp
Feel free to post questions, but if you have specific questions start a new thread
.
Basics
This section teaches what the basic commands do.
Code:
if (question here) {
//do something
}It means this
If question then do something.
So, an example script would be:
Code:
//This is a comment, it doesn't effect the script
var a=1; //this makes a new variable called a and sets it to 1
var b=1; //this makes a new variable called b and sets it to 1
if (a==b) { //if a=b then
a=3; //this makes a=3
} //closing bracket, end of what you do if a=bNote that == checks for equality, but = sets the variable.
Strings, Integers, And Booleans
This section teaches what strings integers and booleans are
Code:
var a; //this could be a string integer or boolean
var b=true; //this is a boolean, booleans are either true or false
var c=1; //this is an integer, integers are numbers
var d='You are currently on level one'; //this is a string, strings are textElse and Simplifications
This section is somewhat advanced compared to the first section, read this after you understand the basics.
Code:
if (a==true) {
b=2000;
} else {
b=3000;
}Code:
if (count==true) {
otherVariable=2000;
}
//Well, this code can be simplified lots.
if (count) { //saying if(variable) { asks if that variable is true
otherVariable=2000;
}
//It can still be simplified, you can use
if (count) otherVariable=2000; //This does that in one line, use this when theres only only one command after the if and there is no elseCode:
//Not
if (variable!=1) do something; //says "if the variable is NOT 1 then do something"
//You can also use
if (!variable) do something; //this says if the variable is false then do somethingCode:
x=x+y//This can be simplified
x+=y //This also applys to - * / and %
//You can also do this
x=x++ //this sets y to x+1
//this applys to + and -Functions and Calling them
This section is about functions and calling them.
Code:
function characterConstruct(obj)
{
//code goes inside functions, you make variables out of them but all other code should be inside functions
//functions are like sections, you can call them whenever you want.
otherFunction(obj); //this tells the script to go to the function called otherFunction.
//The "obj" written in the function name is the api to load, api will be discussed in the next section
}API
api stands for application programming interface, it's what does anything to the game
Api are things like
Code:
obj.motionVector.walkToPlayer
to putting text on the screen (iface.text.set(Text Name,'text here')).API can be found in the documentation, click on the scripting section then look at all the sections (obj, modle, iface). Api works like this:
Code:
section.subSection.command(parameters);Code:
obj.Code:
obj.motionVectorthen found turnToObject
Code:
obj.motionVector.turnToObjectCode:
obj.motionVector.turnToObject(You would put an object ID here);When naming a function, you put the section of the API you need to load in the name
.Other Stuff
Theres alot more you can learn
Dim3 scripts always start at the function called "event".
Code:
//This is an example of a switch
switch (variableName) { //this starts a switch with the name "variableName"
case 1: //if variableName is 1
//do something
return;
case 2: //if variableName is 2
//do something
return;
case 3: //if variableName is 3
//do something
return;
}There are other commands like if, (while, for) but if you feel you want to become more advanced google them (I'm a very good programmer but I rarely use those commands, you probably won't need them in dim3 unless your making very complicated scripts).
Appling this knowledge
I reccomend starting out by modifieng the demo scripts, then when you feel you get it starting your own scripts
.And
Code:
if (a && b) obj.motionVector.walkToPlayer(); //says if a is true AND b is true, walk to the playerCode:
if (a || b) do something; //This says "If a is true or b is true then do something"JAVA AND JAVASCRIPT ARE 2 DIFFERENT THINGS, dim3 using javascript.
For more info try the w3 schools site: http://www.w3schools.com/js/default.asp
Feel free to post questions, but if you have specific questions start a new thread
.