3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2

Author Topic: Scripts - my last thread  (Read 2750 times)

« on: December 16, 2012, 07:17:29 PM »
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
}
« Last Edit: December 16, 2012, 07:20:16 PM by cypermethrin »

secondry2

« Reply #1 on: December 16, 2012, 08:35:59 PM »
Very useful cyper, sorry to see you go! Hope you may come back sometime!
« Reply #2 on: December 17, 2012, 05:31:39 AM »
Very useful information mate.

Left wondering who all those that are left are going to be able to turn to once they've driven every useful and knowledgable member of the community away...
« Reply #3 on: December 17, 2012, 06:12:41 AM »
Woah wait what? Have i missed something? Why you going mate whats happend? I don't understand why, serously reconsider! Damn thats really gutting :/ !!!


Gamefreaks1234 gaming forum a great place for general gaming chat and getting your games out there and played.

BorekS

« Reply #4 on: December 17, 2012, 06:28:08 AM »
cypher said why
Quote
I have become disillusioned with the forum, it is not what it was and the fun has gone out of it for me
and I agreee  :)

« Reply #5 on: December 17, 2012, 06:45:08 AM »
:( well we make our own fun. I dunno, this is the start of the end then :( i really thought the rotary gaming challenge really breathed some life into these forums! Damn redfox has really killed the mood though. Damn i'm gutted none the less, who's next then? :/


Gamefreaks1234 gaming forum a great place for general gaming chat and getting your games out there and played.
« Reply #6 on: December 17, 2012, 09:23:22 AM »
Just to be clear, my decision is not down to the actions of any one person, it is just the right decision for me right now, i'll still look at the forum from time to time, its just that I will end up posting something to get me banned at some point given the way things currently are and I know I can be a bit harsh in my comments and I do not wish to discourage anyone, this now appears to be very much a forum for kids, and I am not.

I did not want to fade out with no explanation or goodbye, I also wanted to go out with something that some may find useful.
nor will, or should, my departure affect the future of this forum or other users contributions
« Reply #7 on: December 17, 2012, 09:44:41 AM »
I can't stop you i suppose :/ and you are right. Question is whats going to happen with your developments? You are going to continue making games? Also what about 3Dfoundry... A good place to carry on right?


Gamefreaks1234 gaming forum a great place for general gaming chat and getting your games out there and played.
« Reply #8 on: December 17, 2012, 10:21:14 AM »
have faith cyper... there's still enough of the "ole crowd", and a few new members, who... are seriously trying to do some game development...

i think i know how you feel... but, inspite of those who just come around with some hair brain ideas of creating the next great Skyrim or COD killer, without even understanding how to write a single line of code or string together a single line of logic objects...  despite the kiddies who come around expecting someone else to do all their work (and thinking) for em... there are a few members who make it worthwhile staying with RAD...

and despite being pc only, i think we still have a lil while to go before RAD is totally outdated...

the forum will be a lot less without you... but i understand that you are at the point where, well... you gotta do what you gotta do...

good luck...

--Mike


« Reply #9 on: December 17, 2012, 10:44:09 AM »
What Mike said! I ain't going to beg, would be selfish to ask you to stay against your own will. I just hope you know it wont be the same with out you here. Though like Mike said RAD has life in it yet aslong as we continue to give it that life. Also i think its better to stay for the people who care then leave because of the people who don't.
« Last Edit: December 17, 2012, 10:55:41 AM by hypokill »


Gamefreaks1234 gaming forum a great place for general gaming chat and getting your games out there and played.
« Reply #10 on: December 17, 2012, 10:57:18 AM »
Thank you both, brought a tear to my eye ;)
Rotary continues, I will continue with games with rad, I still have 4 half finished projects with potential
I will probably post results 'on the other side of the road' so its not the last you've heard of me.
Anyway, never say never, my account won't be deleted, i'm not in the 'taking my ball and going home' frame of mind, I may change my mind in the future depending on how things change over here

fourdee

« Reply #11 on: December 17, 2012, 11:12:54 AM »
Cyper, if only you posted that 1 year ago!

This is an excellent set of details/info and working logic on scripting. It would of saved me months of learning basic programming if i had access to this.

Excellent post, but, stay active.
As an example:
I'am still working on my Tr0n game, but i dont post updates every day, iam a perfectionist and will only release something when i've made a massive improvement.

Thats not to say updates everyday is wrong, thats just the way i am.

To be honest, if the forums were more active, i would ask for more assistance in many of the issues iam currently encountering.
Then again, i like to break things and work them out myself, but a little nudge from someone with the knowledge would always be greatful!

Its a catch 22. For the forums to be more active, we all need to chip in.
I've only been able to get where i am with the help/support and time invested by many of the forum members.
Its about time i returned the favour!

I for one will try and create some tutorials and templates for others to use in the comming weeks. I dont wont to see this forum disband due to loss of members. Lets keep it active!
« Last Edit: December 17, 2012, 11:29:09 AM by Fourdee »
« Reply #12 on: December 17, 2012, 12:14:54 PM »
I wasn't here a year ago, nor could I have posted that then, just shows you can learn it if you try.
Hope it might help some to evolve from car on terrain
« Reply #13 on: December 17, 2012, 12:42:45 PM »
mate, seriously, if it was because of me, just say and i will leave and not come back.
i am sorry that i have dampend the mood, and upset everyone.

PLEASE DONT LET MY ACTIONS MAKE YOU GO!

i really enjoy seeing everyone here as one big comunity, and if you go, lots of other people will go! at least stay untill march, to see if things pick up a bit?!


honestly tho, unless i make up for what i did, i will go within reason if you want me to, for you to stay on. :'( :-\
« Reply #14 on: December 17, 2012, 01:05:31 PM »
I suppose I could make a you or me poll and let the public decide ;)

seriously though, don't flatter yourself, you have no impact on anything I decide, why would I let someone like you influence me?
Pages: [1] 2