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 05-17-2006, 02:02 AM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
enum

How does it work?
I've used it before, but I can't remember how now.

enum MODE{"FOLLOW","STAY","ATTACK"};
enum MODE{FOLLOW,STAY,ATTACK};
MODE.FOLLOW;
this.action = MODE.FOLLOW;

Help? I have no clue how it works.
Reply With Quote
  #2  
Old 05-17-2006, 03:07 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
I'm not sure how Graal does it, but I think in C++ an enumeration is a word constant for numbers, in your example, follow would be 0, stay as 1, and attack as 2 and so on. But this isn't the format I've seen it in, I've never seen using mode.follow or the MODE at the front of the enumeration, so I could be very wrong XD
Reply With Quote
  #3  
Old 05-17-2006, 03:38 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
looks as if some array o.O
__________________
Deep into the Darkness peering...
Reply With Quote
  #4  
Old 05-17-2006, 04:00 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by Yen
this.action = MODE.FOLLOW;
From what I remember about enumerated types, that would give this.action the value of 0. (this.action = MODE.ATTACK //this.action is 2).

It's used mostly so that you don't have to remember '2' means attack. You can just use MODE.ATTACK instead.

Examples:
PHP Code:
enum foo{abc}; 
is sort of like:
PHP Code:
foo.0;
foo.1;
foo.2
You can also do:
PHP Code:
enum foo{4810}; //4, 8, 10 are arbitrary 
Which is like:
PHP Code:
foo.4;
foo.8;
foo.10
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #5  
Old 05-17-2006, 01:32 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
All hail Napo =p
__________________
Deep into the Darkness peering...
Reply With Quote
  #6  
Old 05-17-2006, 04:54 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
I'm not sure how Graal does it, but I think in C++ an enumeration is a word constant for numbers, in your example, follow would be 0, stay as 1, and attack as 2 and so on. But this isn't the format I've seen it in, I've never seen using mode.follow or the MODE at the front of the enumeration, so I could be very wrong XD
PHP Code:
enum MODE
{
  
IDLEWALK

... produces the following possibilities:
  • MODE.IDLE, with value 0
  • MODE.WALK, with value 1
Also.
PHP Code:
enum
{
  
IDLEWALK

... produces the following possibilities:
  • IDLE, with value 0
  • WALK, with value 1
__________________
Skyld
Reply With Quote
  #7  
Old 05-17-2006, 05:08 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Yeah I've never done it with something in front of the definitions, I suppose it would be quite usefull
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 09:49 AM.


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