Game Development Community

Function block

by Jared Reno · in Technical Issues · 07/06/2007 (8:56 am) · 12 replies

Hey this post should probably go in a diffrent section but I thought that you might understand it better.
It tells me how to make a function block and im not sure I understand. Its from 3dGPAi1 in chapter two. After the exercise it says this about how to make a function block:

begins with keyword function followed by 1 or more spaces and whatever name you want it to have.
after the names comes the argument list (or parameter list). Then comes the opening or left brace .
After that comes the body function followed by the closing or right brace.

Now if someone could make a simple function block with all that listed in there to show me what it is, Id be greatful. Thanks

#1
07/06/2007 (9:11 am)
Take a look at literally any script file (ok, except for the mission file) and you will see exactly what he describes in the book.
#2
07/06/2007 (9:18 am)
Ok then. You wouldnt happen to now how I can gain acess to a script file would you?
#3
07/06/2007 (9:20 am)
Have you downloaded the demo, or installed the (older) demo from the book's cd?

Everything within the /example directory are script files--basically, anything that ends with .cs
#4
07/06/2007 (9:23 am)
Yes to the cd installation. Thanks ill look for the .cs files. Dont know why I didnt think of that.
#5
07/06/2007 (9:25 am)
Problem. Cant access the .cs files.
#6
07/06/2007 (9:34 am)
The book covers this, not only in discussion, but also gives you suggestions (and even an installer if I remember correctly) for an editor.

This is one of those "forums help those that help themselves" type of things :) There are no less than two .cs editors (Torsion and Codeweaver) available from this site, an installer on the CD, and dozens of discussions on the topic "what's the best TorqueScript editor" in the forums.
#7
07/06/2007 (9:35 am)
Lets see if I get this after looking at it over and over again.

Keyword Function means just put the word function in doesnt it?

then the name like (this is book example) runHelloWorld()

then the parameter list like if (&toobig == true) echo("Its too big")

After parameters I understood perfectly. Did I get it right?

Or wait the parameters would just be the if and then in the main part of the function body (after the first brace) you put echo("Its too big")
#8
07/06/2007 (9:45 am)
Thanks Stephen for the help. I did try to open those files with Ultraedit-32 up but it errored out on me.
#9
07/06/2007 (10:04 am)
I kinda need an awnser. I really dont want to go on in the book without a for sure awnser. I tried everything to open the bloody .cs files but it doesnt work. Except for the hello world one thats it. Thats the only script ive seen. Please help me on this.
#10
07/06/2007 (11:10 am)
en.wikipedia.org/wiki/Function_%28computer_science%29
en.wikipedia.org/wiki/Parameter_%28computer_science%29

You can open .cs files with notepad, but like Stephen said above: TORSION or CODEWEAVER are better options.
#11
07/07/2007 (1:26 am)
Don't double click the .cs file to open.
instead Go into any text editor (just try notepad first) and go:

File->open file
Set the 'Files of types' to 'All Files'
Go to the directory that has the .cs you're trying to open
select the file
click on open

edit: don't try and open the .cs.dso files just open and edit the .cs file
#12
07/07/2007 (11:21 am)
Thanks. I did that and I kinda see what he says. Im going on in my book anyway hoping that later on Ill pick up the concept. Wish me luck.

Jared A.K.A The guy whose head hurts after every lesson. xD