removing getvar in favor of having getalias work on both aliases and built-in client variables (fov), and execute & return commands

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6594 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Bukz
2011-08-19 01:43:54 +00:00
parent 2fc6596eb8
commit f3b2c09d98
5 changed files with 76 additions and 19 deletions
+1 -1
View File
@@ -101,7 +101,6 @@ CubeScript
[*] delmenu - Deletes all of the menu items in the specified menu.
[*] akimboautoswitch - Enables or disables automatically switching to akimbo upon pickup. (regardless of current weapon)
[*] add2list - Appends a new element to a list. (Exactly like add2alias, simply without the additional ";")
[*] getvar - Gets the current value of a CVAR. (client variable)
[*] isIdent - Determines if the argument given is a built-in identifier.
[*] isSpect - Determines if you are in any form of spectating (team, or singleplayer "fly")
[*] inWater - Determines if you are standing or submerged in water.
@@ -178,6 +177,7 @@ CubeScript
[*] gametimestart - Returns the time (in milliseconds) when the last map was loaded.
[*] mapbackupsonsave - Determines if map backups (.bak) should be created when a map is saved.
[*] isclient - Determines if the client number given is a valid client (player).
[*] getalias can now work on built-in client variables (CVARs). - (e.g. fov)
[*] "Sleeps" can be persistent. (e.g. "Persist" even through map loads - new optional 3rd argument of the /sleep command)
[*] Substr crash bug is fixed. Also the command can now use a negative position value.
[*] New stat in (pstat_score) for teamkills. New list is: FLAGS FRAGS DEATHS POINTS TEAM TEAMKILLS NAME
+7 -3
View File
@@ -135,6 +135,11 @@ docargument [A] [action] [] [0];
docexample [p = 1; push p 2; echo $p] [Output: 2];
docident [result] [sets the result value of a CubeScript block];
docargument [R] [the result] [] [0];
docident [return] [sets the result value of a CubeScript block "(same as using result)"]
docargument [R] [the result] [] [0];
docident [execute] [Executes the specified string as CubeScript.];
docargument [S] [the string to execute] [] [0];
docexample [execute (concat echo (addpunct fov 3))] [Example output: 90.0];
docident [round] [Round a float and returns an integer];
docargument [F] [The float number to be rounded] [] [0];
docident [ceil] [Return the ceil value (integer) of a float];
@@ -193,11 +198,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];
docident [storesets] [Generates an alias (list) of the current values for the given aliases/CVARs.];
docargument [L] [the list of aliases/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".];
docremark [Some idents cannot be stored via this command "(e.g. curname)", if an argument is given that cannot be used, the command will throw an error to notify you.];
docident [onLastMin] [If this alias exists, it will be automatically executed on the last minute remaining mark.];
docident [akimboautoswitch] [Enables or disables automatic switching to the akimbo upon pickup.];
docargument [N] [enable or disable] [min 0/max 1/default 1] [0];
+4 -3
View File
@@ -7,6 +7,8 @@
// Note: The editent command can NOT define rotation/yaw inside the command!
// However, the current yaw of the player will define the rotation/yaw when
// using the command!
const return [ result $arg1 ]
const editent [
if (strcmp (getenttype) "mapmodel") [ saycommand "/entset" (getenttype) (getentattr 1) (getentattr 2) (getentattr 3) ] [
if (> (findlist "light sound clip plclip" (getenttype)) -1) [
@@ -332,14 +334,13 @@ const getscrext [
]
// storesets - Generates an alias (list) of the current values for the given CVARs.
const omit_idents "botsshoot curname curteam idlebots name"
const storesets [
if (> $numargs 1) [
badargs = 0; $arg2 = ""
loop ssl (listlen $arg1) [
if (&& (isIdent (at $arg1 $ssl)) (! (strstr $omit_idents (at $arg1 $ssl)))) [
add2list $arg2 (getvar (at $arg1 $ssl))
if (isIdent (at $arg1 $ssl)) [
add2list $arg2 (getalias (at $arg1 $ssl))
] [ badargs = 1; break ]
]
if $badargs [ delalias $arg2; echo (c 3)Error: (c 5)Bad "argument(s)" given! ]
+35 -8
View File
@@ -85,6 +85,34 @@
<arguments>
<argument token="R" description="the result"/>
</arguments>
<references>
<identifierReference identifier="execute"/>
<identifierReference identifier="return"/>
</references>
</command>
<command name="return">
<description>sets the result value of a CubeScript block</description>
<arguments>
<argument token="R" description="the result"/>
</arguments>
<references>
<identifierReference identifier="execute"/>
<identifierReference identifier="result"/>
</references>
</command>
<command name="execute">
<description>Executes the specified string as CubeScript.</description>
<arguments>
<argument token="S" description="the string to execute"/>
</arguments>
<examples>
<example>
<code><![CDATA[execute (concat echo (addpunct fov 3))]]></code>
<explanation>Example output: 90.0</explanation>
</example>
</examples>
</command>
<command name="push">
@@ -110,10 +138,12 @@
<argument token="N" description="alias name"/>
</arguments>
<references>
<identifierReference identifier="getvar"/>
<identifierReference identifier="storesets"/>
</references>
</command>
<!--
// (getalias) can not handle built-in client variables
<command name="getvar">
<description>return the value of the engine variable</description>
<arguments>
@@ -122,7 +152,7 @@
<references>
<identifierReference identifier="getalias"/>
</references>
</command>
</command>-->
<command name="isIdent">
<description>returns whether or not there is an identifier by that name</description>
@@ -809,22 +839,19 @@
</command>
<command name="storesets">
<description>Generates an alias (list) of the current values for the given CVARs.</description>
<description>Generates an alias (list) of the current values for the given aliases/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 an error to notify you.</remark>
</remarks>
<arguments>
<argument token="L" description="the list of CVARs"/>
<argument token="L" description="the list of aliases/CVARs"/>
<argument token="A" description="the alias to store them in"/>
</arguments>
<references>
<identifierReference identifier="getvar"/>
<identifierReference identifier="getalias"/>
</references>
</command>
+27 -2
View File
@@ -345,12 +345,36 @@ const char *getalias(const char *name)
}
void _getalias(char *name)
{
string o;
ident *id = idents->access(name);
const char *action = getalias(name);
if(id)
{
switch(id->type)
{
case ID_VAR:
formatstring(o)("%d", *id->storage.i);
result(o);
break;
case ID_FVAR:
formatstring(o)("%.3f", *id->storage.f);
result(o);
break;
case ID_SVAR:
formatstring(o)("%s", *id->storage.s);
result(o);
break;
case ID_ALIAS:
result(action ? action : "");
break;
default: break;
}
}
}
COMMANDN(getalias, _getalias, ARG_1STR);
void _getvar(char *name)
// (getalias) now handles client variables as well
/*void _getvar(char *name)
{
string resstr;
resstr[0] = '\0';
@@ -373,7 +397,7 @@ void _getvar(char *name)
}
result(resstr);
}
COMMANDN(getvar, _getvar, ARG_1STR);
COMMANDN(getvar, _getvar, ARG_1STR);*/
COMMANDN(isIdent, identexists, ARG_1EST);
bool addcommand(const char *name, void (*fun)(), int narg)
@@ -1319,6 +1343,7 @@ COMMAND(concat, ARG_CONC);
COMMAND(concatword, ARG_CONCW);
COMMAND(format, ARG_VARI);
COMMAND(result, ARG_1STR);
COMMAND(execute, ARG_1STR);
COMMAND(at, ARG_2STR);
COMMAND(listlen, ARG_1EST);
COMMAND(findlist, ARG_2STR);