Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-12-2008, 09:09 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Longer numerals / Class Implementation

I've been working for gScript for quite a while now, and one thing that bugs me is that the numerals supported in gScript can only go to 2147483647. In C++, another language I excel at, there are extended primitive types such as 'long' and 'long double' which allow you to go to a much higher number (long double goes from 3.4e-4932 to 1.1e+4932 -- scientific notation of course).

Another thing I'd like to see implemented is the functionality to create inline classes (ones inside the weapon script, for example) to organize the things the weapon / NPC-script does. These should include inheritance.

Any comments?
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #2  
Old 03-12-2008, 09:16 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
i dont see why you need long integers, but inline classes can improve performance i suppose
Reply With Quote
  #3  
Old 03-12-2008, 10:13 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Maybe just me, I can't think of any reason you'd need to go up to 2147483647 that there is no workaround for.
__________________
Reply With Quote
  #4  
Old 03-12-2008, 10:44 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
For "classes" use a TStaticVar and join a class to it or define its functions manually with function objects.
__________________
Reply With Quote
  #5  
Old 03-12-2008, 11:19 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
The numbers I agree on.. well, I would love to see that implented

The Exp curve I made, just goes to 2147483647 as maxexp when almost near max level And I don't want to make a new formula, then I need to balance everything out again..
__________________
Reply With Quote
  #6  
Old 03-12-2008, 11:25 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by Inverness View Post
For "classes" use a TStaticVar and join a class to it or define its functions manually with function objects.
Not my point. The point is to allow classes to be included in Weapon scripts.

e.g.
PHP Code:
//#CLIENTSIDE
class Foo
{
virtual public void DoSomething() const { return "Something done..."; }
private 
int numeral;
}

class 
Bar extends Foo
{
public 
void DoSomething() const { return "Bar done..."; }
}

function 
onCreated()
{
bar = new Bar();

echo(
bar.DoSomething());

Notice the inheritance and the virtual methods.
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #7  
Old 03-12-2008, 11:46 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Yes and like I said, use a TStaticVar object and define its functions with function objects or a class.
PHP Code:
//// Example Script
function onCreated() {
  
this.topleft Objects.Rect(null00screenwidth 2screenheight 2);
}
function 
GraalControl.onMouseDown() {
  if (
this.topleft.inside(mousescreenxmousescreeny)) {
    
// do stuff
  
}
}
//// Weapon Script: Objects
public function Rect(objnamenxnynwnh) {
  
temp.obj = new TStaticVar(""@objname);
  
obj.int(nx);
  
obj.int(ny);
  
obj.int(nw);
  
obj.int(nh);
  
obj.join("type_rect");
  return 
obj;
}
//// Class Script: type_rect
function inside(nxny) {
  if (
nx in |this.xthis.this.w| && ny in |this.ythis.this.h|) {
    return 
true;
  }
  return 
false;
}
public function 
objecttype() {
  return 
"TRect";

It is not necessary to include what you're saying into GScript when the same functionality can already be achieved.
__________________

Last edited by Inverness; 03-13-2008 at 12:00 AM..
Reply With Quote
  #8  
Old 03-13-2008, 12:09 AM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by Inverness View Post
Yes and like I said, use a TStaticVar object and define its functions with function objects or a class.
PHP Code:
//// Example Script
function onCreated() {
  
this.topleft Objects.Rect(null00screenwidth 2screenheight 2);
}
function 
GraalControl.onMouseDown() {
  if (
this.topleft.inside(mousescreenxmousescreeny)) {
    
// do stuff
  
}
}
//// Weapon Script: Objects
public function Rect(objnamenxnynwnh) {
  
temp.obj = new TStaticVar(""@objname);
  
obj.int(nx);
  
obj.int(ny);
  
obj.int(nw);
  
obj.int(nh);
  
obj.join("type_rect");
  return 
obj;
}
//// Class Script: type_rect
function inside(nxny) {
  if (
nx in |this.xthis.this.w| && ny in |this.ythis.this.h|) {
    return 
true;
  }
  return 
false;
}
public function 
objecttype() {
  return 
"TRect";

It is not necessary to include what you're saying into GScript when the same functionality can already be achieved.
Simplicity, my friend.

Also, you're not getting my point.

read the following words:

INHERITANCE


Your argument contained no hint of inheritance at all


-----
I'd also like to point out that I said classes within Weapon scripts, not class scripts.

Creating a class in a Weapon script is much different than in a class script.
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ

Last edited by Programmer; 03-13-2008 at 12:23 AM..
Reply With Quote
  #9  
Old 03-13-2008, 01:14 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
OH GOD HELP I'M IN A BOX.

PHP Code:
// someclass_a
public function foo() {
  return 
3.141592653;

PHP Code:
//someclass_b
public function foo() {
  return 
589793238;

PHP Code:
function bar() {
  
temp.var = new TStaticVar();
  
with (temp.var) {
    
this.join("someclass_a");
    ...
  }
  return 
temp.var;
}

function 
baz() {
  
temp.var = new TStaticVar();
  
with (temp.var) {
    
this.join("someclass_b");
    for (
cbar().joinedclasses)
      
this.join(c);
    ...
  }
}

function 
onCreated() {
  
temp.bar();
  
temp.baz();
  echo(
temp.r.foo() @ temp.z.foo());

Also, since I'll bet you'll be wondering, yes, you can make abstract datatypes this way. And you can inherit directly (in baz: temp.var = bar()) if children do not try to overwrite functions.

As for longer numbers, you can use strings to display them, or I'm sure there are ways (not easy ways, mind you) for arbitrary precision math. I won't go into detail.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #10  
Old 03-13-2008, 01:44 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Programmer View Post
Your argument contained no hint of inheritance at all
Obviously. If you know how to script then you would know how to implement inheritance on your own based on my example.
PHP Code:
// Weapon Script: Objects
public function ColoredRect(objnamenxnynwnhcrcgcbcacf) {
  
temp.obj this.Rect(objnamenxnynwnh);
  
obj.color this.Color(nullcrcgcbcacf);
  
obj.join("type_coloredrect");
  return 
obj;
}
public function 
SimpleColoredRect(objnamenxnynwnhcrcgcbca) {
  
temp.obj this.Rect(objnamenxnynwnh);
  
obj.red cr;
  
obj.green cg;
  
obj.blue cb;
  
obj.alpha ca;
  
obj.join("type_simplecoloredrect");
  return 
obj;
}
public function 
Color(objnamecrcgcbcacf) {
  
temp.obj = new TStaticVar(""@objname);
  
obj.red cr;
  
obj.green cg;
  
obj.blue cb;
  
obj.alpha ca;
  
obj.float cf;
  
obj.join("type_color");
  return 
obj;
}
// Class Script: type_color
public function toint() {
  if (
this.float) {
    
this.check();
    
this.red int(this.red 255);
    
this.green int(this.green 255);
    
this.blue int(this.blue 255);
    
this.alpha int(this.alpha 255);
    
this.float false
  }
}
public function 
tofloat() {
  if (!
this.float) {
    
this.check();
    
this.red this.red 255;
    
this.green this.green 255;
    
this.blue this.blue 255;
    
this.alpha this.alpha 255;
  }
}
public function 
check() {
  if (
this.float) {
    for (
temp.i: {"red""green""blue""alpha"}) {
      if (
this.(@ i) > 1)
        
this.(@ i) = 1;
      else if (
this.(@ i) < 0)
        
this.(@ i) = 0;
    }
  }
  else {
    for (
temp.i: {"red""green""blue""alpha"}) {
      if (
this.(@ i) > 255)
        
this.(@ i) = 255;
      else if (
this.(@ i) < 0)
        
this.(@ i) = 0;
    }
  }

I don't use inheritance myself because the time I did I found I was overcomplicating the script (a large one) and stopped doing it. Instead I now just have a single class that does everything, even stuff you might not need it for, rather like TShowImg.

So how would you implement inheritance in Graal?
Quote:
Originally Posted by Programmer View Post
I'd also like to point out that I said classes within Weapon scripts, not class scripts.
Classes should be global in all cases. We certainly don't need classes specific to a script.
Quote:
Originally Posted by Programmer View Post
Creating a class in a Weapon script is much different than in a class script.
Obviously. What you should have is a script to control all the classes on your server and not be specific to any object's script.

Edit: By the way PFA (?), if Graal didn't have a garbage collector you would cause memory leak with that
__________________

Last edited by Inverness; 03-13-2008 at 06:11 AM..
Reply With Quote
  #11  
Old 03-17-2008, 01:16 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by Inverness View Post
Edit: By the way PFA (?), if Graal didn't have a garbage collector you would cause memory leak with that
It was just an example; I see that I made at least one mistake. I have a bad habit of writing code in the reply box, going to test it, changing it around and never replacing it in the reply box. :P
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
Reply


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 03:21 AM.


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