User:David/Cvar Matrix

From Tremulous Wiki
Jump to: navigation, search

Introduction

As with the Imported Cvars automation was used to generate the Cvar Matrix. This is here to document how that was done so it can be repeated if needed. Flag A (Archive) is deliberately left off as almost all cvars have it set.

Steps

  • Get a list of cvars.
  • Run script.
    • Source is below.
    • It wants the cvar list on stdin.
    • Spews all output to stdout.
  • Check it!
    • Again, don't blame me when it all goes horribly wrong.
  • Copy and paste it where you want it.
    • The generated output has no header, or other surrounding table stuffs.

The Script

#!/usr/bin/perl -W
use strict;

sub trunc
{
	my ($str) = @_;
	if (length($str) > 20)
	{
		return (substr($str, 0, 17) . "...");
	}
	return ($str);
}

while(my $line = <STDIN>)
{
	if ($line =~ /^(.)(.)(.)(.)(.)(.)(.) ([^ ]+) "([^"]*)"$/)
	{
		# SURIALC
		# S=serverinfo
		# U=userinfo
		# R=readonly
		# I=initilisation only or something.
		# A=archive
		# L=latched
		# C=cheat
		
		print "|-\n";
		print "| [[$8]] || " . ($9 eq "" ? "None" : trunc($9)) . " || {{unk}} || ";
		print $1 eq "S" ? "{{yes|[[Cvars#Serverinfo_Cvars|Yes]]}}" : "{{no|[[Cvars#Serverinfo_Cvars|No]]}}";
		print " || ";
		print $2 eq "U" ? "{{yes|[[Cvars#Userinfo_Cvars|Yes]]}}" : "{{no|[[Cvars#Userinfo_Cvars|No]]}}";
		print " || ";
		print $3 eq "R" ? "{{yes|[[Cvars#Readonly_Cvars|Yes]]}}" : "{{no|[[Cvars#Readonly_Cvars|No]]}}";
		print " || ";
		print $4 eq "I" ? "{{yes|[[Cvars#Initialization_Only_Cvars|Yes]]}}" : "{{no|[[Cvars#Initialization_Only_Cvars|No]]}}";
		print " || ";
		print $5 eq "A" ? "{{yes|[[Cvars#Archived_Cvars|Yes]]}}" : "{{no|[[Cvars#Archived_Cvars|No]]}}";
		print " || ";
		print $6 eq "L" ? "{{yes|[[Cvars#Latched_Cvars|Yes]]}}" : "{{no|[[Cvars#Latched_Cvars|No]]}}";
		print " || ";
		print $7 eq "C" ? "{{yes|[[Cvars#Cheat_Cvars|Yes]]}}" : "{{no|[[Cvars#Cheat_Cvars|No]]}}";
		print "\n";
	}
	else
	{
		print STDERR "Unable to parse line: " . $line;
	}
}
Tremulous
Personal tools