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
This commit is contained in:
Bukz
2011-04-17 17:22:23 +00:00
parent 401f018b76
commit 29a9a49c9c
3 changed files with 42 additions and 0 deletions
+4
View File
@@ -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];
+18
View File
@@ -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"
+20
View File
@@ -658,6 +658,26 @@
<argument token="E" description="the new element to add"/>
</arguments>
</command>
<command name="storesets">
<description>Generates an alias (list) of the current values for the given CVARs.</description>
<examples>
<example>
<code><![CDATA[storesets "sensitivity hudgun fov" tmp]]></code>
<explanation>Example result: stores "3.000 1 120" into alias "tmp".</explanation>
</example>
</examples>
<remarks>
<remark>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.</remark>
</remarks>
<arguments>
<argument token="L" description="the list of CVARs"/>
<argument token="A" description="the alias to store them in"/>
</arguments>
<references>
<identifierReference identifier="getvar"/>
</references>
</command>
</identifiers>
</section>