Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-03-2009, 11:39 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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.
Reply With Quote
  #2  
Old 02-03-2009, 02:07 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #3  
Old 02-03-2009, 03:19 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Stefan View Post
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.)
Reply With Quote
  #4  
Old 02-04-2009, 02:25 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Loriel View Post
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.
Reply With Quote
  #5  
Old 02-04-2009, 12:17 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by WhiteDragon View Post
import is something he added awhile ago to the GServers.
This. Is. Awesome.
Reply With Quote
  #6  
Old 02-04-2009, 02:01 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
Quote:
Originally Posted by WhiteDragon View Post
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?
__________________
Reply With Quote
  #7  
Old 02-04-2009, 03:08 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by Inverness View Post
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.
Reply With Quote
  #8  
Old 02-05-2009, 02:45 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
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.
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 08:45 AM.


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