(This is another bind-related topic, I put it here because I did not find a subforum better suited for this topic. If I am wrong, any moderator may feel free to move this topic.)
Some of you may have witnessed people standing near the armoury and obviously switchting from one weapon to another. Then you may have thought, Wow, cool, there is a bind where you can cycle through weapons, and then desperately tried to find it.
Stop searching. There IS NO such command.
In fact, if you want to achieve such an effect, you have to use the vstr-command in your bindings. A vstr now is nothing else then a string-definition,
set FOO "echo hello world"
bind x "vstr FOO"
will do the same like
bind x "echo hello world"
Doesn't seem to be very useful, but exactly this command allows you "cycling" effects. For instance, if you want to cycle through the commands "build mgturret","build armory" and "build medistat" with one single key, you can do this via
bind x "vstr buildret"
set buildret "build mgturret; bind x vstr buildarm"
set buildarm "build armory; bind x vstr buildmedi"
set buildmedi "build medistat; bind x vstr buildret"
If you now insert this code into your binds, are a builder, and push the x-xutton, that button will cycle through the respective commands.
Because this is a bit inconvenient to hardcode, above all else this code is a pain in the ass to maintain (if you want to change the order of the commands etc.) so I wrote a small python-script that does exactly this for you:
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
# first, the "library"
def vstrname(thekey):
"return the name of the vstr associatable to thekey"
return("_BIND_"+thekey+"_")
def bind(thekey,thesequence):
"""
generate a tremulous-bind,
bind thekey to thesequence
if thesequence is an array, the FIRST value of thesequence
will be used as the default setting for that key
This function assumes that you will NOT use a ; at the end of a bind!
"""
if type(thesequence)!=list:
result='bind '+thekey+' "'+thesequence+'"'
else:
if len(thesequence)==1:
bind(thekey,thesequence[0])
return()
#else:
myvstr=vstrname(thekey)
mylen=len(thesequence)
result = 'bind '+thekey+' "vstr '+myvstr+'0"'
for i in range(mylen):
result += '\nset '+myvstr+str(i)+' "'+thesequence[i]+'; bind '+thekey+' vstr '+myvstr+str((i+1)%mylen)+'"'
print(result)
You now can push this code into a python-interpreter and then add the following command:
bind("x",["build mgturret","build armory","build medistat"])
And voila!, this is the result:
bind x "vstr _BIND_x_0"
set _BIND_x_0 "build mgturret; bind x vstr _BIND_x_1"
set _BIND_x_1 "build armory; bind x vstr _BIND_x_2"
set _BIND_x_2 "build medistat; bind x vstr _BIND_x_0"
Personally, I of course more sophisticated binds, so the code I use myself is:
structure_binds=[
"echo - turret -; build mgturret; bind MWHEELDOWN build mgturret",
"echo - armory -; build arm; bind MWHEELDOWN build arm",
"echo - telenode -; build telenode; bind MWHEELDOWN build telenode",
"echo - medistation -; build medistat; bind MWHEELDOWN build medistat",
"echo - defence computer -; build dcc; bind MWHEELDOWN build dcc",
"echo - tesla generator -; build tesla; bind MWHEELDOWN build tesla",
"echo - repeater -; build repeater; bind MWHEELDOWN build repeater"
]
bind("0","vstr "+vstrname("x")+"; class ackit; class ckit; sell weapons; buy ackit; buy ckit")
bind("x",structure_binds)
but this is entirely up to you.