Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-22-2014, 03:08 PM
Johnaudi Johnaudi is offline
Weirdo
Join Date: May 2014
Location: Lebanon
Posts: 4
Johnaudi will become famous soon enough
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)

Graal Script Code:
player.chat sqrt(81); // returns Function not found (0) 
Graal Script Code:
temp.= new Math();
player.chat temp.m.sqrt(81); // function not found as well. 
(under clientside)
And on serverside:
Graal Script 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)
Reply With Quote
  #2  
Old 07-22-2014, 03:24 PM
PiX PiX is offline
Registered User
PiX's Avatar
Join Date: Jul 2014
Posts: 9
PiX will become famous soon enough
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:
Graal Script 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.
Reply With Quote
  #3  
Old 07-22-2014, 03:37 PM
Johnaudi Johnaudi is offline
Weirdo
Join Date: May 2014
Location: Lebanon
Posts: 4
Johnaudi will become famous soon enough
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?
Reply With Quote
  #4  
Old 07-22-2014, 03:59 PM
PiX PiX is offline
Registered User
PiX's Avatar
Join Date: Jul 2014
Posts: 9
PiX will become famous soon enough
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 07:36 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.