Create an account


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Console Tips & Tricks

#26
I understand (i think) the logics, but fail with code, i tried ""bx_if_not_eq ${bx_weapon} blaster; bx_if_eq ${bx_weapon} blaster weaplast"" but failed
Reply

#27
Split your commands into parts and find out where they fail. Also keep in mind the console is retarded and broken in various ways - e.g. you can't set a cvar and read the new value in one alias - it'll keep using the old value presumably because cvar expansion happens too early. You have to split it into multiple aliases - this will first print old_value, then new_value:
Code:
set some_cvar old_value
alias step1 "set some_cvar new_value ; echo $some_cvar ; step2"
alias step2 "echo $some_cvar"

Another issue is that nested curly braces are broken so stuff like
Code:
${${1 !}}
won't work - again you have to split it into multiple steps.
[Image: 30381.jpg]

<packer> when i see martin-t's name my blood pressure increases

<[BOT]Hоtdоg> anyone here lives near martin?
<[BOT]Hоtdоg> will pay monies for shooting him
Reply

#28
Anyone knows how to scale the strafe hud? I lost my config and it used to be bigger than how it is now. It's very small to see currently.
Reply

#29
(02-13-2021, 09:15 AM)Aguaumreal Wrote: Anyone knows how to scale the strafe hud? I lost my config and it used to be bigger than how it is now. It's very small to see currently.

You can find many cvars for strafehud by typing hud_panel_strafehud and then TAB
[Image: 96798.jpg]
Reply

#30
thank you i kinda found it.
Reply

#31
Hi,

While looking at the commands related to demo recording I came across something interesting, a new variable function that's not mentioned in this guide, perhaps it was added later, I'm not sure about it's timeline. I'm talking about these expansion variable functions:
Quote:${4 ?} means the fourth parameter, or nothing if it wasn't passed.
${2 asis} means the second parameter, without escaping quotes (because by default they are escaped)
${* q}, ${1- q} means all the parameters as they were provided, escaped (spaces and quotes work)

In Xonotic "?", "asis", "q" and a new member to the family "!" (the exclamation mark, also know as bang) are collectively referred to as "variable function" (at least that's what the error messages call them Tongue ). They specify how to handle the expansion of arguments (passed to aliases) and cvars. While BlaXpirit has explained the behavior of first 3 of these variable functions, I'll try to explain the behavior of the 4th variable function.

The bang variable function throws detailed error message and aborts the execution of procedure/actions associated with it, when there is an expansion error (undefined cvar or an argument not passed to an alias etc). It has no effect on the input like the other 3 variable functions have.
Code:
// NOTE: "->" means it's console output.
// Cvar expansion, the greeting cvar is not defined
echo ${greeting};   // -> Warning: Could not expand $greeting
                    // -> $greeting
                    // echo command was still executed regardless of an expansion error.

echo ${greeting !}; // -> Error: Could not expand $greeting
                    // no output for the echo command as it was likely aborted.

// Alias parameter expansion
alias print "echo ${1- !}; echo SUCCESS"
print Hello Xonotic!; // -> Hello Xonotic!
                      // -> SUCCESS

print;                // -> Error: Could not expand $1- in alias print
                      // No SUCCESS was printed to the console.

This can be used to check if a cvar is defined in console namespace, like so:
Code:
// cvar_exists <identifier> <cvar-name>
alias cvar_exists     "set ${1 !} \"0\"; set __cvar_exists_cvar_name__ \"${2 !}\"; __cvar_exists__ ${1}"
alias __cvar_exists__ "${1 !} 1; set __tmp_data__ \"${$__cvar_exists_cvar_name__ !}\""

// the procedures/actions in __cvar_exists__ alias only get executed when the expansion is successful, thus
// the <identifier> is set to 1 on expansion success, otherwise it remains 0. Effectively letting us know, if
// the cvar is defined or not, this can then be combined with rest of the console tricks to perform action based
// on the existence of certain cvars.

// Usage example:
cvar_exists result1 _cl_name      // result1 contains 1; it exists and contains your player nick
cvar_exists result2 _uncle_roger  // result2 contains 0; does not exists/ is not defined, it will also output an error message
                                  //                     which can be ignored.

That's all, thanks to BlaXpirit for his awesome guide.
Keep fragging! erebus
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Console Commands Tutorial Beagle 4 15,084 03-10-2016, 05:53 PM
Last Post: -z-
  kojns video tips and creation thread kojn^ 10 16,340 03-03-2014, 03:11 PM
Last Post: deoxys
  Disabling console print in upper-left corner Zxen 4 8,532 12-11-2012, 06:43 PM
Last Post: s1lence
  Video Creation Tips & Tricks Antibody 10 30,453 11-07-2012, 12:33 PM
Last Post: rocknroll237

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-