From 29a9a49c9ccb806cbfb08f2f5e6c37c175e32bda Mon Sep 17 00:00:00 2001 From: Bukz Date: Sun, 17 Apr 2011 17:22:23 +0000 Subject: [PATCH] storesets - store multiple CVARs into an alias (list) efficiently git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6274 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/docs.cfg | 4 ++++ config/scripts.cfg | 18 ++++++++++++++++++ docs/reference.xml | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/config/docs.cfg b/config/docs.cfg index 3fcebd18..b0cf10f8 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -173,6 +173,10 @@ docident [add2list] [Appends a new element to a list.]; docargument [A] [the alias (list) to add to] [] [0]; docargument [E] [the new element to add] [] [0]; docexample [tmp_list = []; add2list tmp_list Hello; add2list tmp_list world!; echo $tmp_list] [Output: Hello world!]; +docident [storesets] [Generates an alias (list) of the current values for the given CVARs.]; +docargument [L] [the list of CVARs] [] [0]; +docargument [A] [the alias to store them in] [] [0]; +docexample [storesets "sensitivity hudgun fov" tmp] [Example result: stores "3.000 1 120" into alias "tmp".]; docsection [General] docident [addserver] [Adds a server to the list of server to query in the server list menu.]; docargument [S] [the address of the server (hostname or IP)] [] [0]; diff --git a/config/scripts.cfg b/config/scripts.cfg index 746dcd68..0d8e21a3 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -384,6 +384,24 @@ setmr = [ ] [ echo (c 3)Error: (c 5)You are not currently watching a demo. ] ] +// storesets - Generates an alias (list) of the current values for the given CVARs. +omit_idents = "curname curteam name" + +storesets = [ + if (> $numargs 1) [ + if (listlen $arg1) [ + badargs = 0 + $arg2 = "" + loop ssl (listlen $arg1) [ + if (&& (isIdent (at $arg1 $ssl)) (! (strstr $omit_idents (at $arg1 $ssl)))) [ + add2list $arg2 (getvar (at $arg1 $ssl)) + ] [ badargs = 1 ] + ] + if $badargs [ delalias $arg2; echo (c 3)Error: (c 5)Bad "argument(s)" given! ] + ] + ] +] + // Simple claim-admin script for one single-server. // Fill in the 3 aliases below, and uncomment the below line to activate. // bind F3 "customclaimadminscript" diff --git a/docs/reference.xml b/docs/reference.xml index 61ff4cd6..e08b8602 100644 --- a/docs/reference.xml +++ b/docs/reference.xml @@ -658,6 +658,26 @@ + + + Generates an alias (list) of the current values for the given CVARs. + + + + Example result: stores "3.000 1 120" into alias "tmp". + + + + Some idents cannot be stored via this command (e.g. curname), if an argument is given that cannot be used, the command will throw and error to notify you. + + + + + + + + +