diff --git a/changelog.txt b/changelog.txt index 5dc6bf02..94b565ba 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/config/docs.cfg b/config/docs.cfg index 7e108610..ec47e934 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -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]; diff --git a/config/scripts.cfg b/config/scripts.cfg index 5e99878e..9b4ac7a7 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -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! ] diff --git a/docs/reference.xml b/docs/reference.xml index 65aec34a..4034b5f2 100644 --- a/docs/reference.xml +++ b/docs/reference.xml @@ -85,7 +85,35 @@ + + + + + + + sets the result value of a CubeScript block + + + + + + + + + + + Executes the specified string as CubeScript. + + + + + + + Example output: 90.0 + + + Temporarily redefines the value of an alias. @@ -110,11 +138,13 @@ - + - + returns whether or not there is an identifier by that name @@ -809,22 +839,19 @@ - Generates an alias (list) of the current values for the given CVARs. + Generates an alias (list) of the current values for the given aliases/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 an error to notify you. - - + - + diff --git a/source/src/command.cpp b/source/src/command.cpp index a3f13442..d94ea229 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -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); - result(action ? action : ""); + 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);