Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Gs2 Missing or Depricated functions? (https://forums.graalonline.com/forums/showthread.php?t=134269401)

Johnaudi 07-22-2014 02:08 PM

Gs2 Missing or Depricated functions?
 
Hey,

I've been coding recently and been trying lots of code currently, not sure if the issue is from my part or the function itself.


An important method used is sqrt() which is, the square root... It is as important as cos() and sin() for me.

Quote:

Script help for 'sqrt':
Clientside:
Math.sqrt(float) - returns float
Math.sqrt1_2 - float (read only)
Math.sqrt2 - float (read only)

PHP Code:

player.chat sqrt(81); // returns Function not found (0) 

PHP Code:

temp.= new Math();
player.chat temp.m.sqrt(81); // function not found as well. 

(under clientside)
And on serverside:
PHP Code:


function onCreated() echo(sqrt(81));

--

Script: Function sqrt not found at line 3 in script of X


I'm trying not to hard-code the function as it reduces the performance of the code, any ideas why it's not working?

I came across lots of problems and will post them here shortly.

Thanks in advance.

(posted on Graalians as well)

PiX 07-22-2014 02:24 PM

There are sometimes variables and functions in script help which do not exist. To perform the square root operation, take a value to the power of 0.5. For example, if you wanted to have an identical call as to what is found in script help, put the following code into a weaponscript called Math:
PHP Code:

public function sqrt(a) {
  return 
0.5;
}
//#CLIENTSIDE
public function sqrt(a) {
  return 
0.5;


By creating these into a weaponscript called Math, the name Math becomes global can then call Math.sqrt(number) from anywhere.

Johnaudi 07-22-2014 02:37 PM

Thanks but I'd like to know is there a reason under this deprication? Aren't all scripting/programming language supposed to have the basic math classes?

PiX 07-22-2014 02:59 PM

Most math functions are available in normal methods, such as cos, arccos, sin, arcsin, tan, arctan, getangle, and abs ( there are more ). Graal does have basic math as any language should, but it is a bit different sometimes, as it uses the operator ^ for math power, whereas in most languages ^ is used for bitwise comparisons.


All times are GMT +2. The time now is 07:25 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.