AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Macro suggestions (https://forums.alliedmods.net/showthread.php?t=46174)

DarkSnow 10-20-2006 11:34

Macro suggestions
 
In a project of mine, i have it setup to load a huge ammount of settings from a config file. The plugin can have multiple configurations loaded simultaniously, and can switch between them.

Now im working on having a "macro" thingy, in where the plugin reads from a config file 4 parsed values:

Code:

#1. object
#2. condition
#3. value
#4. config id (rl)

An example from the macro file:

Code:

"mapname" "contain" "de_" "4"
//if mapname contains "de_" switch rl to #4

"mapname" "not_equal" "cs_assault" "2"
//if mapname != "cs_assault" switch rl to #2


So, im asking for suggestions on different "objects" and "conditions". Any help is apreciated :)

Zenith77 10-20-2006 12:07

Re: Macro suggestions
 
Here is some very abstract code. It uses simulated structs to organize some stuff. Also, you'll notice that the condition should be parsed from the file and set accordingly (example: if condition is "not_equal" then itsCondition should be set to CONDITION_NOTEQUAL).

Code:
enum Config {     itsObject[],     itsCondition, // Instead of using a string, when you parse the config, just set it has a cell.     itsValue[],     itsConfigID }; enum {     CONDITION_CONTAIN = 0,     CONDITION_NOTEQUAL     // Put your stuff here. }; #define MAX_CONFIGS 10 new gConfig[MAX_CONFIGS][Config]; // A very quick example on how you can use this: // ---- // Read config file bla bla bla set some stuff. // ---- new someConfig = 5; if (gConfig[someConfig][itsCondition] == CONDITION_NOTEQUAL) {       if (!equal(gConfig[someConfig][itsObject], gConfig[someConfig][itsValue]))     {         // Code...     } }

DarkSnow 10-20-2006 12:29

Re: Macro suggestions
 
Zenith77:
Thanks, this will make the code alot clearer.

Do you have any suggestions on "objects" that might be of interest? Im kinda stuck on mapname, and have run out of ideas.

Zenith77 10-20-2006 19:08

Re: Macro suggestions
 
You can use/set it up the same way I did with conditions.


All times are GMT -4. The time now is 04:55.

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