Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] A few questions regarding the configuration language

#1
Hello!

Today I was playing with the game configuration/console, I've got most of the reference for the syntax and command from "Console Tips & Tricks".

Does the language used by the configuration have a name? Is there some actual documentation for it?

I've noticed that variables act weirdly inside aliases, it appears that they are not updated as soon as a new value is assigned to them.
The following code demonstrates that:
Code:
alias test1 "set param $1; echo $1 - $param;";
Calling test1 with some parameter will reveal that $param keeps old values, while $1 is correct.
I've found that this can be solved in the following way:
Code:
alias test2a "echo $1 - $param;";
alias test2 "set param $1; test2a $1";
It seems weird enough to me.
I'm new to this so maybe I'm not using set properly, is there some other way to have (local) variables?
Reply

#2
Hi! Thanks for your interest in the Xonotic console, I think it's wonderful to play with.

First of all, there is no name for the language. It's very generic and doesn't have a lot of features in itself.

The behavior you describe is nothing surprising once you know how the variable expansion is done: the variables are expanded for the entire compound command (i.e. for all the commands separated by semicolons) before it is interpreted. If we imagine that we set $param to "bar" before calling your alias as "test1 foo", the resulting command is
Code:
set param foo; echo foo - bar;
The workaround you suggest is the proper way to get the behaviour you want: $param is expanded in test2a only after it is set by test2.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#3
Thanks for the info.

I've been able to recreate some higher level control structure so I guess it's Turing complete at least.

I have a few more questions though.

Is it possible to make a defition of an alias spread across multiple lines?
Something like the following does not seem to work:
Code:
alias foo "echo hello;
echo world"

Is it possible to defer variable expansion?
I've implemented a for loop and I'd like more to be able to use
Code:
for i 0 10 echo $i
rather than
Code:
alias for_body echo $i
for i 0 10 for_body
Reply

#4
It is Turing complete indeed!

You can defer variable expansion, yes. You just need to escape the $ by doubling it.

Here's a subtle detail you should note to help you make sense out of this all: "alias" lines receive a special treatment. When a command starts (excepting whitespace) with alias, no variable expansion is done on the arguments. That is why you can simply do
Code:
alias foo echo $bar
and $bar will only be expanded when calling foo. That's a behavior specific to alias. To circumvent that and make expansion work the same as in other commands, you can put alias between quotes:
Code:
"alias" foo echo $bar
and the alias will include the value of the referenced variable at definition time.

That means the following two commands are equivalent:
Code:
alias foo echo $bar
"alias" foo echo $$bar



EDIT: I'll also mention Blub's contribution to console scripting from a few years ago (2008!). He basically implemented an instruction set based on x86! He then implemented a few constructs such as a for loop using that new language. You can find the old thread here: http://www.alienTRAP.org/archive/forum/v...php?t=2875
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#5
Thanks again!

Playing with the console is kinda fun.

I hope now that I'll keep playing with the shooter as well Wink

One last question: is it possible to extract a character from a string? (By random access, trimming the string or with some other method)
Reply

#6
That's not possible, unfortunately.

You can extract only substrings from the beginning of a string, but not in the middle. This is done using the one-string sprintf from the set of rpn commands, and taking advantage of the precision for string specifiers. Example:
Code:
menu_cmd rpn /abcdefg /%.3s sprintf1s
leaves "abc" on the stack. To store the three first characters of $foo into $result, this becomes
Code:
set foo abcdefg
menu_cmd rpn /result /foo load /%.3s sprintf1s def
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#7
Good enough. Thanks!
Reply

#8
Rainbow 
I've kept playing with this and found a way to get a specific character from a string.
After tons of alias hacks now I have a colorful chat, kida like Mario.
SmileSmileSmile
Reply

#9
Really? Can you share it?
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#10
Sure.

A few things to note:
  • I didn't manage to manage spaces correctly, so mb_print it will output only the first word
  • Performance are not the best
  • The function that extracts characters is a really bad hack, as such it works only with ASCII and it's a performance bottleneck
  • for cannot be nested because it uses global variabless
  • mb_ is a namespace, all aliases and most variables have that prefix
  • I'm performing string comparisong using the CRC codes because I didn't find a better way to check if two strings are equal
  • The first few lines are comments describing the synopsis of the high level commands
Code:
// if:
// mb_if      boolean {if true}
// mb_if_else boolean "if true" "if false"
// mb_if_cmp  value operator value {if true}    //eg: mb_if_cmp x < y echo Yep

// for:
// mb_for identifier number_min number_max {block}

// mb_hue: sets $cvar_name to a string in the form "^xfff". integer must be in [0-360]
// mb_hue integer cvar_name

// strlen: sets the length of a strong in the cvar $mb_strlen_count
// mb_strlen "string"

// mb_string_ch: get a character of a string (ASCII only) in the cvar $mb_string_ch_result
// mb_string_ch index "string"

// mb_print: echo and say a colorful string
// mb_print "string"

alias mb_noop ""
set mb_if_condition ""
alias mb_if_else "set mb_if_condition $1; toggle mb_if_condition; alias mb_if_action0 $2; alias mb_if_action1 $3;  mb_if_execute "              
alias mb_if "set mb_if_condition $1; toggle mb_if_condition; alias mb_if_action0 ${2-}; alias mb_if_action1 mb_noop;  mb_if_execute "              
alias mb_if_execute "mb_if_action${mb_if_condition}"
alias mb_if_cmp "rpn /mb_if_condition $1 $3 $2 =; alias mb_if_action1 ${4-}; alias mb_if_action0 mb_noop;  mb_if_execute "

alias mb_for "set mb_for_counter $2; set mb_for_max $3; mb_for_recurse $1 ${4- asis};"
alias mb_for_recurse "set $1 $mb_for_counter; rpn /mb_for_counter /mb_for_counter load 1 + =; ${2- asis}; mb_for_tail_recurse ${1- asis}"
alias mb_for_tail_recurse "rpn /mb_for_condition /mb_for_counter load /mb_for_max load < =; mb_for_tail_recurse_if ${1- asis}"
alias mb_for_tail_recurse_if "mb_if $mb_for_condition mb_for_recurse ${1- asis}"


set mb_hex10 "a"
set mb_hex11 "b"
set mb_hex12 "c"
set mb_hex13 "d"
set mb_hex14 "e"
set mb_hex15 "f"
alias mb_float2hex_4 "set $1 ${$mb_float2hex_digit}"
alias mb_float2hex_3 "set mb_float2hex_digit mb_hex${$1}; mb_float2hex_4 $1"
alias mb_float2hex_2 "alias mb_if_action0 set $1 $mb_float2hex_digit; alias mb_if_action1 mb_float2hex_3 $1;  mb_if_execute"
alias mb_float2hex_1 "set mb_float2hex_digit ${$1}; rpn /mb_if_condition /$1 load 10 >= =; mb_float2hex_2 $1"
alias mb_float2hex "rpn /$1 dup load floor =; mb_float2hex_1 $1"

alias mb_hue_result_1 "set $1 ^x$mb_hue_r$mb_hue_g$mb_hue_b"
alias mb_hue_result "mb_float2hex mb_hue_r; mb_float2hex mb_hue_g; mb_float2hex mb_hue_b; mb_hue_result_1 ${*}"
alias mb_hue_60 "set mb_hue_r 15; set mb_hue_b 0; rpn /mb_hue_g $1 15 * 60 / =; mb_hue_result ${2-}"
alias mb_hue_120 "set mb_hue_g 15; set mb_hue_b 0; rpn /mb_hue_r 15 $1 60 - 15 * 60 / - =; mb_hue_result ${2-}"
alias mb_hue_180 "set mb_hue_g 15; set mb_hue_r 0; rpn /mb_hue_b $1 120 - 15 * 60 / =; mb_hue_result ${2-}"
alias mb_hue_240 "set mb_hue_b 15; set mb_hue_r 0; rpn /mb_hue_g 15 $1 180 - 15 * 60 / - =; mb_hue_result ${2-}"
alias mb_hue_300 "set mb_hue_b 15; set mb_hue_g 0; rpn /mb_hue_r $1 240 - 15 * 60 / =; mb_hue_result ${2-}"
alias mb_hue_360 "set mb_hue_r 15; set mb_hue_g 0; rpn /mb_hue_b 15 $1 300 - 15 * 60 / - =; mb_hue_result ${2-}"
alias mb_hue_call "$mb_hue_callee ${*}"
alias mb_hue_switch "set mb_hue_callee mb_hue_$mb_hue_which; mb_hue_call ${*}"
alias mb_hue "rpn /mb_hue_which 60 120 180 240 300 360 $1 300 < when $1 240 < when $1 180 < when $1 120 < when $1 60 <  when =; mb_hue_switch ${*}"


alias mb_strlen_end ""
alias mb_strlen_recurse_tail "mb_if_else $mb_if_condition mb_strlen_do mb_strlen_end"
alias mb_strlen_recurse "rpn /mb_if_condition /mb_strlen_string1 load crc16 /mb_strlen_string load crc16 != =; mb_strlen_recurse_tail"
alias mb_strlen_substr "rpn /mb_strlen_string1 /mb_strlen_string load /%.${mb_strlen_count}s sprintf1s =; mb_strlen_recurse"
alias mb_strlen_do "rpn /mb_strlen_count dup load 1 + =; mb_strlen_substr"
alias mb_strlen "set mb_strlen_string ${* asis};" set mb_strlen_string1 "." "; set mb_strlen_count 0; mb_strlen_recurse"


set mb_ascii_opt_0 "_"
set mb_ascii_opt_1 "e"
set mb_ascii_opt_2 "t"
set mb_ascii_opt_3 "a"
set mb_ascii_opt_4 "o"
set mb_ascii_opt_5 "i"
set mb_ascii_opt_6 "n"
set mb_ascii_opt_7 "s"
set mb_ascii_opt_8 "h"
set mb_ascii_opt_9 "r"
set mb_ascii_opt_10 "d"
set mb_ascii_opt_11 "l"
set mb_ascii_opt_12 "c"
set mb_ascii_opt_13 "u"
set mb_ascii_opt_14 "T"
set mb_ascii_opt_15 "A"
set mb_ascii_opt_16 "S"
set mb_ascii_opt_17 "H"
set mb_ascii_opt_18 "W"
set mb_ascii_opt_19 "I"
set mb_ascii_opt_20 "O"
set mb_ascii_opt_21 "B"
set mb_ascii_opt_22 "M"
set mb_ascii_opt_23 "F"
set mb_ascii_opt_24 "C"
set mb_ascii_opt_25 "m"
set mb_ascii_opt_26 "w"
set mb_ascii_opt_27 "f"
set mb_ascii_opt_28 "g"
set mb_ascii_opt_29 "y"
set mb_ascii_opt_30 "p"
set mb_ascii_opt_31 "b"
set mb_ascii_opt_32 "v"
set mb_ascii_opt_33 "k"
set mb_ascii_opt_34 "j"
set mb_ascii_opt_35 "x"
set mb_ascii_opt_36 "q"
set mb_ascii_opt_37 "z"
set mb_ascii_opt_38 "L"
set mb_ascii_opt_39 "D"
set mb_ascii_opt_40 "P"
set mb_ascii_opt_41 "N"
set mb_ascii_opt_42 "E"
set mb_ascii_opt_43 "G"
set mb_ascii_opt_44 "R"
set mb_ascii_opt_45 "Y"
set mb_ascii_opt_46 "U"
set mb_ascii_opt_47 "V"
set mb_ascii_opt_48 "J"
set mb_ascii_opt_49 "K"
set mb_ascii_opt_50 "Q"
set mb_ascii_opt_51 "X"
set mb_ascii_opt_52 "Z"
set mb_ascii_opt_53 "!"
set mb_ascii_opt_54 "?"
set mb_ascii_opt_55 "."
set mb_ascii_opt_56 "0"
set mb_ascii_opt_57 "1"
set mb_ascii_opt_58 "2"
set mb_ascii_opt_59 "3"
set mb_ascii_opt_60 "4"
set mb_ascii_opt_61 "5"
set mb_ascii_opt_62 "6"
set mb_ascii_opt_63 "7"
set mb_ascii_opt_64 "8"
set mb_ascii_opt_65 "9"
set mb_ascii_opt_66 " "
set mb_ascii_opt_67 "\"" //"
set mb_ascii_opt_68 "#"
set mb_ascii_opt_69 "$$"
set mb_ascii_opt_70 "%"
set mb_ascii_opt_71 "&"
set mb_ascii_opt_72 "'"
set mb_ascii_opt_73 "("
set mb_ascii_opt_74 ")"
set mb_ascii_opt_75 "*"
set mb_ascii_opt_76 "+"
set mb_ascii_opt_77 ","
set mb_ascii_opt_78 "-"
set mb_ascii_opt_79 "/"
set mb_ascii_opt_80 "@"
set mb_ascii_opt_81 "["
set mb_ascii_opt_82 "\\"
set mb_ascii_opt_83 "]"
set mb_ascii_opt_84 "^"
set mb_ascii_opt_85 "{"
set mb_ascii_opt_86 "|"
set mb_ascii_opt_87 "}"
set mb_ascii_opt_88 "~"
set mb_ascii_opt_89 ":"
set mb_ascii_opt_90 ";"
set mb_ascii_opt_91 "<"
set mb_ascii_opt_92 "="
set mb_ascii_opt_93 ">"

alias mb_string_ch_recurse_check "mb_if $mb_if_condition mb_string_ch_set_first"
alias mb_string_ch_recurse "rpn /mb_if_condition /mb_string_ch_target load 0 > = /mb_string_ch_target dup load 1 - =; mb_string_ch_recurse_check"
alias mb_string_ch_set_result_if_body "set mb_string_ch_result ${$mb_string_ch_nextchar}; set mb_for_counter 999"
alias mb_string_ch_set_result "mb_if $mb_if_condition mb_string_ch_set_result_if_body"
alias mb_string_ch_check "rpn /mb_if_condition /mb_string_ch_match_1 load crc16 /mb_string_ch_match_2 load crc16 == =; mb_string_ch_set_result"
alias mb_string_ch_check_set "set mb_string_ch_match_1 $mb_string_ch_firstchar${$mb_string_ch_nextchar}; rpn /mb_string_ch_match_2 /mb_string_ch_str load /%.${mb_string_ch_index}s sprintf1s =; mb_string_ch_check"
alias mb_string_ch_loop_body "set mb_string_ch_nextchar mb_ascii_opt_$mb_string_ch_i; mb_string_ch_check_set"
alias mb_string_ch_loop "mb_for mb_string_ch_i 0 93 mb_string_ch_loop_body"
alias mb_string_ch_set_first "rpn /mb_string_ch_firstchar /mb_string_ch_str load /%.${mb_string_ch_index}s sprintf1s = /mb_string_ch_index dup load 1 + =; mb_string_ch_loop; mb_string_ch_recurse"
alias mb_string_ch_check_0_if_exit rpn /mb_string_ch_result /mb_string_ch_str load /%.1s sprintf1s =
alias mb_string_ch_check_0_if "mb_if_else $mb_if_confition mb_string_ch_check_0_if_exit mb_string_ch_set_first"
alias mb_string_ch_check_0 "rpn /mb_if_confition /mb_string_ch_target load 0 < =; mb_string_ch_check_0_if"
alias mb_string_ch "set mb_string_ch_str ${2-}; set mb_string_ch_index 1; rpn /mb_string_ch_target $1 1 - =; mb_string_ch_check_0"


// todo generic nestable for
alias mb_forX "set mb_for_counterX $2; set mb_for_maxX $3; mb_for_recurseX $1 ${4- asis};"
alias mb_for_recurseX "set $1 $mb_for_counterX set mb_for_conditionX 0; rpn /mb_for_conditionX /mb_for_counterX load /mb_for_maxX load < =; alias mb_for_executeX ${2- asis}; mb_for_executeX; rpn /mb_for_counterX /mb_for_counterX load 1 + =; mb_for_tail_recurseX ${1- asis}"
alias mb_for_tail_recurseX "mb_if $mb_for_conditionX mb_for_recurseX ${1- asis}"

alias mb_print_echo "echo $mb_print_result; say $mb_print_result"
alias mb_print_loop_add_character "set mb_print_result $mb_print_result$mb_print_hue_str$mb_string_ch_result"
//alias mb_print_loop_add_space set mb_print_result "${mb_print_result} $mb_print_hue_str"
//alias mb_print_replace_underscore_if mb_if_else $mb_if_condition mb_print_loop_add_space mb_print_loop_add_character
//alias mb_print_replace_underscore "rpn /mb_if_condition /mb_string_ch_result load crc16 /_ crc16 == =; mb_print_replace_underscore_if"
alias mb_print_loop_body_2 "mb_hue $mb_print_hue mb_print_hue_str; mb_print_loop_add_character; rpn /mb_print_hue dup load /mb_print_hue_step load + ="
alias mb_print_loop_body_1 "mb_string_ch $mb_print_i \"$mb_print_str\""
alias mb_print_loop_body "mb_print_loop_body_1; mb_print_loop_body_2"
alias mb_print_loop "mb_forX mb_print_i 0 $mb_print_sl mb_print_loop_body"
alias mb_print_counter_set "rpn /mb_print_sl /mb_strlen_count load 1 - =; rpn /mb_print_hue 0 =; rpn /mb_print_hue_step 360 /mb_strlen_count load / floor ="
alias mb_print_strlen "mb_strlen \"$mb_print_str\""
alias mb_print "set mb_print_result ^xf00; set mb_print_str ${*}; mb_print_strlen; mb_print_counter_set; mb_print_loop; mb_print_echo"
Reply

#11
Haha wow, heavy stuff! I'd need some time to read through that. I thought about bruteforcing like you do to get the character, but I thought it would not be worth the effort to implement it. But I still love that you did it.

As for string comparison, there are two implementations of it in blub's vmutil.cfg. Say you have two strings, $1 and $2. The first way is to define alias strcmp_$1 to set a result variable to false, and strcmp_$2 to set that variable to true. Then, you call strcmp_$1. If the strings are the same, the result will be true. You can use unalias to avoid polluting the namespace.

The second way is to take advantage of the toggle command with arguments. Modifying the original implementation a bit to cut the x86 stuff:
Code:
alias strcmp "set result \"_$1\"; toggle result 0 \"_$2\" 1"
If $1 is equal to $2, toggle will cycle the value of result to 1. If not, it will use the first value of the 0, _$2, 1 cycle which is 0. The underscore is to avoid the case where $1 or $2 are "0" or "1".
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#12
That's interesting, is there anywhere some exaustive reference for all the built-in commands? help is not really helpful...
I've never seen a scripting language that's so low level, lower level than x86 assembly as it seems. It's kinda fun to write stuff in it though.
Reply

#13
Unfortunately I don't think there's a reference for those. You can use "cmdlist" but that will give you a ton of useless commands in the bunch. "apropos" is an interesting one when it comes to help: it searches in descriptions of commands and variables.
[Image:http://i.imgur.com/4XODR.png]640K ought to be enough for anybody.
     ― Linux Torvalds
Reply

#14
Congratulations! You just passed the test for the

divVerent Certified Xonotic Console Expert (DCXCE)

Your badge will soon be provided.
BRLOGENSHFEGLE (core dumped)

The Bot Orchestra is back! | Xoylent Easter Egg | 5bots1piano
My music on Google Play and SoundCloud
Reply

#15
Ha, silly me. I was calculating all the n characters when calling mb_string_ch n "foo".
Now it's much better. I've also fixed the space bug.

mb_string_ch:
Code:
alias mb_string_ch_set_result_if_body "set mb_string_ch_result \"${$mb_string_ch_nextchar}\"; set mb_for_counter 999"
alias mb_string_ch_set_result "mb_if $mb_streq_result mb_string_ch_set_result_if_body"
alias mb_string_ch_check " mb_streq \"$mb_string_ch_match_1\" \"$mb_string_ch_match_2\"; mb_string_ch_set_result"
alias mb_string_ch_check_set "set mb_string_ch_match_1 \"$mb_string_ch_firstchar${$mb_string_ch_nextchar}\"; rpn /mb_string_ch_match_2 /mb_string_ch_str load /%.${mb_string_ch_index}s sprintf1s =; mb_string_ch_check"
alias mb_string_ch_loop_body "set mb_string_ch_nextchar mb_ascii_opt_$mb_string_ch_i; mb_string_ch_check_set"
alias mb_string_ch_loop "mb_for mb_string_ch_i 0 93 mb_string_ch_loop_body"
alias mb_string_ch_set_first "rpn /mb_string_ch_firstchar /mb_string_ch_str load /%.${mb_string_ch_index}s sprintf1s = /mb_string_ch_index dup load 1 + =; mb_string_ch_loop; "
alias mb_string_ch_check_0_if_exit rpn /mb_string_ch_result /mb_string_ch_str load /%.1s sprintf1s =
alias mb_string_ch_check_0_if "mb_if_else $mb_if_condition mb_string_ch_check_0_if_exit mb_string_ch_set_first"
alias mb_string_ch_check_0 "rpn /mb_if_condition /mb_string_ch_index load 0 < =; mb_string_ch_check_0_if"
alias mb_string_ch "set mb_string_ch_str ${2- asis};  rpn /mb_string_ch_index $1 =; mb_string_ch_check_0"

mb_print:
Code:
alias mb_print_say "say $mb_print_result"
alias mb_print_echo "echo $mb_print_result"
alias mb_print_loop_add_character "set mb_print_result \"$mb_print_result$mb_print_hue_str$mb_string_ch_result\""
alias mb_print_loop_body_2 "mb_hue $mb_print_hue mb_print_hue_str; mb_print_loop_add_character; rpn /mb_print_hue dup load /mb_print_hue_step load + ="
alias mb_print_loop_body_1 "mb_string_ch $mb_print_i \"$mb_print_str\""
alias mb_print_loop_body "mb_print_loop_body_1; mb_print_loop_body_2"
alias mb_print_loop "mb_forX mb_print_i 0 $mb_print_sl mb_print_loop_body"
alias mb_print_counter_set "rpn /mb_print_sl /mb_strlen_count load 1 - =; rpn /mb_print_hue 0 =; rpn /mb_print_hue_step 360 /mb_strlen_count load / floor ="
alias mb_print_strlen "mb_strlen \"$mb_print_str\""
alias mb_print_setup "set mb_print_result ^xf00; set mb_print_str ${*}; mb_print_strlen; mb_print_counter_set; mb_print_loop;"
alias mb_print "mb_print_setup ${*}; mb_print_echo; mb_print_say"
alias mb_echo "mb_print_setup ${*}; mb_print_echo"
alias mb_say "mb_print_setup ${*}; mb_print_say"

Scripting the Xonotic console has enough complexity and fun that I've set up a git repo for this.
Reply

#16
(08-29-2013, 11:54 PM)Melanosuchus Wrote: Ha, silly me. I was calculating all the n characters when calling mb_string_ch n "foo".
Now it's much better. I've also fixed the space bug.

mb_string_ch:
Code:
alias mb_string_ch_set_result_if_body "set mb_string_ch_result \"${$mb_string_ch_nextchar}\"; set mb_for_counter 999"
alias mb_string_ch_set_result "mb_if $mb_streq_result mb_string_ch_set_result_if_body"
alias mb_string_ch_check " mb_streq \"$mb_string_ch_match_1\" \"$mb_string_ch_match_2\"; mb_string_ch_set_result"
alias mb_string_ch_check_set "set mb_string_ch_match_1 \"$mb_string_ch_firstchar${$mb_string_ch_nextchar}\"; rpn /mb_string_ch_match_2 /mb_string_ch_str load /%.${mb_string_ch_index}s sprintf1s =; mb_string_ch_check"
alias mb_string_ch_loop_body "set mb_string_ch_nextchar mb_ascii_opt_$mb_string_ch_i; mb_string_ch_check_set"
alias mb_string_ch_loop "mb_for mb_string_ch_i 0 93 mb_string_ch_loop_body"
alias mb_string_ch_set_first "rpn /mb_string_ch_firstchar /mb_string_ch_str load /%.${mb_string_ch_index}s sprintf1s = /mb_string_ch_index dup load 1 + =; mb_string_ch_loop; "
alias mb_string_ch_check_0_if_exit rpn /mb_string_ch_result /mb_string_ch_str load /%.1s sprintf1s =
alias mb_string_ch_check_0_if "mb_if_else $mb_if_condition mb_string_ch_check_0_if_exit mb_string_ch_set_first"
alias mb_string_ch_check_0 "rpn /mb_if_condition /mb_string_ch_index load 0 < =; mb_string_ch_check_0_if"
alias mb_string_ch "set mb_string_ch_str ${2- asis};  rpn /mb_string_ch_index $1 =; mb_string_ch_check_0"

mb_print:
Code:
alias mb_print_say "say $mb_print_result"
alias mb_print_echo "echo $mb_print_result"
alias mb_print_loop_add_character "set mb_print_result \"$mb_print_result$mb_print_hue_str$mb_string_ch_result\""
alias mb_print_loop_body_2 "mb_hue $mb_print_hue mb_print_hue_str; mb_print_loop_add_character; rpn /mb_print_hue dup load /mb_print_hue_step load + ="
alias mb_print_loop_body_1 "mb_string_ch $mb_print_i \"$mb_print_str\""
alias mb_print_loop_body "mb_print_loop_body_1; mb_print_loop_body_2"
alias mb_print_loop "mb_forX mb_print_i 0 $mb_print_sl mb_print_loop_body"
alias mb_print_counter_set "rpn /mb_print_sl /mb_strlen_count load 1 - =; rpn /mb_print_hue 0 =; rpn /mb_print_hue_step 360 /mb_strlen_count load / floor ="
alias mb_print_strlen "mb_strlen \"$mb_print_str\""
alias mb_print_setup "set mb_print_result ^xf00; set mb_print_str ${*}; mb_print_strlen; mb_print_counter_set; mb_print_loop;"
alias mb_print "mb_print_setup ${*}; mb_print_echo; mb_print_say"
alias mb_echo "mb_print_setup ${*}; mb_print_echo"
alias mb_say "mb_print_setup ${*}; mb_print_say"

Scripting the Xonotic console has enough complexity and fun that I've set up a git repo for this.

[Image: 862c968ad1ab5cbd678155192b255f5d.png]
BRLOGENSHFEGLE (core dumped)

The Bot Orchestra is back! | Xoylent Easter Egg | 5bots1piano
My music on Google Play and SoundCloud
Reply

#17
A couple of other players are using my script for colored chat. I'll start a thread focused on that.
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  What's your Hotkey/HUD Configuration Mirio 113 87,272 12-25-2018, 05:37 PM
Last Post: Wolf-Snipe
Information Trackball configuration TrackBallUser 4 1,206 02-09-2018, 12:51 AM
Last Post: Smilecythe
  Newbie questions Matadula 7 2,061 07-29-2017, 03:09 AM
Last Post: Smilecythe
  Questions about moovie making. Andrii 8 4,543 03-28-2014, 07:21 PM
Last Post: Andrii
  Help with game configuration. Andrii 7 6,295 02-18-2014, 03:39 PM
Last Post: kojn^
  decent configuration maquejode 1 2,939 08-19-2012, 02:02 PM
Last Post: edh

Forum Jump:


Users browsing this thread:
1 Guest(s)

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