So this is basically a farewell thread for me, I will no longer be active in the new year, after we have posted the stuff for the Rotary Tool Challenge I will be gone
I do not speak for Rotary Gaming in this or for Grimbarian
I have become disillusioned with the forum, it is not what it was and the fun has gone out of it for me
I have had some good times here though and there are some good people
Anyway as a good bye I give you the basics of script so you won't have to do the "please write everything for me because I suck at scripting" routine. Take it or leave it, add to it, have it deleted by a mod, the choice is yours, but if you read it and do the stuff you'll be on your way, if you can't pick up anything from what it says here then, to be blunt, give up
(I wrote this quick so hopefully no mistakes, if there are let me know and I'll put it straight)
THESE ARE THE BASICS, VERY BASICS, YOU MUST KNOW THESE TO SCRIPT...IT IS NOT EXHAUSTIVE JUST A START FOR THESE OF YOU WHO SAY "I CAN'T SCRIPT"
YOU CAN SCRIPT WITH MINIMAL LEARNING, THESE ARE THE BASICS, LEARN THEM, YOU CAN USE THEM TO DO SIMPLE STUFF, YOU CAN COMBINE THEM TO DO COMPLEX STUFF, WITHOUT THEM YOU CAN DO NOTHING
THIS IS JUST TO GET YOU STARTED, ITS NOT MEANT TO BE ADVANCED, I'M NOT THAT GOOD
IT DOES NOT CONSIDER VECTORS OR QUATERNIONS OR ANY COMPLEX COMMANDS, JUST SOME SIMPLE LOGIC WORK
OVERVIEW
A SCRIPT DOES NOT INTERPRET MISTAKES, IT DOES WHAT YOU TELL IT TO, EXACTLY, NO QUESTIONS ASKED. IF IT DOESN'T DO WHAT YOU WANTED YOU DID IT WRONG
IT IS STRUCTURED AND IF YOU DO NOT USE THE CORRECT STRUCTURE IT WILL NOT WORK, IT WILL DO NOTHING IF THERE IS AN ERROR, THE check script button WILL TELL YOU IF THEREE IS AN ERROR AND WHAT IT IS
CAPITALISATION COUNTS ie Its Case Sensitive, iObjectStart is not the same as iobjectstart or IOBJECTSTART
EACH COMMAND MUST END WITH A SEMICOLON ; (THIS DOES NOT APPLY TO THE CONDITIONAL PART OF AN IF STATEMENT OR ELSE
THE SCRIPT STARTS WITH void { and ends with } (THE EDITOR PUTS THESE IN FOR YOU, IF YOU DELETE THEM IT WILL NOT WORK)
VARIABLES MUST BE DECLARED BEFORE THEY ARE USED, USUALLY RIGHT AT THE START OF THE SCRIPT
// MAKES THE SCRIPT IGNORE EVERYTHING AFTER THE // USEFUL FOR ADDING COMMENTS TO A SCRIPT SO YOU DON'T FORGET WHAT BITS DO - USE THIS!!
THE SCRIPT HELP BUTTON! - DO NOT UNDERESTIMATE THIS, CLICK THE Script Object Reference LINK FOR ALL THE OBJECT COMMANDS AND THEIR EXPLAINATIONS - READ IT, YOU NEED THESE
PLAN WHAT YOU WANT TO DO, DON'T JUMP INTO SCRIPT, WRITE DOWN IN ENGLISH WHAT YOU WANT TO HAPPEN AND GO FROM THERE
THE SCRIPT WINDOW EXPLAINED
THERE ARE FOUR MAIN PARTS TO THE WINDOW
THE MAIN RIGHT HAND WINDOW - THIS IS WHERE YOUR SCRIPT GOES
THE TOP LEFT WINDOW - THIS TELLS YOU WHAT YOUR OBJECTS ARE CALLED IN THE SCRIPT (THE HANDLES) - OBJ_xxx where xxx is a number - IF YOU WANT TO REFER TO AN OBJECT FROM THE EDITOR USE THIS
THE MIDDLE LEFT WINDOW - THESE ARE THE INPUTS FROM THE WORLD TO YOUR SCRIPT - IN_xxx where xxx is a number - THESE ARE USUALLY FLOATS AND THE HELP FILE FOR THE OBJECT WILL TELL YOU WHAT THEY CONTAIN
THE BOTTOM LEFT WINDOW - THESE ARE THE PARTS OF OBJECTS YOU CAN MANIPULATE, YOU CAN WRITE TO THESE FROM THE SCRIPT TO MAKE YOUR EDITOR OBJECTS DO STUFF, THE HELP FILE FOR THE OBJECT WILL TELL YOU WHAT THEY DO
CHECK SCRIPT BUTTON - USE IT, IF IT DOES NOTHING YOU'RE GOOD TO GO (EVEN IF IT DOESN'T DO WHAT YOU WANTED), IF THERE'S AN ERROR IT TELLS YOU WHERE AND WILL NOT RUN AT ALL
VARIABLES - DATA OBJECTS WHICH CAN CHANGE VALUE
INT - INTEGER, THIS IS A WHOLE NUMBER WHICH CAN BE WRITTEN TO, MANIPULATED AND READ eg 13
FLOAT - FLOATING POINT NUMBER, THIS IS A WHOLE NUMBER OR FRACTION (DECIMAL) WHICH CAN BE WRITTEN TO, MANIPULATED AND READ eg 13.5434
BOOL - BOOLEAN, THIS IS A STATE WHICH CAN BE TRUE OR FALSE, IT CAN BE WRITTEN TO AND READ eg true
STRING - WORDS AND STUFF, eg "stuff"
LOGIC COMMANDS
IF - THE BUILDING BLOCK OF DECISIONS, EXACTLY AS IT SOUNDS, IF A CONDITION IS MET THEN DO SOMETHING
ELSE - WHAT HAPPENS IF THE IF CONDITION IS NOT MET (NOT NEEDED FOR AN IF STATEMENT BUT VERY USEFUL)
EQUAL TO - == THIS MEANS IS EQUAL TO, x == y
MORE THAN - > FOR EXAMPLE, IF X IS MORE THAN X IS, if (x > y)
LESS THAN - < FOR EXAMPLE, IF X IS LESS THAN X IS, if (x < y)
AND - && EXACTLY AS IT SOUNDS, SPECIFIES THAT TWO (OR MORE) THINGS MUST BE BOTH (ALL) MET FOR, TYPICALLY, AN IF STATEMENT, if (x==y && z==v)
OR - || EXACTLY AS IT SOUNDS, SPECIFIES THAT AT LEAST ONE THINGS OUT OF A SELECTION MUST BE MET FOR, TYPICALLY, AN IF STATEMENT, if (x==y || z==v)
ADDITION - USE + TO ADD ONE VARIABLE TO ANOTHER, x + y (OR A NUMBER TO A VARIABLE), ALSO CAN USE variable += x TO INCREASE A VARIABLE BY THE AMOUNT X (y += x IS THE SAME AS y = y + x)
SUBTRACTION - USE + TO SUBTRACT SOMETHING FROM ANOTHER, x - y, ALSO CAN USE variable -= x TO deCREASE A VARIABLE BY THE AMOUNT X (y -= x IS THE SAME AS y = y - x)
MULTIPLICATION - USE * TO MULTIPLY TWO VARIABLES TOGETHER, x * y
DIVISION - USE / TO DIVIDE ONE VARIABLE BY ANOTHER, x / y
SIMPLE APPLICATIONS
COUNTERS - COUNTERS ARE VERY USEFUL, USE A VARIABLE, eg x, AND INCREMENT IT, x += 1, THEN CHECK TO SEE IF IT REACHES THE NUMBER YOU WANT, if (x == 10)
eg.
int x; // set the variable x as an integer
x += 1; // add one to x
if (x == 10) // if x equals 10 do this
{ your commands for when your counter reaches 10 here } // this is what it does at 10 - curly brackets are not needed if there is only one command
else // if x is not equal to 10 then do this
{your commands for when counter has not reached 10 here } // this is what it does when not at 10 - curly brackets are not needed if there is only one command
EXAMPLE PROBLEM
when a counter reaches 10 seconds show the sprite and play the sound
SOLVE THE PROBLEM IN ENGLISH
make a counter
increase the counter
if the counter is at ten seconds then show the object and start the sound
otherwise don't do anything
THEN DECIDE WHAT YOU NEED
a variable for the counter, we choose counter1
an incremental value for the counter, 1 seems easiest
an end value for the counter, there are 60 cycles per second (approx), so 600 cycles is 10 seconds
the object handles for the sprite and the sound, ensure objects are linked to the script, then check the top left hand window (example OBJ_22 & OBJ_44)
THEN TRANSLATE TO SCRIPT
int counter1;
counter += 1;
if (counter == 600)
{ iObjectShow(OBJ_22);
iObjectStart(OBJ_44);
}
NOW TRY IT YOURSELF WITH A MORE COMPLEX PROBLEM
IN THE EDITOR CREATE A TERRAIN WITH A CAR WHICH IS DRIVABLE AND A SPRITE - (IF YOU CAN'T DO THAT THEN YOU SHOULDN'T BE HERE!)
NOW YOUR SCRIPT CHALLENGE....
WHEN THE 'GAME' HAS BEEN PLAYED FOR AT LEAST 15 SECONDS AND THE CAR SPEED IS OVER 10 METRES PER SECOND THEN SHOW THE SPRITE, OTHERWISE THE SPRITE SHOULD BE HIDDEN
FOLLOW THE LOGIC, STRUCTURE YOUR IDEAS AND THEN TRANSLATE TO SCRIPT, THERE IS NOT ONE ANSWER TO THIS
YOU WILL NEED TO USE AN IN_xxx VALUE, A VARIABLE AND SOME HELPFUL OPERATORS ARE .... IF > ELSE += &&
IF YOU SUCCEED YOU CAN BASICALLY SCRIPT...CONGRATULATIONS, NOW MAKE A GAME
ONE POSSIBLE EXAMPLE ANSWER - place this code inbetween the curly brackets in a script object - where it says your script here
int counter;
if (counter > 900 && IN_0 > 10) //WHERE IN_0 IS THE SPEED OF THE CAR, TAKEN FROM THE LIST IN THE MIDDLE LEFT WINDOW
iObjectShow(OBJ_22); //WHERE OBJ_22 IS THE SPRITE HANDLE, TAKEN FROM THE LIST IN THE TOP LEFT WINDOW
else
{
iObjectHide(OBJ_22);
counter += 1; // PLACING THIS HERE JUST STOPS THE COUNTER GOING UP AFTER IT REACHES 901, IT COULD BE PLACED OUTSIDE THE IF/ELSE STATEMENTS
}
I do not speak for Rotary Gaming in this or for Grimbarian
I have become disillusioned with the forum, it is not what it was and the fun has gone out of it for me
I have had some good times here though and there are some good people
Anyway as a good bye I give you the basics of script so you won't have to do the "please write everything for me because I suck at scripting" routine. Take it or leave it, add to it, have it deleted by a mod, the choice is yours, but if you read it and do the stuff you'll be on your way, if you can't pick up anything from what it says here then, to be blunt, give up
(I wrote this quick so hopefully no mistakes, if there are let me know and I'll put it straight)
THESE ARE THE BASICS, VERY BASICS, YOU MUST KNOW THESE TO SCRIPT...IT IS NOT EXHAUSTIVE JUST A START FOR THESE OF YOU WHO SAY "I CAN'T SCRIPT"
YOU CAN SCRIPT WITH MINIMAL LEARNING, THESE ARE THE BASICS, LEARN THEM, YOU CAN USE THEM TO DO SIMPLE STUFF, YOU CAN COMBINE THEM TO DO COMPLEX STUFF, WITHOUT THEM YOU CAN DO NOTHING
THIS IS JUST TO GET YOU STARTED, ITS NOT MEANT TO BE ADVANCED, I'M NOT THAT GOOD
IT DOES NOT CONSIDER VECTORS OR QUATERNIONS OR ANY COMPLEX COMMANDS, JUST SOME SIMPLE LOGIC WORK
OVERVIEW
A SCRIPT DOES NOT INTERPRET MISTAKES, IT DOES WHAT YOU TELL IT TO, EXACTLY, NO QUESTIONS ASKED. IF IT DOESN'T DO WHAT YOU WANTED YOU DID IT WRONG
IT IS STRUCTURED AND IF YOU DO NOT USE THE CORRECT STRUCTURE IT WILL NOT WORK, IT WILL DO NOTHING IF THERE IS AN ERROR, THE check script button WILL TELL YOU IF THEREE IS AN ERROR AND WHAT IT IS
CAPITALISATION COUNTS ie Its Case Sensitive, iObjectStart is not the same as iobjectstart or IOBJECTSTART
EACH COMMAND MUST END WITH A SEMICOLON ; (THIS DOES NOT APPLY TO THE CONDITIONAL PART OF AN IF STATEMENT OR ELSE
THE SCRIPT STARTS WITH void { and ends with } (THE EDITOR PUTS THESE IN FOR YOU, IF YOU DELETE THEM IT WILL NOT WORK)
VARIABLES MUST BE DECLARED BEFORE THEY ARE USED, USUALLY RIGHT AT THE START OF THE SCRIPT
// MAKES THE SCRIPT IGNORE EVERYTHING AFTER THE // USEFUL FOR ADDING COMMENTS TO A SCRIPT SO YOU DON'T FORGET WHAT BITS DO - USE THIS!!
THE SCRIPT HELP BUTTON! - DO NOT UNDERESTIMATE THIS, CLICK THE Script Object Reference LINK FOR ALL THE OBJECT COMMANDS AND THEIR EXPLAINATIONS - READ IT, YOU NEED THESE
PLAN WHAT YOU WANT TO DO, DON'T JUMP INTO SCRIPT, WRITE DOWN IN ENGLISH WHAT YOU WANT TO HAPPEN AND GO FROM THERE
THE SCRIPT WINDOW EXPLAINED
THERE ARE FOUR MAIN PARTS TO THE WINDOW
THE MAIN RIGHT HAND WINDOW - THIS IS WHERE YOUR SCRIPT GOES
THE TOP LEFT WINDOW - THIS TELLS YOU WHAT YOUR OBJECTS ARE CALLED IN THE SCRIPT (THE HANDLES) - OBJ_xxx where xxx is a number - IF YOU WANT TO REFER TO AN OBJECT FROM THE EDITOR USE THIS
THE MIDDLE LEFT WINDOW - THESE ARE THE INPUTS FROM THE WORLD TO YOUR SCRIPT - IN_xxx where xxx is a number - THESE ARE USUALLY FLOATS AND THE HELP FILE FOR THE OBJECT WILL TELL YOU WHAT THEY CONTAIN
THE BOTTOM LEFT WINDOW - THESE ARE THE PARTS OF OBJECTS YOU CAN MANIPULATE, YOU CAN WRITE TO THESE FROM THE SCRIPT TO MAKE YOUR EDITOR OBJECTS DO STUFF, THE HELP FILE FOR THE OBJECT WILL TELL YOU WHAT THEY DO
CHECK SCRIPT BUTTON - USE IT, IF IT DOES NOTHING YOU'RE GOOD TO GO (EVEN IF IT DOESN'T DO WHAT YOU WANTED), IF THERE'S AN ERROR IT TELLS YOU WHERE AND WILL NOT RUN AT ALL
VARIABLES - DATA OBJECTS WHICH CAN CHANGE VALUE
INT - INTEGER, THIS IS A WHOLE NUMBER WHICH CAN BE WRITTEN TO, MANIPULATED AND READ eg 13
FLOAT - FLOATING POINT NUMBER, THIS IS A WHOLE NUMBER OR FRACTION (DECIMAL) WHICH CAN BE WRITTEN TO, MANIPULATED AND READ eg 13.5434
BOOL - BOOLEAN, THIS IS A STATE WHICH CAN BE TRUE OR FALSE, IT CAN BE WRITTEN TO AND READ eg true
STRING - WORDS AND STUFF, eg "stuff"
LOGIC COMMANDS
IF - THE BUILDING BLOCK OF DECISIONS, EXACTLY AS IT SOUNDS, IF A CONDITION IS MET THEN DO SOMETHING
ELSE - WHAT HAPPENS IF THE IF CONDITION IS NOT MET (NOT NEEDED FOR AN IF STATEMENT BUT VERY USEFUL)
EQUAL TO - == THIS MEANS IS EQUAL TO, x == y
MORE THAN - > FOR EXAMPLE, IF X IS MORE THAN X IS, if (x > y)
LESS THAN - < FOR EXAMPLE, IF X IS LESS THAN X IS, if (x < y)
AND - && EXACTLY AS IT SOUNDS, SPECIFIES THAT TWO (OR MORE) THINGS MUST BE BOTH (ALL) MET FOR, TYPICALLY, AN IF STATEMENT, if (x==y && z==v)
OR - || EXACTLY AS IT SOUNDS, SPECIFIES THAT AT LEAST ONE THINGS OUT OF A SELECTION MUST BE MET FOR, TYPICALLY, AN IF STATEMENT, if (x==y || z==v)
ADDITION - USE + TO ADD ONE VARIABLE TO ANOTHER, x + y (OR A NUMBER TO A VARIABLE), ALSO CAN USE variable += x TO INCREASE A VARIABLE BY THE AMOUNT X (y += x IS THE SAME AS y = y + x)
SUBTRACTION - USE + TO SUBTRACT SOMETHING FROM ANOTHER, x - y, ALSO CAN USE variable -= x TO deCREASE A VARIABLE BY THE AMOUNT X (y -= x IS THE SAME AS y = y - x)
MULTIPLICATION - USE * TO MULTIPLY TWO VARIABLES TOGETHER, x * y
DIVISION - USE / TO DIVIDE ONE VARIABLE BY ANOTHER, x / y
SIMPLE APPLICATIONS
COUNTERS - COUNTERS ARE VERY USEFUL, USE A VARIABLE, eg x, AND INCREMENT IT, x += 1, THEN CHECK TO SEE IF IT REACHES THE NUMBER YOU WANT, if (x == 10)
eg.
int x; // set the variable x as an integer
x += 1; // add one to x
if (x == 10) // if x equals 10 do this
{ your commands for when your counter reaches 10 here } // this is what it does at 10 - curly brackets are not needed if there is only one command
else // if x is not equal to 10 then do this
{your commands for when counter has not reached 10 here } // this is what it does when not at 10 - curly brackets are not needed if there is only one command
EXAMPLE PROBLEM
when a counter reaches 10 seconds show the sprite and play the sound
SOLVE THE PROBLEM IN ENGLISH
make a counter
increase the counter
if the counter is at ten seconds then show the object and start the sound
otherwise don't do anything
THEN DECIDE WHAT YOU NEED
a variable for the counter, we choose counter1
an incremental value for the counter, 1 seems easiest
an end value for the counter, there are 60 cycles per second (approx), so 600 cycles is 10 seconds
the object handles for the sprite and the sound, ensure objects are linked to the script, then check the top left hand window (example OBJ_22 & OBJ_44)
THEN TRANSLATE TO SCRIPT
int counter1;
counter += 1;
if (counter == 600)
{ iObjectShow(OBJ_22);
iObjectStart(OBJ_44);
}
NOW TRY IT YOURSELF WITH A MORE COMPLEX PROBLEM
IN THE EDITOR CREATE A TERRAIN WITH A CAR WHICH IS DRIVABLE AND A SPRITE - (IF YOU CAN'T DO THAT THEN YOU SHOULDN'T BE HERE!)
NOW YOUR SCRIPT CHALLENGE....
WHEN THE 'GAME' HAS BEEN PLAYED FOR AT LEAST 15 SECONDS AND THE CAR SPEED IS OVER 10 METRES PER SECOND THEN SHOW THE SPRITE, OTHERWISE THE SPRITE SHOULD BE HIDDEN
FOLLOW THE LOGIC, STRUCTURE YOUR IDEAS AND THEN TRANSLATE TO SCRIPT, THERE IS NOT ONE ANSWER TO THIS
YOU WILL NEED TO USE AN IN_xxx VALUE, A VARIABLE AND SOME HELPFUL OPERATORS ARE .... IF > ELSE += &&
IF YOU SUCCEED YOU CAN BASICALLY SCRIPT...CONGRATULATIONS, NOW MAKE A GAME
ONE POSSIBLE EXAMPLE ANSWER - place this code inbetween the curly brackets in a script object - where it says your script here
int counter;
if (counter > 900 && IN_0 > 10) //WHERE IN_0 IS THE SPEED OF THE CAR, TAKEN FROM THE LIST IN THE MIDDLE LEFT WINDOW
iObjectShow(OBJ_22); //WHERE OBJ_22 IS THE SPRITE HANDLE, TAKEN FROM THE LIST IN THE TOP LEFT WINDOW
else
{
iObjectHide(OBJ_22);
counter += 1; // PLACING THIS HERE JUST STOPS THE COUNTER GOING UP AFTER IT REACHES 901, IT COULD BE PLACED OUTSIDE THE IF/ELSE STATEMENTS
}