Ludwig van | 2009-11-27 23:17
Ludwig van's Keys
58
points ]
 (6 votes)
Assign keys for commands or chatmessages. Just open the menu, write a text and assign a key.

-- What's this ? --
This script will give you a new menu that makes it easy to assign keys to commands and chatmessages. So, if you are a noob, you can now easily assign a key for saying "Sorry", or "Nice Shot". If you are not a noob, you can use this to save a few commands, which you then have fast access to (by menu or key). You can have up to 20 different chatmessages, teamchatmessages, commands and editcommands. There is also the possibility to look up all unused keys.
Hope, you like it.

-- How to install --
1. Download "l_keys.cfg"
2. Put the file into the directory where your sauerbraten.bat is.
3. Open "autoexec.cfg" which is located in the same directory. Add this line and save:
exec l_keys.cfg
5. Open Sauerbraten and press F10
There will be one error message on your first launch of Sauer. Don't mind it.
[6. Optional: Add this line to your data/menu.cfg before the line oldbinds = (searchbinds [@@@n]):
l_keytoclear = $@newbinds; l_clearoldkey
This will delete the Ludwig van's keybinding, if you change a key in the options/keys menu.]

-- Fix --
1. Fixed the "unknown command: nokey" error and added instruction 6 in -- How to install --.

-- Use --
You may use, or change this script for any purpose. You don't have to attribute this work. However, if you want to tell me about your using this, I would be glad.

//Ludwig van's keys - fix 1
//by Ludwig van

//standard texts
l_textreset = [
	l_text0 = "Shoot red only, please."
	l_text1 = "Nice shot"
	l_text2 = "Write in english, please."
	l_text3 = "Balance, please."
	l_text4 = "Anybody up for a duel?"
	l_text5 = "Sorry"
	l_text6 = "Flag carrier needs some backup."
	l_text7 = "Good job, team."
	l_text8 = "Incoming"
	l_text9 = "Help in defence needed."
	l_text10 = [showgui servers]
	l_text11 = [connect 98.76.543.2]
	l_text12 = [connect 98.76.543.2 [1000 [password]]]
	l_text13 = [if (strcmp (getteam) "good") [team evil] [team good]]
	l_text14 = [setmaster 1]
	l_text15 = [if (= $floatspeed 60) [floatspeed (- $floatspeed 50)]]
	l_text17 = [newent particles 7 6008 20 0x00B]
	l_text18 = [sendmap]
	l_text19 = [getmap]
]

//resets the keys
l_keyreset = [
    loop i 19 [
        (concatword "l_key" $i) = ""
    ]
]

//will be executed only once, when you use the script first.
if (= $l_used 1) [] [  
    l_used = 1  
    bind [F10] [showgui l_say ]
    l_saykey = [F10]
    l_teamsaykey = "nokey"
    l_commandkey = "nokey"
    l_editcommandkey = "nokey"
    l_showunused = 0
    l_guistayopen = 1
    l_guistayopen2 = 1
    l_guistayopen3 = 1
    l_guistayopen4 = 1
    l_lines = ""
    l_keytoclear = ""
    l_keynottoclear = ""
    l_addfieldnumber = 20
    l_addfield0 = 5
    l_addfield1 = 5
    l_addfield2 = 5
    l_addfield3 = 5
    l_textreset
    l_keyreset 
]

//oldkeys is used to clear the old binding of a command
l_oldkey = [
    loop i $l_addfieldnumber [
        (concatword "l_oldkey" $i) = (getalias (concatword "l_key" $i))
    ]
    l_oldsaykey = (getalias (concatword "l_sayke" "y"))
    l_oldteamsaykey =  (getalias (concatword "l_teamsayke" "y"))
    l_oldcommandkey = (getalias (concatword "l_commandke" "y"))
    l_oldeditcommandkey = (getalias (concatword "l_editcommandke" "y"))
]


//clearoldkey and l_clearoldeditkey  are used, to delete the key of another command, if a key is used twice.
l_clearoldkey = [
    loop i (- $l_addfieldnumber $l_addfield3) [
        if (strcmp (getalias (concatword "l_key" $i)) $l_keytoclear) [if (= $l_keynottoclear $i) [] [(concatword "l_key" $i) = ""]]
    ]
    if (strcmp $l_saykey $l_keytoclear) [if (= $l_keynottoclear -1) [] [l_saykey  = "nokey"]]
    if (strcmp $l_teamsaykey $l_keytoclear) [if (= $l_keynottoclear -2) [] [l_teamsaykey  = "nokey"]]
    if (strcmp $l_commandkey $l_keytoclear) [if (= $l_keynottoclear -3) [] [l_commandkey  = "nokey"]]
    l_keytoclear = ""
    l_keynottoclear = ""
]

l_clearoldeditkey = [
    loop i $l_addfieldnumber [
        if (>= $i (- $l_addfieldnumber $l_addfield3)) [
            if (strcmp (getalias (concatword "l_key" $i)) $l_keytoclear) [if (= $l_keynottoclear $i) [] [(concatword "l_key" $i) = ""]]
        ]
    ]
    if (strcmp $l_editcommandkey $l_keytoclear) [if (= $l_keynottoclear -4) [] [l_editcommandkey  = "nokey"]]
    l_keytoclear = ""
    l_keynottoclear = ""
]

//those aliases are executed, when you press the assigned button
l_initexec = [
    loop i $l_addfieldnumber [     
        l_temp = (getalias (concatword l_text $i))   
        if (= $l_temp (at $l_addfieldpos 1)) [
				if (= (at $l_addfieldpos 1) $l_temp) [(concatword "l_text" $l_temp) = ""; (concatword "l_key" $l_temp) = ""] [(concatword "l_text" $l_temp) = (getalias (concatword "l_text" (- $l_temp 1))); (concatword "l_key" $l_temp) = (getalias (concatword "l_key" (- $l_temp 1)))]
			]
		]
	] [
                if (strcmp (getalias (concatword "l_key" (- (at $l_addfieldpos 1) 1))) "") [] [bind (getalias (concatword "l_key" (- (at $l_addfieldpos 1) 1))) ""]
		l_addfieldnumber = (- $l_addfieldnumber 1)
		loop i $l_addfieldnumber [
			if (>= (+ $i 1) (at $l_addfieldpos 1)) [
				(concatword "l_text" $i) = (getalias (concatword "l_text" (+ $i 1)))
				(concatword "l_key" $i) = (getalias (concatword "l_key" (+ $i 1)))
			]
		]
	]
]


//the guis

newgui l_say [
    l_oldkey
    l_initexec 
	guilist [
		guitext "^f6Say^f~"
		guibar
		guibutton "Teamsay" [cleargui 1;sleep 1 [showgui l_teamsay]]
		guibar
		guibutton "Commands" [cleargui 1;sleep 1 [showgui l_commands]]
		guibar
		guibutton "Editcommands" [cleargui 1;sleep 1 [showgui l_editcommands]]
		guibar
		guibar
		guibutton "Help" [cleargui 1;sleep 1 [showgui l_help]]
	]
    loop i $l_addfield0 [
        guilist [
            guifield (concatword "l_text" $i) 50 (if (strcmp (getalias (concatword "l_key" $i)) "") [] [bind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i))])
            guibar
            guikeyfield (concatword "l_key" $i) 11 [  
                if (strcmp (getalias (concatword "l_oldkey" $i)) "") [] [bind (getalias (concatword "l_oldkey" $i)) ""]  
                (concatword "l_key" $i) = (at (getalias (concatword "l_key" $i)) 0)
                if (strcmp (getalias (concatword "l_key" $i)) "") [] [bind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i)); l_keytoclear = (getalias (concatword "l_key" $i)); l_keynottoclear = $i; l_clearoldkey]
            ]
            if (= $l_guistayopen 0) [l_temp = (getalias (concatword "l_exec" $i)); guibutton "say now" [@l_temp]] [guistayopen [l_temp = (getalias (concatword "l_exec" $i)); guibutton "say now" [@l_temp]]]
        ]
		if (= $i (- $l_addfield0 1 )) [
			guistayopen [
				guilist [
					guibutton "^f0Add field^f~" [if ( $l_addfield0 1) [l_addfieldpos = [ "-" @l_addfield0]; l_addfield0 = (- $l_addfield0 1); l_fieldchange]] "arrow_bw"
				]
				guibar
				guilist [
					 guitext "Open this gui: "
					 guikeyfield l_saykey 11 [
						 if (strcmp $l_oldsaykey "nokey") [] [bind $l_oldsaykey ""]
						 l_saykey = (at $l_saykey 0)
						 if (strcmp $l_saykey "") [l_saykey = "nokey"] [bind $l_saykey [showgui l_say]; l_keytoclear = $l_saykey; l_keynottoclear = -1; l_clearoldkey]
					 ]
					 guibar
					 guicheckbox "Don't close Gui when using 'say now'" l_guistayopen          
				]
				if (= $l_showunused 0) [guibutton "^f1Show unused keys^f~" [l_showunused = 1]] [guibutton "^f1Hide unused keys^f~" [l_showunused = 0]]
			]	 
			guilist [
				guilist [
					if (= $l_showunused 1) [
						l_searchbinds = (searchbinds)
						l_lines = ""
						loop i (listlen $l_searchbinds) [
							l_lines = (concat $l_lines (at $l_searchbinds $i))
							if (= (listlen $l_lines) 8) [guitext $l_lines; l_lines = ""]
						]
						if (strcmp $l_lines "")[] [guitext $l_lines]
					]
			   ]
			]
		]
	]
] "Ludwig van's Keys: Say"

newgui l_teamsay [
    l_oldkey
    l_initexec 
    guilist [
		guibutton "Say" [cleargui 1;sleep 1 [showgui l_say]]
		guibar
		guitext "^f6Teamsay^f~"
		guibar
		guibutton "Commands" [cleargui 1;sleep 1 [showgui l_commands]]
		guibar
		guibutton "Editcommands" [cleargui 1;sleep 1 [showgui l_editcommands]]
		guibar
		guibar
		guibutton "Help" [cleargui 1;sleep 1 [showgui l_help]]
	]
    loop i (+ $l_addfield0 $l_addfield1) [
		if (>= $i $l_addfield0) [
			guilist [
				guifield (concatword "l_text" $i) 50 (if (strcmp (getalias (concatword "l_key" $i)) "") [] [bind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i))])
				guibar
				guikeyfield (concatword "l_key" $i) 11 [
					if (strcmp (getalias (concatword "l_oldkey" $i)) "") [] [bind (getalias (concatword "l_oldkey" $i)) ""]
					(concatword "l_key" $i) = (at (getalias (concatword "l_key" $i)) 0)
					if (strcmp (getalias (concatword "l_key" $i)) "") [] [bind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i)); l_keytoclear = (getalias (concatword "l_key" $i)); l_keynottoclear = $i; l_clearoldkey]
				]
				if (= $l_guistayopen2 0) [l_temp = (getalias (concatword "l_exec" $i)); guibutton "say now" [@l_temp]] [guistayopen [l_temp = (getalias (concatword "l_exec" $i)); guibutton "say now" [@l_temp]]]
			]
		]
		if (= $i (- (+ $l_addfield0 $l_addfield1) 1)) [
			guistayopen [
				guilist [
					guibutton "^f0Add field^f~" [if ( $l_addfield1 1) [l_temp = (+ @l_addfield0 @l_addfield1); l_addfieldpos = [ "-" @l_temp ]; l_addfield1 = (- $l_addfield1 1);l_fieldchange]] "arrow_bw"
				]
				guibar
				guilist [
					 guitext "Open this gui: "
					 guikeyfield l_teamsaykey 11 [
						 if (strcmp $l_oldteamsaykey "nokey") [] [bind $l_oldteamsaykey ""]
						 l_teamsaykey = (at $l_teamsaykey 0)
						 if (strcmp $l_teamsaykey "") [l_teamsaykey = "nokey"] [bind $l_teamsaykey [showgui l_teamsay]; l_keytoclear = $l_teamsaykey; l_keynottoclear = -2; l_clearoldkey]
					 ]
					 guibar
					 guicheckbox "Don't close Gui when using 'say now'" l_guistayopen2
				]
			 if (= $l_showunused 0) [guibutton "^f1Show unused keys^f~" [l_showunused = 1]] [guibutton "^f1Hide unused keys^f~" [l_showunused = 0]]
			]
			guilist [
				guilist [
					if (= $l_showunused 1) [
						l_searchbinds = (searchbinds)
						l_lines = ""
						loop i (listlen $l_searchbinds) [
							l_lines = (concat $l_lines (at $l_searchbinds $i))
							if (= (listlen $l_lines) 8) [guitext $l_lines; l_lines = ""]
						]
						if (strcmp $l_lines "")[] [guitext $l_lines]
					]
			   ]
			]
		]
	]
] "Ludwig van's Keys: Teamsay"

newgui l_commands [
    l_oldkey
    l_initexec 
	guilist [
		guibutton "Say" [cleargui 1;sleep 1 [showgui l_say]]
		guibar
		guibutton "Teamsay" [cleargui 1;sleep 1 [showgui l_teamsay]]
		guibar
		guitext "^f6Commands^f~"
		guibar
		guibutton "Editcommands" [cleargui 1;sleep 1 [showgui l_editcommands]]
		guibar
		guibar
		guibutton "Help" [cleargui 1;sleep 1 [showgui l_help]]
	]
	loop i (+ (+ $l_addfield0 $l_addfield1) $l_addfield2) [
		if (>= $i (+ $l_addfield0 $l_addfield1)) [
			guilist [
				guifield (concatword "l_text" $i) 80 (if (strcmp (getalias (concatword "l_key" $i)) "") [] [bind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i))])
				guibar
				guikeyfield (concatword "l_key" $i) 12 [
					if (strcmp (getalias (concatword "l_oldkey" $i)) "") [] [bind (getalias (concatword "l_oldkey" $i)) ""]
					(concatword "l_key" $i) = (at (getalias (concatword "l_key" $i)) 0)
					if (strcmp (getalias (concatword "l_key" $i)) "") [] [bind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i)); l_keytoclear = (getalias (concatword "l_key" $i)); l_keynottoclear = $i; l_clearoldkey]
				]
				if (= $l_guistayopen3 0) [l_temp = (getalias (concatword "l_exec" $i)); guibutton "exec now" [@l_temp]] [guistayopen [l_temp = (getalias (concatword "l_exec" $i)); guibutton "exec now" [@l_temp]]]
			]
		]
			if (= $i (- (+ (+ $l_addfield0 $l_addfield1) $l_addfield2) 1)) [
				guistayopen [
					guilist [
						guibutton "^f0Add field^f~" [if ( $l_addfield2 1) [l_temp = (+ (+ @l_addfield0 @l_addfield1) @l_addfield2); l_addfieldpos = [ "+" @l_temp ]; l_addfield2 = (- $l_addfield2 1);l_fieldchange]] "arrow_bw"
				]
				guibar
				guilist [
					 guitext "Open this gui: "
						 guikeyfield l_commandkey 11 [
							 if (strcmp $l_oldcommandkey "nokey") [] [bind $l_oldcommandkey ""]
							 l_commandkey = (at $l_commandkey 0)
							 if (strcmp $l_commandkey "") [l_commandkey = "nokey"] [bind $l_commandkey [showgui l_commands]; l_keytoclear = $l_commandkey ; l_keynottoclear = -3; l_clearoldkey]
						 ]
					 guibar
					 guicheckbox "Don't close Gui when using 'exec now '" l_guistayopen3
				]
			 if (= $l_showunused 0) [guibutton "^f1Show unused keys^f~" [l_showunused = 1]] [guibutton "^f1Hide unused keys^f~" [l_showunused = 0]]
			]
			guilist [
				guilist [
					if (= $l_showunused 1) [
						l_searchbinds = (searchbinds)
						l_lines = ""
						loop i (listlen $l_searchbinds) [
							l_lines = (concat $l_lines (at $l_searchbinds $i))
							if (= (listlen $l_lines) 10) [guitext $l_lines; l_lines = ""]
						]
						if (strcmp $l_lines "")[] [guitext $l_lines]
					]
			   ]
			]
		]
	]
] "Ludwig van's Keys: Commands"

newgui l_editcommands [
    l_oldkey
    l_initexec 
	guilist [
		guibutton "Say" [cleargui 1;sleep 1 [showgui l_say]]
		guibar
		guibutton "Teamsay" [cleargui 1;sleep 1 [showgui l_teamsay]]
		guibar
		guibutton "Commands" [cleargui 1;sleep 1 [showgui l_commands]]
		guibar
		guitext "^f6Editcommands^f~"
		guibar
		guibar
		guibutton "Help" [cleargui 1;sleep 1 [showgui l_help]]
	]
		loop i (+ (+ (+ $l_addfield0 $l_addfield1) $l_addfield2) $l_addfield3) [
		if (>= $i (+ (+ $l_addfield0 $l_addfield1) $l_addfield2)) [
			guilist [
				guifield (concatword "l_text" $i) 80 (if (strcmp (getalias (concatword "l_key" $i)) "") [] [bind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i))])
				guibar
				guikeyfield (concatword "l_key" $i) 12 [
					if (strcmp (getalias (concatword "l_oldkey" $i)) "") [] [bind (getalias (concatword "l_oldkey" $i)) ""]
					(concatword "l_key" $i) = (at (getalias (concatword "l_key" $i)) 0)
					if (strcmp (getalias (concatword "l_key" $i)) "") [] [editbind (getalias (concatword "l_key" $i)) (getalias (concatword "l_exec" $i)); l_keytoclear = (getalias (concatword "l_key" $i)); l_keynottoclear = $i; l_clearoldeditkey]
				]
				if (= $l_guistayopen4 0) [l_temp = (getalias (concatword "l_exec" $i)); guibutton "exec now" [@l_temp]] [guistayopen [l_temp = (getalias (concatword "l_exec" $i)); guibutton "exec now" [@l_temp]]]
			]
		]
			if (= $i (- (+ (+ (+ $l_addfield0 $l_addfield1) $l_addfield2) $l_addfield3) 1)) [
				guistayopen [
					guilist [
						guibutton "^f0Add field^f~" [if ( $l_addfield3 1) [l_temp = (+ (+ (+ @l_addfield0 @l_addfield1) @l_addfield2) @l_addfield3); l_addfieldpos = [ "+" @l_temp ]; l_addfield3 = (- $l_addfield3 1);l_fieldchange]] "arrow_bw"
				]
				guibar
				guilist [
					 guitext "Open this gui: "
						 guikeyfield l_editcommandkey 11 [
							 if (strcmp $l_oldeditcommandkey "nokey") [] [bind $l_oldeditcommandkey ""]
							 l_editcommandkey = (at $l_editcommandkey 0)
							 if (strcmp $l_editcommandkey "") [l_editcommandkey = "nokey"] [editbind $l_editcommandkey [showgui l_editcommands]; l_keytoclear = $l_editcommandkey; l_keynottoclear = -4; l_clearoldeditkey]
						 ]
					 guibar
					 guicheckbox "Don't close Gui when using 'exec now'" l_guistayopen4
				]
			 if (= $l_showunused 0) [guibutton "^f1Show unused keys^f~" [l_showunused = 1]] [guibutton "^f1Hide unused keys^f~" [l_showunused = 0]]
			]
			guilist [
				guilist [
					if (= $l_showunused 1) [
						l_searchbinds = (searcheditbinds)
						l_lines = ""
						loop i (listlen $l_searchbinds) [
							l_lines = (concat $l_lines (at $l_searchbinds $i))
							if (= (listlen $l_lines) 10) [guitext $l_lines; l_lines = ""]
						]
						if (strcmp $l_lines "")[] [guitext $l_lines]
					]
			    ]
			]
		]
	]
] "Ludwig van's Keys: Editcommands"

newgui l_help [
	guilist [
		guibutton "Say" [cleargui 1;sleep 1 [showgui l_say]]
		guibar
		guibutton "Teamsay" [cleargui 1;sleep 1 [showgui l_teamsay]]
		guibar
		guibutton "Commands" [cleargui 1;sleep 1 [showgui l_commands]]
		guibar
		guibutton "Editcommands" [cleargui 1;sleep 1 [showgui l_editcommands]]
		guibar
		guibar
		guitext "^f6Help^f~"
	]
	guibar
    guitext "^f1How to use^f~: The left fields are textfields. There is a total of 50 characters"
    guitext "for say and teamsay, and 80 characters for commands and editcommands."
    guitext "The small field on the right is the keyfield. Enter a key here."
    guitext "Pressing this key now will say the text, or execute the command, written in the textfield."
    guitext "The keys for editing will only work in Edit mode. The others mostly won't work in edit mode."
    guibar
    guitext "^f1Say now^f~ and ^f1Exec now^f~: Press this button to say the text,"
    guitext "or execute the command, written in the left field."
    guibar
    guitext "^f1Add field^f~ and ^f1Del field^f~: Will add/delete a field. There is a total of 20 fields per gui."
    guibar
    guitext "^f1Show unused keys^f~ : Will show you all keys that are not in Sauerbraten right now."
    guitext "In the Editcommands gui the keys for editmode are shown."
    guitext "Some of the displayed keys cannot be used, because SHIFT is a standalone key."
    guitext "For example DOLLAR will not be accepted. Only 4 will work."
    guibar
    guitext "^f1Open this gui^f~ : Assign a key that will open this gui."
    guitext "The key for the Editcommands gui will only work in editmode."
    guibar
    guitext "^f1Don't close Gui when using 'exec now^f~ :"
    guitext "The menu will not be closed when pressing the button 'exec now' or 'say now'."
  
] "Ludwig van's Keys: Help"
l_keys.cfg (17.87 KB)
58
points
 (6 votes)
AttachmentSize
l_keys.jpg257.18 KB
User login
Users on Quadropolis
1 guest & no users online
30
points ]
 (3 votes)
Created 2019-05-17 21:51
5 years 27 weeks ago
30
points ]
 (3 votes)
Created 2020-06-13 21:05
4 years 23 weeks ago
20
points ]
 (2 votes)
Created 2021-05-24 00:01
3 years 26 weeks ago
8
points ]
 (1 vote)
Created 2024-06-02 14:26
24 weeks 5 days ago
8
points ]
 (1 vote)
Created 2024-06-02 22:13
24 weeks 4 days ago
vampirefrog
Created 2024-04-11 22:25
32 weeks 19 hours ago
vampirefrog
29
points ]
 (4 votes)
Created 2010-05-30 10:00
14 years 25 weeks ago
Gangler
36
points ]
 (4 votes)
Created 2020-10-22 00:50
4 years 4 weeks ago
Zoocata
10
points ]
 (1 vote)
Created 2024-02-11 21:20
40 weeks 4 days ago
vampirefrog
10
points ]
 (1 vote)
Created 2023-07-23 20:02
1 year 17 weeks ago
36
points ]
 (4 votes)
Created 2020-12-10 12:49
3 years 49 weeks ago
Created 2023-12-12 23:34
49 weeks 2 days ago
Zoocata
Created 2023-11-27 23:00
51 weeks 3 days ago
20
points ]
 (2 votes)
Created 2023-10-01 15:21
1 year 7 weeks ago
9
points ]
 (1 vote)
Created 2023-06-13 17:54
1 year 23 weeks ago
Zoocata
27
points ]
 (3 votes)
Created 2023-05-05 20:58
1 year 28 weeks ago
Zoocata
18
points ]
 (2 votes)
Created 2023-03-02 01:40
1 year 38 weeks ago
Getridou
Created 2023-01-29 23:27
1 year 42 weeks ago
Created 2023-01-19 19:36
1 year 43 weeks ago
Getridou
Created 2023-01-10 17:10
1 year 45 weeks ago
Who's new
  • ColdIV
  • Aidan
  • Hunk
  • letic86
  • BATMAN