Tutorial Adding A Custom Menu
____________
*******note for other contributors*******
link http://code.google.com/p/x3tcscripts/
Code: Select all
it would be good here people if the code your c+ping from could be uploaded as a separate script for users to use or look at in more detail (remember many new scripters don't know where all the command we take for granted are)
uploading a script is simple using the google upload site i've imperialised for tc
just log in with
lordvader@ikillclowns.com
egosoftmods
takes about 20 seconds to upload a script ;)
First you can install this download to your x3 folder which contains the tutorial scripts
[ external image ]
zip
Cycrow Installer Version
[ external image ]
Once installed you need the 8800-L044 t file in your t directory
[ external image ]
Below is the t file text
Code: Select all
<language id="44"> // english (49 is german)
−
<page id="2008" title="Script Object Commands" descr="0">
<t id="1309">A_LV_TUTORIAL_MENU</t>
</page> \\ creates the command shown lower in the "Custom" interface
−
<page id="2010" title="Script Cmd Names" descr="Long version of commandos. These are the commandos assigned to ships using the commandconsole. Page 2010 and 2011 belong together and hold short and long versions of the same commands">
<t id="1309">Open Tutorial Interface</t>
</page>
−
<page id="2011" title="Script Cmd Shorts" descr="Short version of commandos. These are the commandos assigned to ships using the commandconsole. Page 2010 and 2011 belong together and hold short and long versions of the same commands">
<t id="1309">OTI</t>
</page>
−
<page descr="" id="8800" title="Tutorials">
<t id="1">\033GChoose a station or ship\033X</t>
\\makes the text ingame show as green
<t id="2">You chose \033R%s\033X</t>
\\shown in the games rss feed ticker bottom left of screen
<t id="3">Play a sound</t>
<t id="4">Enter sound number 900-1000</t>
<t id="5">Open another menu</t>
<t id="6">Option 1</t>
<t id="7">Option 2</t>
<t id="8">Option 3</t>
<t id="9">Option 4</t>
<t id="10">Option 5</t>
<t id="11">Tutorial Interface Main Menu</t>
<t id="12">Tutorial Interface 1st Menu</t>
<t id="13">Tutorial Interface 2nd Menu</t>
<t id="14">Show Some Text In The RRS Feed</t>
<t id="15">This is tutorial text by \033GLV\033X</t>
</page>
</language>
The highlighted 2 files will also be in your scripts directory if you have installed correctly.
[ external image ]
Once ingame go into your script editor will have the 2 scripts near the bottom of the list
[ external image ]
Code: Select all
Script setup.lv.tutorials
Version: 0
for Script Engine Version: 41
Description
Tutorial scripts for TC scripters
Arguments
Source Text
001 load text: id=8800
002 * loads youtr t file
003 $ware = Cargo Lifesupport System
004
005 add ship custom command: id=1309
006 * loads the text from your t file to set up a comand in the interface
007 set script command upgrade: command=A_LV_TUTORIAL_MENU upgrade=[TRUE]
008 * upgrade = TRUE means command shows by default
009
010 *set script command upgrade: command=A_LV_TUTORIAL_MENU upgrade=$ware
011 * upgrade = ware means unless the ship has the ware installed the command is off
012
013
014 global script map: set: key=A_LV_TUTORIAL_MENU, class=Moveable Ship, race=Player, script='tutorial.lv.main', prio=0
015 * this adds the command to all your ships and calls the script that the comm uses
016 * command will now show in custom interface.
017 return null
Once installed you will now have the command in your "Custom Menu"
[ external image ]
[ external image ]
The setup script is what binds the new command above from the t file.
[ external image ]
Which then opens this menu
[ external image ]
Choose the "open another menu" option for this
[ external image ]
When you select the command
this is the script called which we set up into the initail setup.tutorial script above
global script map: set: key=A_LV_TUTORIAL_MENU, class=Moveable Ship, race=Player, script='tutorial.lv.main', prio=0
Code: Select all
Script tutorial.lv.main
Version: 0
for Script Engine Version: 41
Description
Description
Arguments
Source Text
001 $anull = null
002
003 $a = 'a'
004 $b = 'b'
005 $c = 'c'
006 $d = 'd'
007 $e = 'e'
008 $f = 'f'
009
010
011 $text = sprintf: pageid=8800 textid=11, null, null, null, null, null
012 $menu = create custom menu array: heading=$text
013
014 $text = sprintf: pageid=8800 textid=1, null, null, null, null, null
015 add custom menu item to array $menu: text=$text returnvalue=$a
016
017 $text = sprintf: pageid=8800 textid=3, null, null, null, null, null
018 add custom menu item to array $menu: text=$text returnvalue=$b
019
020 $text = sprintf: pageid=8800 textid=5, null, null, null, null, null
021 add custom menu item to array $menu: text=$text returnvalue=$c
022
023 add custom menu item to array $menu: text='Tell Me What Ship I'm In' returnvalue=$d
024
025 $text = sprintf: pageid=8800 textid=14, null, null, null, null, null
026 add custom menu item to array $menu: text=$text returnvalue=$e
027
028 $text = sprintf: pageid=8800 textid=11, null, null, null, null, null
029
030 add custom menu item to array $menu: text='Monitor For Users Closing Menu Accidently' returnvalue=$f
031
032 loop:
033 @ = wait 1 ms
034 $return = open custom menu: title=$menu description=$text option array=$menu
035
036
037 if $return == $a
038 |$input = [THIS] -> get user input: type=Var/Ship/Station, title='Choose a station or ship'
039 |$text = sprintf: pageid=8800 textid=2, $input, null, null, null, null
040 |display subtitle text: text=$text duration=3000 ms
041 else if $return == $b
042 |$text = sprintf: pageid=8800 textid=4, null, null, null, null, null
043 |$menu = create custom menu array
044 |add custom menu item to array $menu: text=$text returnvalue='sound'
045 |$sound = open custom menu: title=$menu description='try 928' option array=$menu
046 |$input = [THIS] -> get user input: type=Var/Number, title=$text
047 |play sample $input
048 else if $return == $c
049 |$text = sprintf: pageid=8800 textid=12, $anull, null, null, null, null
050 |$menu.1 = create custom menu array: heading=$text
051 |$text = sprintf: pageid=8800 textid=6, $anull, null, null, null, null
052 |add custom menu item to array $menu.1: text=$text returnvalue=$f
053 |$text = sprintf: pageid=8800 textid=7, $anull, null, null, null, null
054 |add custom menu item to array $menu.1: text=$text returnvalue=$f
055 |$text = sprintf: pageid=8800 textid=8, $anull, null, null, null, null
056 |add custom menu item to array $menu.1: text=$text returnvalue=$f
057 |$text = sprintf: pageid=8800 textid=9, $anull, null, null, null, null
058 |add custom menu item to array $menu.1: text=$text returnvalue=$f
059 |$return1 = open custom menu: title=$menu.1 description='Tutorial' option array=$menu.1
060 else if $return == $d
061 |$pship = get player ship
062 |$text = 'You are currently flying a ' + $pship
063 |display subtitle text: text=$text duration=3000 ms
064 else if $return == $e
065 |$text = sprintf: pageid=8800 textid=15, $anull, null, null, null, null
066 |display subtitle text: text=$text duration=3000 ms
067 else if $return == $f
068 |display subtitle text: text='Next time the menu appears press del key' duration=3000 ms
069 @ |= wait 4000 ms
070 |goto label loop
071 else if $return == -1
072 * if del is pressed the rturn value is -1
073 * make a loop to stop this
074 @ |= wait 4000 ms
075 |goto label loop
076 end
077
078
079
080
081 return null
within the Tutorial scripts you can now also see how to check if a user closes a menu //
LV's Terran Conflict Script Index