Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Inheriting enums? (https://forums.graalonline.com/forums/showthread.php?t=84005)

Loriel 02-03-2009 11:39 AM

Inheriting enums?
 
I am defining an enum in class 1, like this:

NPC Code:
enum FOO {
VAL_1,
VAL_2
}



then in another class I do:

NPC Code:
join("class 1");
this.chat = FOO.VAL_2;



and the chat text of NPCs of that class gets set to 0. Why is it not 1, ie. why is the enum not coming into scope by having the surrounding class joined?

Edit: Same with "const" constants, actually.

Admins 02-03-2009 02:07 PM

Because join and leave are dynamic functions, not done at compile time. It could be possible to expand the "import" function to allow importing of const and enums from other classes.

Loriel 02-03-2009 03:19 PM

Quote:

Originally Posted by Stefan (Post 1462459)
Because join and leave are dynamic functions, not done at compile time. It could be possible to expand the "import" function to allow importing of const and enums from other classes.

I would be happy with a non-dynamic, compile-time, include-style alternative to join, for my situation. (I am not sure whether you are suggesting to modify join, or add an 'import' compile-time-function, or.)

WhiteDragon 02-04-2009 02:25 AM

Quote:

Originally Posted by Loriel (Post 1462471)
I would be happy with a non-dynamic, compile-time, include-style alternative to join, for my situation. (I am not sure whether you are suggesting to modify join, or add an 'import' compile-time-function, or.)

import is something he added awhile ago to the GServers.

You make the class "foo.bar" and you can do stuff like

PHP Code:

public function Bar() {
  return 
this;
}
public function 
getSomething() {
  return 
2;


And then elsewhere:

PHP Code:

import foo.bar;
function 
onPlayerEnters() {
  
temp.myBar = new Bar();
  echo(
temp.myBar.getSomething()); // echos 2


I'm guessing this is done at compile-time, so your enums would work as well if Stefan were to make the changes.

Twinny 02-04-2009 12:17 PM

Quote:

Originally Posted by WhiteDragon (Post 1462690)
import is something he added awhile ago to the GServers.

This. Is. Awesome.

Inverness 02-04-2009 02:01 PM

Quote:

Originally Posted by WhiteDragon (Post 1462690)
import is something he added awhile ago to the GServers.

So if you hadn't announced this, when was the rest of the scripting community going to find out about it?

Admins 02-04-2009 03:08 PM

Quote:

Originally Posted by Inverness (Post 1462785)
So if you hadn't announced this, when was the rest of the scripting community going to find out about it?

Already mentioned it before: http://forums.graalonline.com/forums...7&postcount=24
It's not really doing a lot though.

Inverness 02-04-2009 06:58 PM

Quote:

Originally Posted by Stefan (Post 1462790)
Already mentioned it before: http://forums.graalonline.com/forums...7&postcount=24
It's not really doing a lot though.

I'm sure many would appreciate if you created a sticky thread full of the random NPC-Server updates that you do.

Loriel 02-04-2009 07:54 PM

Quote:

Originally Posted by Inverness (Post 1462835)
I'm sure many would appreciate if you created a sticky thread full of the random NPC-Server updates that you do.

I miss newfeatures.txt.

WhiteDragon 02-05-2009 02:45 AM

import is a bit buggy though, every time I attempt to do something with it I encounter errors after the program structure gets more complicated.

Admins 02-05-2009 06:04 PM

Quote:

Originally Posted by Loriel (Post 1462844)
I miss newfeatures.txt.

There was never a newfeatures.txt for npcserver, and the updates for the client are already on the wiki :)
Might be interesting to add a wiki page for the npcserver/gserver updates, there is usually a lot. In the past few weeks these things were added (will work once the new npcserver is tested and uploaded everywhere):
- /stats displays memory usage
- calling leave() for other objects will directly let the object leave the class instead of waiting until the current script has finished execution
- TDrawingPanel on serverside for image manipulation, also adds a new command maskimage(x,y,imagename,"add" or "multiply")
- getimgwidth() and getimgheight() also work for jpegs etc., not just gifs and png/mng
- some new commands for the mudlib which are secret right now except for the kingdoms staff

Crow 02-05-2009 07:02 PM

Quote:

Originally Posted by Stefan (Post 1463199)
There was never a newfeatures.txt for npcserver, and the updates for the client are already on the wiki :)
Might be interesting to add a wiki page for the npcserver/gserver updates, there is usually a lot. In the past few weeks these things were added (will work once the new npcserver is tested and uploaded everywhere):
- /stats displays memory usage
- calling leave() for other objects will directly let the object leave the class instead of waiting until the current script has finished execution
- TDrawingPanel on serverside for image manipulation, also adds a new command maskimage(x,y,imagename,"add" or "multiply")
- getimgwidth() and getimgheight() also work for jpegs etc., not just gifs and png/mng
- some new commands for the mudlib which are secret right now except for the kingdoms staff

Uhh, top secret. Awesome. I agree though, a wiki page for gserver/npcserver changes would be very nice.

Loriel 02-05-2009 07:03 PM

Quote:

Originally Posted by Stefan (Post 1463199)
There was never a newfeatures.txt for npcserver, and the updates for the client are already on the wiki :)

Let me rephrase that: I miss the old days when I could get more or less complete information about any feature by checking newfeatures.txt.


All times are GMT +2. The time now is 11:37 PM.

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