Jump to content

UI/Coding Question


Recommended Posts

Posted

Hey guys.

 

I was tinkering around with the base SP .menu files, and I found something interesting. in the menu "ingameMissionSelect1", there appears to be itemDef (a bit of the menu) that has...a rather advanced CvarTest (a cvartest is when the game checks the cvar for selected values and preforms an indicated operation, like Hide Show Enable Disable). The bit that makes it so odd is that it is testing a cvar I've never heard of: "tiers_complete". But there is one more odd part to this cvartest, a line called "cvarSubString". Now, this is pretty cool. Usually, if you are testing a string, if looks for the literal defnition of the string, and if it maches the test, it does its thing. Here, however, it looks for a certain part of the string. So if the test is looking for "TRUE", then valid values include "This question is TRUE" or "FALSE TRUE" or any other value that has a space, and the TRUE in it. Very cool! But I have a question regarding this. I could do SO much with this, however, is there any way to 'add' to a cvar string, rather than redefine it?

 

For example, when you play SP, you may check the value of tiers_complete and you'll get "t1_sour t1_rail t1_suprise". As you can tell, it's a list of values for the menu to check later. So, when you beat a level, it automatically adds it's map name to this cvar. I was curious and checked OpenJK's git repository and found this:

extern void G_ChangeMap (const char *mapname, const char *spawntarget, qboolean hub);	//g_utils
void target_level_change_use(gentity_t *self, gentity_t *other, gentity_t *activator)
{
G_ActivateBehavior(self,BSET_USE);

if( self->message && !Q_stricmp( "disconnect", self->message ) )
{
gi.SendConsoleCommand( "disconnect\n");
}
else
{
G_ChangeMap( self->message, self->target, (self->spawnflags&1) );
}
if (self->count>=0)
{
gi.cvar_set("tier_storyinfo", va("%i",self->count));
if (level.mapname[0] == 't' && level.mapname[2] == '_'
&& ( level.mapname[1] == '1' || level.mapname[1] == '2' || level.mapname[1] == '3' )
)
{
char s[2048];
gi.Cvar_VariableStringBuffer("tiers_complete", s, sizeof(s));	//get the current list
if (*s)
{
gi.cvar_set("tiers_complete", va("%s %s", s, level.mapname));	//strcat this level into the existing list
}
else
{
gi.cvar_set("tiers_complete", level.mapname);	//set this level into the list
}
}
if (self->noise_index)
{
cgi_S_StopSounds();
cgi_S_StartSound( NULL, 0, CHAN_VOICE, cgs.sound_precache[ self->noise_index ] );
}
}

set_mission_stats_cvars();

}

So it seems like this feature is...hard coded to the target_level_change entity. That being said, is there any other way to add to a cvar, rather than re-define it? For example, if my cvar is "CvarNpc" and the value is "Alora" but I use a command to set it to "Reborn", the new value of "CvarNpc" would be "Alora Reborn". Or is this feature strictly hard-coded?

 

Regardless, this is really cool and I can't wait to work with CvarSubStrings. Any coders (@@eezstreet, @@Raz0r) have any opinions on this?

Thanks!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...