Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial Basic GSC Coding: Operations
04-04-2012, 13:07
Post: #1
Basic GSC Coding: Operations
Hello

This is another basic tutorial I wanted to make before doing a tutorial about making your first codes. This one is about numbers and math functions ( I am not going to teach you maths guys Troll ).

In cod you can use 2 kinds of numbers, "int"s and "float"s. "Int"s are entire numbers ( 2, 3, 50, 1000, 45 ... ) and "float"s are decimal numbers ( 1.1, 4.324, 6.67, 3.141592 ... ). If you have for example the number 5.31 you can do some operations with it, like:

Code:
Int( 5.31 ) //will return 5
Floor( 5.31 ) //will return 5 ( aproximation to down )
Ceil( 5.31 ) //will return 6 ( aproximation to up )

The game also has some interesting functions relationed with "Int"s and "Float"s which give you random numbers, they are this 4:

Code:
randomInt( number )
randomIntRange( number 1, number 2 )
randomFloat( number )
randomFloatRange( number 1, number 2 )

Lets put some real examples with them:

Code:
luckynumber = randomInt( 6 ); //will give a random number beetween 0 and 6
wait ( randomFloatRange( 3, 6 ) ); //will wait a random ammount of time beetween 3 and 6 seconds, the times will probably be decimal numbers
tutorialnumber = randomIntRange( 1, 50 ); //random number beetween 1 and 50
wait ( randomFloat( 2 ) ); //will give you a random number beetween 0 and 2

Also the game allows you to use some basic operations such as: divisions, multiplications..... They work like this with real examples ( I recommend doing operations with pathenthesys: "( )" ):

Code:
plus = ( 3 + 15 ); // 18
minus = ( 100 - 30 ); // 70
multiplied = ( 2 * 2 ); // 4
divided = ( 100 / 20 ); // 5
moduled = ( 10 % 3 ); // 1, is the leftover of doing a division: 10 / 3 = 3, but there is one 1 missing, thats the module.
nepperlog = log( 1 ); // 0, is the natural logarithm ( Nepper one )
cosine = cos( 0 ); // 1, cosine, trigonometrical function
sine = sin( 90 ); // 1, sine, trigonometrical function
tangent = tan( 45 ); // 1, tangent, trigonometrical function
arcosine = asin( 1 ); // 90, arco sine, trigonometrical function
arcocosine = acos( 1 ); // 0, arco cosine, trigonometrical function
arcotangent = atan( 1 ); // 45, arco tangent, trigonometrical function
absolutevalue = abs( -3 ); // 3, if the number is lower than 0, it returns that number multiplied by -1
squareroot = sqrt( 4 ); // 2, square root
whatonebigger = max( 3, 9 ); //9, 9 is bigger than 3
whatonesmaller = min( 2, 6 ); //2, 2 is smaller than 6

Well, thats it, if you dont know what is mathematic operation -> Google it

Thanks for reading, @Yamato
Related links

[Image: veovuq.png]
Find all posts by this user
Add Thank You Quote this message in a reply
[-] The following 2 users say Thank You to Yamato for this post:
Bloodfocus (04-04-2012), SailorMoon (04-04-2012)
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Tutorial] Basic GSC Coding: Making your second code Yamato 9 689 12-28-2012 13:30
Last Post: Yamato
  [Tutorial] Basic GSC Coding: Making your third code Yamato 2 524 04-20-2012 23:04
Last Post: SuperNovaAO
  [Tutorial] Basic GSC Coding: Building your first mod and your first code Yamato 1 1,160 04-05-2012 17:53
Last Post: Pozzuh
  [Tutorial] Basic GSC Coding: Foreach, Continue and Return Yamato 6 593 04-04-2012 08:33
Last Post: Yamato
  [Tutorial] Basic GSC Coding: Switch Yamato 6 398 04-03-2012 18:32
Last Post: tsoPANos
  [Tutorial] Basic GSC Coding: If, Else and Else If Yamato 2 472 03-30-2012 10:47
Last Post: alvarogt95
  [Tutorial] Basic GSC Coding: Downloading and Installing a mod Yamato 1 515 03-30-2012 10:42
Last Post: alvarogt95
  [Tutorial] Basic GSC Coding: For Yamato 4 404 03-26-2012 18:39
Last Post: tsoPANos
  [Tutorial] Basic GSC Coding: While, Break and Wait Yamato 6 484 03-06-2012 13:48
Last Post: Yamato
  [Tutorial] Basic GSC Coding: Functions Yamato 10 688 03-05-2012 00:04
Last Post: alvarogt95

Forum Jump:


User(s) browsing this thread: 1 Guest(s)
Media Embeding by Simple Audio Video Embeder