User panel stuff on forum
  1 post on 1 page  1
Advanced Configuration
2013-12-10, 11:16
Member
1 post

Registered:
Dec 2013
After some 15 odd years I decided to look back into QW. I'm happy to see this game is still alive, and that the client has come a long way.

I played around with making a new config yesterday, to achieve what I had back when I was playing. I'm also happy to see that script language and it's underlying features has been extended a lot (even includes a regex engine!)

I ran into an issue with the if statement. I thought I'd ask here before taking this up with the dev(s), since it might just be me missing something, but:

The documentation http://ezquake.sourceforge.net/docs/?scripting#advanced specifies the if syntax as follows:
if (<condition1> then <commands> [else <commands>]
where <commands> is a command or ;-separated list of commands.

Issues with this I found is that there is 1) no unique symbol to close the conditional block, 2) ; closes the conditional block, 3) I have found no way to group commands inline.

1) would lead to an ambiguous parse tree if it wasn't for 2), but 2) makes the documentation wrong. 3) could mediate both issues, but I found nothing of the sort in the documentation, save making aliases.

Example:

set x 10
bind u "if ($x > 5 && $x < 20) then echo bigger than 5;echo smaller than 20"

The last statement has an ambiguous parse tree since is it not clear whether "echo smaller than 20" belongs in the conditional block or after it.
Since ; closes the conditional block, it is executed after it, so "smaller than 20" gets printed no matter the value of x. But this means that <commands> cannot be a ;-separated list of commands, invalidating the documentation

how a unique symbol (end) (1) resolves this issue:
bind u "if ($x > 5 && $x < 20) then echo bigger than 5; echo smaller than 20; end echo you pressed u"
how a command grouping/block (3) (unsupported, as far as I can tell) resolves this issue:
bind u "if ($x > 5 && $x < 20) then { echo bigger than 5; echo smaller than 20; } echo you pressed u"

what I did to resolve this in my use case was:
alias commandgroup "echo bigger than 5; echo smaller than 20"
bind u "if ($x > 5 && $x < 20) then commandgroup; echo you pressed u"

So am I missing some nuance/feature of the language here, or is this how this is done? Is there a way to group commands (3) that I have not discovered, like some way of escaping quotes for nesting?
  1 post on 1 page  1