Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial Basic GSC Coding: Operations
#1
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
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tutorial] Basic GSC Coding: Building your first mod and your first code Yamato 2 11,205 06-07-2016, 21:49
Last Post: FrostbytePG
  [Tutorial] Basic GSC Coding: Functions Yamato 15 12,284 08-17-2013, 10:17
Last Post: hamza-q99
  [Tutorial] Basic GSC Coding: Making your second code Yamato 9 8,636 12-28-2012, 13:30
Last Post: Yamato
  [Tutorial] Basic GSC Coding: Foreach, Continue and Return Yamato 6 7,574 04-04-2012, 08:33
Last Post: Yamato
  [Tutorial] Basic GSC Coding: Switch Yamato 6 6,035 04-03-2012, 18:32
Last Post: tsoPANos
  [Tutorial] Basic GSC Coding: If, Else and Else If Yamato 2 5,795 03-30-2012, 10:47
Last Post: alvarogt95
  [Tutorial] Basic GSC Coding: Downloading and Installing a mod Yamato 1 5,195 03-30-2012, 10:42
Last Post: alvarogt95
  [Tutorial] Basic GSC Coding: For Yamato 4 5,925 03-26-2012, 18:39
Last Post: tsoPANos
  [Tutorial] Basic GSC Coding: While, Break and Wait Yamato 6 7,516 03-06-2012, 13:48
Last Post: Yamato

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.