Raised This Month: $ Target: $400
 0% 

Editing a global variable without a function.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PreDominance
Member
Join Date: Jul 2014
Old 07-31-2014 , 11:56   Editing a global variable without a function.
Reply With Quote #1

Yo,
I have a global variable, an array of strings. I'm trying to edit this array in multiple files, but I want to do so without using a function.

For context, this array is called RACE_NAMES. Each race file, ideally, will have something like: RACE_NAMES[RACE_XXX] = "XXX";

If I do this from inside a function, I have to call that function from somewhere else. The whole point is that, when I add a new race, I only have to edit the RACE_NAMES gVar without having to edit other parts of my plugin to include the race.

Is there a way to do this inside each race's file, or would I just be better off initializing the array when I declare it? The whole point is that I want to minimize the number of things I need to edit when adding a new race.

Last edited by PreDominance; 07-31-2014 at 12:01.
PreDominance is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-31-2014 , 14:51   Re: Editing a global variable without a function.
Reply With Quote #2

What do you mean by "each race file"? What kind of file is this?

It is possible to make your code flexible enough to the point you only need to change a few things but the more flexible you make your code, the more complex code it is.
__________________
fysiks is offline
PreDominance
Member
Join Date: Jul 2014
Old 07-31-2014 , 22:27   Re: Editing a global variable without a function.
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
What do you mean by "each race file"? What kind of file is this?

It is possible to make your code flexible enough to the point you only need to change a few things but the more flexible you make your code, the more complex code it is.
I don't necessarily mind the complication, so long as it's all back-end stuff that does not need to be modified.

By each race file..I mean that every race will have its own .inl file. I currently have two, race_human_alliance.inl and race_undead_scourge.inl . In each file, I would like to have some kind of declaration of the race name. Otherwise, I have to do:
Code:
new RACE_NAMES[RACE_LAST][20] = {
    "None",
    "Undead Scourge",
    "Human Alliance",
    "Orcish Horde",
    "Night Elves"
};
I want to localize as much information per race as I can into its own specific file. The main reason I wasn't able to work off of the existing war3:Ft mod was that every race had skills and abilities scattered throughout the mod in differing files. I want my mod to have almost 100% of the race in its own file.
PreDominance is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-31-2014 , 23:55   Re: Editing a global variable without a function.
Reply With Quote #4

Oh, so you want all of this done pre-compile. . . I doubt that is possible.

I've heard of API based systems that would probably work better than what you are trying to do with pre-compile integration.

In an API style system, you would have a plugin for each race. Each plugin would then "register" with the main API giving all the relevant information (including race name, race functions, etc.)
__________________

Last edited by fysiks; 07-31-2014 at 23:58.
fysiks is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-01-2014 , 00:20   Re: Editing a global variable without a function.
Reply With Quote #5

Huh. That sounds kind of cool to be honest and I'd never considered it.

I'm just going to go with editing an array declaration and be done with it. It's not too hard to find and shouldn't be a pain. Thanks anyway!
PreDominance is offline
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 -4. The time now is 17:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode