voltron
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Chat generator for tremulous (primary for volt's HUD)
#+TITLE:    Using of voltron
#+AUTHOR:   Olexandr Sydorchuk
#+EMAIL:    olexandr_syd [at] users.sourceforge.net
#+STARTUP:  showall

* Overview

  Voltron is generator of chatmenu for different HUDs of several games
  (primary for tremulous and [[http://tremulous.net/forum/index.php?topic=8699.0][Volt  HUD]] [fn:1]). Also allow you add own
  binds into config  file, create message list and  auto split file if
  need.

** Basic Usage:
   You need  to have  tcl to use  voltron. Created configure  file you
   must pass to voltron:

  #+begin_example
%tclsh voltron.tcl yourconfig
  #+end_example

   You can  use sample  configure file [[http://github.com/osv/voltron/blob/master/volt.config.tcl.sample][volt.config.tcl.sample]]  as your
   base configure file. Other example file you can find [[http://github.com/osv/config_files/tree/master/.tremulous/base/scr/][here]].

* Creating chat menu
  Configure file is  [[http://www.tcl.tk][tcl]] source file. But don't  worry, you don't need
  to learn this language for creating your menus.  Below is example of
  simple menu:

#+begin_src tcl -n -r
set snd_menuoff sound/misc/menu3
set snd_menuon  sound/misc/menu1.wav

set 1. {
    {}			{play $snd_menuon}      (ref:all1)
    {Evolve "Evolve to:"} {}			(ref:evolve) (ref:ali1)
    {Buy "Buy:"} {}				(ref:hum1)
    {} {}					(ref:spec1)
}
set 1.1. {  
    ""			{play $snd_menuoff}
    "Dretch"		{class level0}
    "Construction Kit"	{sell weapons;sell upgrades;buy ackit; buy ckit;itemact ackit;itemact ckit}
}
set 1.2. {
    ""			{play $snd_menuoff}
    Basilisk		{class level1}
    Rifle		{sell weapons;sell weapons;buy rifle;itemact rifle}
}
#+end_src

  If you save this sample and run voltron to produce menu:

  #+begin_example
%tclsh voltron.tcl yourconfig
==> Generate menu:
Hud file: chatmenu_alien.cfg
Hud file: chatmenu_human.cfg
Hud file: chatmenu_spec.cfg
==> Generate exec scripts:
EXEC script for all: chatmenu_install.cfg
EXEC script team a: chatmenu_alien_install.cfg
EXEC script team b: chatmenu_human_install.cfg
EXEC script team s: chatmenu_spect_install.cfg
%
  #+end_example

  After you must copy (if you not set [[vars][variables]] in your configure file
  before) created files in =ui/hud/common= for example.  *If you don't
  use volt  HUD* then  you must include  all =chatmenu_*.cfg=  in your
  .menu file,  and do exec command  for one of  *install.cfg files. It
  create next menus for different teams:

| menu   | team A (aliens) | team B (humans)     | Spectator |
| /      | <               | <                   | <         |
|--------+-----------------+---------------------+-----------|
| root   | Sub Menus:      | Sub Menus:          |           |
|        | 1. Evolve       | 1. Buy              |           |
|--------+-----------------+---------------------+-----------|
| menu 1 | Evolve to:      | Buy:                |           |
|        | 1. Dretch       | 1. Construction Kit |           |
|        | 2. Basilisk     | 2. rifle            |           |

  Full syntax of menu is: 

  #+begin_example -r
 set X. {							(ref:root)
     {MenuTextForAll MenuHeaderForAll}	CommandForAll	        (ref:cmd4all)
     {MenuAlienText MenuHeaderForAlien}	AlienCommands           (ref:cmd4ali)
     {MenuHumText MenuHeaderForHuman}	HumCommands             (ref:cmd4hum)
     {MenuSpecText MenuHeaderForSpec}	SpectatorCommands       (ref:cmd4spec)
 }

 set X.Y. {
     MenuTextForAll	CommandForAll
     MenuAlienText	AlienCommands
     MenuHumText	HumCommands
     MenuSpecText	SpectatorCommands
 }
  #+end_example
  
  Here is  list of  4 pairs:  [[(cmd4all)][all]], [[(cmd4ali)][team a]]  (aliens), [[(cmd4hum)][team  b]] (humans),
  [[(cmd4spec)][spectator]].  First  element of  pair is name  of menu item,  second -
  command for  it.  If its  a [[(root)]] menu  item than first  element is
  pair of name  of menu item and header name  of child submenu. Values
  of pair =all= is joined to other pairs.

  You can take different menu action for different teams, but you need
  to load  that config files in  some way. Voltron  generate 4 install
  files:
  
 - =chatmenu_install.cfg=  - it contain  merged action for  all teams.
   You can load him if you  have no conflict commands. For example you
   have no several  "say" command for different teams  (i.e. you setup
   only =CommandForAll=).
 - =chatmenu_alien_install.cfg=  - aliens specified  commands, you may
   need load him when you _join_ to team;
 - =chatmenu_human_install.cfg= - humans specified commands, you may
   need load him when you _join_ to team;
 - =chatmenu_spect_install.cfg= - spectate specified commands, you may
   need load him when you _join_ to team;

  Example of usage =chatmenu_*_install.cfg= files is below:

#+begin_src tcl
set snd_menuoff sound/misc/menu3
set snd_menuon  sound/misc/menu1.wav
# menu example
set 0. {{Join "Join:"}			{play $snd_menuon} }
set 0.1. {"Joint alien"			{team aliens;exec ui/hud/common/chatmenu_alien_install.cfg;play $snd_menuoff}}
set 0.2. {"Joint human"			{team humans;exec ui/hud/common/chatmenu_human_install.cfg;play $snd_menuoff}}
set 0.3. {"Joint spectate"		{team spectate;exec ui/hud/common/chatmenu_spect_install.cfg;play $snd_menuoff}}
# bind example, select spectate team
bind F9 "team spectate; exec ui/hud/common/chatmenu_spect_install.cfg"
#+end_src

** Customising
   You can use several variables and commands for configuring.
*** =bind_keys=
    Keys for menu, default is {1 2 3 4 5 6 7 8 9 0 - =}.

# <>
*** =chatmenu_teama=
    Chat menu output file name  for team A.  Default is =chatmenu_alien.cfg=.

*** =chatmenu_teamb=
    Chat menu output file name for team B.  Default is =chatmenu_human.cfg=.

*** =chatmenu_spect=
    Chat menu output file name for spectator. Default is =chatmenu_spec.cfg=.

*** =chatmenu_install=
    Main chat menu install script that contain all merged binds for all
    teams.  Default is =chatmenu_install.cfg=.

*** =binds_teama_install=
    Script   file  for   binds   of  team   A   (aliens).  Default   is
    =chatmenu_alien_install.cfg=.

*** =binds_teamb_install=
    Script   file  for   binds   of  team   B   (humans).  Default   is
    =chatmenu_human_install.cfg=)

*** =binds_spect_install=
    Script    file    for    binds    of    spectator.    Default    is
    =chatmenu_spect_install.cfg=)

*** Template for menu
    You may set menu template different for all teams:
    - =menu_alien_tmpl=;
    - =menu_human_tmpl=;
    - =menu_spectator_tmpl=.

    Default is:

#+begin_src tcl
set menu_spectator_tmpl "    rect 6 210 400 190
    visible 1
    decoration
    forecolor 45 45 45 1
    textscale 0.25
    autowrapped
    textstyle ITEM_TEXTSTYLE_SHADOWED"
#+end_src

*** Customize menu item
    You can  specify prefix and suffix  of menu item of  chat menu for
    each team.   This variables will  be substituted with  template of
    menu for each menu item. By default used prefixes and suffixes for
    vertical look:

#+begin_src tcl
set tmpl_a_prefix {}
set tmpl_b_prefix {}
set tmpl_s_prefix {}
set tmpl_a_suffix {\n}
set tmpl_b_suffix {\n}
set tmpl_s_suffix {\n}
# will create next menu look:
# 1. \m/
# 2. Yakh
# 3. Dekaruchaa!
#+end_src

    To set horizontal look you need remove \n from default suffix:

#+begin_src tcl
# \[ because "[" and "]" are command substitute parents in tcl 
set tmpl_a_prefix " \["
set tmpl_b_prefix " \["
set tmpl_s_prefix " \["
set tmpl_a_suffix "\]"
set tmpl_b_suffix "\]"
set tmpl_s_suffix "\]"
# will create next menu look:
#  [1. \m/] [2. Yakh] [3. Dekaruchaa!]
#+end_src

*** =backspace_cmd=
    additional command for BACKSPACE  key (primary command is set root
    menu).  Default =play sound/misc/menu4.wav=

*** =fileSplitSize=
    Max file size before split. Quake have limits for cfg file size in
    16k.   To prevent fail  load file  will be  split and  used =exec=
    command.

*** unbind
    Quake like  unbind command. This  command have lower  prioritet vs
    bind command.

*** unbindTeams
    Team specified unbind command. Format of command:

#+begin_example
unbindTeams key team_list
#+end_example

    Where =team_list= is list of:
    - =ali=, =alien=, =a=, =1= -- alien team (team a)
    - =hum=, =human=, =b=, =2= -- human team (team b)
    - =spec=, =spectator=, =3= -- spectator team

    Example:

#+begin_example
unbindTeams v {hum ali}
#+end_example


#<>
*** bind 
    =bind=  add additional  key  bind  at end  of  install script,  it
    similar to quake bind.

*** bindTeams
    =bindTeams= is  quake bind command, but team  specified bind. Like
    menu  you  can  load  different =*_install.cfg=  config  file  for
    different teams, and all binds  with this command will be only for
    one of team. Format of command:

#+begin_example
bindTeams key {
     commandForAll
     commandForTeamA
     commandForTeamB
     commandForTeamSpec
 }
#+end_example

    Example: bind INSERT key to spawn as *(Adv)graner* if you in [[(btalien)][alien]]
    team or spawn as *human* *builder* and take ckit if you are [[(bthuman)][human]]:

#+begin_src tcl -r
set snd_menuoff "sound/misc/menu3"

bindTeams INS {
    {echo ^1Spawn as builder;play $snd_menuoff}
    {class builderupg;class builder}									(ref:btalien)
    {class ackit; class ckit;sell weapons;sell upgrades;buy ackit; buy ckit;itemact ackit;itemact ckit} (ref:bthuman)
    {echo ^1You are spectate}
}
#+end_src

*** seta
    Quake like =seta= command.

*** setaTeams
    Quake like =seta= command but team specified =seta=. Format of command

#+begin_example
setaTeams var command team_list
#+end_example

    Where =team_list= is list of:
    - =ali=, =alien=, =a=, =1= -- alien team (team a)
    - =hum=, =human=, =b=, =2= -- human team (team b)
    - =spec=, =spectator=, =3= -- spectator team

    Example:

#+begin_src tcl
# Wall Walk Auto Pitching
setaTeams cg_wwFollow 0 {alien}
#+end_src  

*** =postInstall=
    Text of  install script  that be at  and. Default is  volt's binds
    like sound control etc. You can easy add some stuff:

#+begin_src tcl
set postInstall "$postInstall
// some addition stuf
unbind v
exec foobaar.cfg"
#+end_src

*** messages-from-file
    Create  messages  list  that  allow  you cyclic  run  some  command
    (default is "say" command).  Format of command:

    =messages-from-file variable_name file_source file_dest execpath {prefix {}} {sufix {}} {command {"say"}}=

    -  =variable_name=  is  quake  var  that  you  can  use  by  =vstr
       variable_name= (good to bind some key to it);
    - =file_source= - source file  of lines, file also will be searched
     in directory where configure file is located;
    - =file_dest= - generated configfile location;
    - =execpath= - quakebased path to file;
    - =prefix=,  =sufix= -  text that be  concatenate before  and after
      each line of text file;
    - =command= - action to each line of text file (default =say=);

    For example you wish to say different "hello". You have file =hello.txt=:

#+begin_src tcl
# comment is line that start with #
Hi
Hello
Hola
#+end_src

  In your config you can add:

#+begin_src tcl
messages-from-file Hello \
    "hello.txt"\
    "~/.tremulous/base/ui/hud/common/msg/hello.cfg" \
    ui/hud/common/msg/alienjoin.cfg \
    \o/(  ) say
# bind it to menu 9.9
set 9. {{Messages "Messages:"}	{play sound/misc/menu1.wav} }
set 9.9. { {} {}
    "Hello"  "vstr Hello"
}
#+end_src

* Footnotes

[fn:1]  It configured by  default for  creating =chatmenu_install.cfg=
which is  a part of volts's  chatmenu, who is initial  creator of this
chat menu i don't know, but you can inform me :).

本源码包内暂不包含可直接显示的源代码文件,请下载源码包。