AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Editing a global variable without a function. (https://forums.alliedmods.net/showthread.php?t=245329)

PreDominance 07-31-2014 11:56

Editing a global variable without a function.
 
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.

fysiks 07-31-2014 14:51

Re: Editing a global variable without a function.
 
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.

PreDominance 07-31-2014 22:27

Re: Editing a global variable without a function.
 
Quote:

Originally Posted by fysiks (Post 2176862)
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.

fysiks 07-31-2014 23:55

Re: Editing a global variable without a function.
 
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.)

PreDominance 08-01-2014 00:20

Re: Editing a global variable without a function.
 
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!


All times are GMT -4. The time now is 12:54.

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