• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Referencing to Enums

K

KorbohneD

Guest
Quick Question Guys.

In my current project I have written a text file translator that turns text file code into real code.

Now the problem is, in the program, I have a bunch of enums, one in particular describing material. And of course I want to tell the textfile, which material it should give to the translator.
Is there any way to translate a string into an enum code?

Like I have this code here:

Code:
enum material {
   stone;
   wood;
   iron
}
textfile_variable = stone;

material_to_use = material.textfile_variable
Something like above?
I am really clueless what to do.
Any help is appreciated.

Sincerely,
KorbohneD
 
T

Taddio

Guest
Not quite sure I got what you want exactly, correct me if I didn't understood correctly
Do you want
Code:
enum material {
   stone,
   wood,
   iron,
}
textfile_variable.material = stone;
?

Like I said, not so sure what you were asking, let me know if that's not it, I'll see what I can do
 
K

KorbohneD

Guest
Not quite sure I got what you want exactly, correct me if I didn't understood correctly
Do you want
Code:
enum material {
   stone,
   wood,
   iron,
}
textfile_variable.material = stone;
?

Like I said, not so sure what you were asking, let me know if that's not it, I'll see what I can do

That code you posted doesn't make any more sense.
I have a text file, where I state an enum.
And I need that statement translated, so I can reference a real enum that I have in my code.
 
T

Taddio

Guest
Why not simply create an unused script and state your enums in there (they will be inittialized even if no one calls the script, neat feature) instead of going through the hassle of dealing with external files?
 
Top