Take Binding to the next level, with Scripting!

Read tips and guides about teeworlds-related subjects (mapping, compiling, ..).
GG Kid
Posts: 266
Joined: Sun Apr 16, 2017 2:33 am
Location: U.S.A.
Player profile: https://ddnet.tw/players/Bolto/
Clan: Kerger

Take Binding to the next level, with Scripting!

Post by GG Kid »

Take Binding to the next level with scripting
written by GG kid

Whats "Scripting" you ask?
Well it's like Binding but on another level, you can rule your client with more power then ever, want to change ten things all at once? write a script for it! it's that easy.
we will use configuration (.cfg) files to hold are settings & commands of choice, to use these .cfg scripts you must place them in in one of the paths specified in storage.cfg located in your DDnet's clients main folder, i suggest you store them in your Teeworlds userdata folder (config_directory)
On Linux: /home/USER/.teeworlds
In Windows: copy %appdata%\Teeworlds & paste it in the start-menus search bar & press enter
your'll see settings_ddnet.cfg in that folder, open it with your favorite text editor(Atom.io) & save a copy as reset.cfg , (this will serve as a backup of your settings)
now open your chosen text editing program & paste the code from this spoiler titled: anonymous.cfg
anonymous.cfgShow

Code: Select all

echo anonymous ID, wake up. 
# this is a note(comment), it will not execute. to execute this script use: exec anonymous.cfg

player_name "anonymous"
player_clan "illuminati"
player_country -1
player_use_custom_color 0
player_skin "default"

dummy_name "brainless tee"
dummy_clan "Dummy"
dummy_country -1
dummy_use_custom_color 0
dummy_skin "default"

& save as anonymous.cfg
now open your DDnet client & join a game, press F1 (Console) on your keyboard & type: exec anonymous.cfg press enter then press F1 again & ta-da :!:
you will now you have a new identity, hahaha!
Congratulations! you have just learned how to use scripts in Teeworlds, at any point you can restore your old configuration data by F1 > exec reset.cfg

Ok that was fun but lets do something a little more creative this time: toggling on & off some cool stuff, just remember these are made for the default settings, so you might what to read & edit them to customize the settings toggled,
(anything to the right of a # is a comment)
ZenMode.cfgShow

Code: Select all

echo Zen mode
# this is a comment, it will not execute. to execute this script use: exec zenmode.cfg

toggle cl_show_quads 1 0
toggle cl_overlay_entities 0 93
toggle cl_show_chat_friends 0 1
toggle cl_nameplates 0 1
toggle cl_scoreboard_on_death 0 1
toggle snd_long_pain 1 0
toggle cl_showkillmessages 0 1
toggle cl_shownotifications 1 0
toggle cl_show_chat_system 1 0
toggle cl_vanilla_skins_only 0 1
# prevents saving in this state
toggle cl_save_settings 1 0



## if you enabled these you might what to toggle them off for this mode. 
#toggle cl_race_show_ghost 0 1
#toggle cl_show_votes_after_voting 0 1
#toggle cl_show_local_time_always 0 1
#toggle cl_showfps 1 0
#toggle cl_showpred 1 0
#toggle ed_showkeys 1 0

# global, for if  show_others is enabled  
#toggle cl_show_others 1 0

# per player
#say /showothers

Attempts to simplify your experience & Remove distractions for when you are stressed or need to focus. #FeelTheZen
RecordingMode.cfgShow

Code: Select all

echo Recording mode
# this is a note, it will not execute. use exec "Recording mode.cfg" with quotes to execute this script.

toggle cl_nameplates 0 1
toggle cl_showhud 0 1
toggle cl_showchat 0 1
toggle cl_show_chat_system 1 0
toggle cl_shownotifications 1 0
say /mapinfo 
say /showothers
say /time 
say /teamtop5 
say /dnd
# prevents saving in this state
toggle cl_save_settings 1 0

## if you enabled these you might what to toggle them off for this mode. 
#toggle cl_show_others 0 1
Removes distracting elements of the game so people can admire your uber pro run.
InfoGeek.cfgShow

Code: Select all

echo Info Geek, you may use Ctrl>Shift>D to toggle: debug & Ctrl>Shift>G to toggle: dbg_graphs
# this is a comment, it will not execute, to execute this script use: exec infogeek.cfg
## if you enabled any of these you might what to comment out the command with a # (else they will be toggled off.) 

say /mapinfo
toggle cl_nameplates_always 0 1
toggle cl_nameplates 0 1
toggle cl_show_votes_after_voting 0 1
toggle cl_show_local_time_always 0 1
toggle cl_showfps 0 1
toggle cl_showpred 0 1
toggle debug 0 1
toggle dbg_graphs 0 1
toggle cl_show_ids 0 1
toggle cl_show_direction 0 1
ping
say /rules
# prevents saving in this state
toggle cl_save_settings 1 0

For those who really want to know. look i just sat down & though of every use for scripts i could for the tutorial, take it or leave it.

Ok nice, but i'm taking this to another level here guys, these are the most advanced scripts on the planet! which maybe have a few bugs :) so with that in mind here we go.
to use scripts with spaces in the name enclose the name with quotes like: exec "Name with spaces.cfg"
Precision hooking.cfgShow

Code: Select all

echo Precision hooking, this sets you mouse sensitivity to 100
# this is a note, it will not execute. use: exec "precision hooking.cfg"  with quotes to execute this script.
## instead of this Script try: bind lctrl "+toggle inp_mousesens 1 100; +showhookcoll" 
### that way holding left Ctrl will slooow mouse movement plus show the hook collision line 

# Shows current Mouse Sensitivity in Console
inp_mousesens

toggle inp_mousesens 1 100
toggle cl_overlay_entities 0 100
toggle cl_predict 0 1
toggle cl_predict_ddrace 0 1
toggle cl_show_hook_coll_always 0 1
## overridden by the above 
# cl_show_hook_coll_own 1
# toggle cl_show_hook_coll_other 1 0
 
 
# prevents saving in this state
toggle cl_save_settings 1 0


## if you enabled these you might what to toggle them off for this mode. 
#toggle cl_antiping 0 1
#toggle cl_antiping_limit 0 1

Helps for hard angle Hooks by enabling Entities, setting mouse sensitivity to the lowest value & enabling Hook collision line.
introducing.cfgShow

Code: Select all

echo Introducing... 
# this is a comment, it will not execute. to execute this script use: exec introducing.cfg

# this will not display the first time executed
say /points

# this will not display 
say /rank

# but these would if you uncomment them	
#say Test 123
#say /dnd

# this will display the first time executed
say Hello! i'm a Pro-noob & have been playing TW for about 3 years,

Alternatively you could use bind X "say /points; say Hello! i'm a Pro-noob & have been playing for about 3 years.;echo Introducing..."
to accomplish the same task, as you can see scripts are mostly like binds.
Fire Spam.cfgShow

Code: Select all

# echo Fire Spam! (enable for lots of (local)chat spam...)


+fire


##### Information #####

# fire spam script, very usefull with Hammer! but must be bound to the keyboard, the mouse will only execute scripts once,
# if another keyboard key is press it will quit/stop the execution of this action, 
# so one can hold left & spam fire but not spam fire & then run left (why still spaming fire).

# this is a note, it will not execute. use: exec "Fire Spam.cfg"  with quotes to execute this script.

### other + actions that also work this way

# +nextweapon
# +prevweapon


### other + actions that do not work this way

# +spectate
# +show_chat

# +left
# +right
# +jump	
# +hook

# +showhookcoll

# +weapon1
# +weapon2
# +weapon3
# +weapon4
# +weapon5

Continuously execute/press Fire, useful for Spaming Hammer or Gun very fast. this one is cooler then most, because it seems like a Bug is making it work.

& Now for Some Advanced Binds using Scripts, i'm calling them "Script binds", these allow you to bind anything & toggle it on & off. Replace bind X with your key of choice. for Dummy Deep-Fly see the Just bind it! thread or the download below.

Take Hammer on switch {inspiration from Firewave}Show
HammerTakeOn.cfg

Code: Select all

###          Information    
# Makes toggling dummy take Hammer in hand
###                    


# tells you privately though chat whats going on
echo Enabled Dummy take Hammer on switch

# bounds toggle dummy to also switch to Hammer
bind X "toggle cl_dummy 0 1; +weapon1"

# makes it so pressing 6 will disable it
bind 6 exec HammerTakeOff.cfg


HammerTakeOff.cfg

Code: Select all

###          Information    
# Restores Regular Dummy toggle
###                    


# tells you privately though chat whats going on
echo Enabled Normal Dummy toggling

# bounds toggle dummy as defualt
bind X "toggle cl_dummy 0 1"

# makes it so pressing 6 will enable "force dummy to take hammer"
bind 6 exec HammerTakeOn.cfg

Enables/Disables Forcing switch to Hammer on Dummy toggle.

To initialize it: exec HammerTakeOff.cfg , then use 6 in-game to toggle it on & off.
Rcon & IF|City move though walls Toggle {by fokkonaut}Show
Taken from here <3
rcon_move.cfg
# Rcon move though walls mode
bind up rcon up
bind down rcon down
bind right rcon right
bind left rcon left
bind x "exec city_move.cfg"
echo Rcon Move

city_move.cfg
# IF|City move though walls mode
bind up say /up
bind down say /down
bind right say /right
bind left say /left
bind x "exec rcon_move.cfg"
echo City move

Use your arrow keys for going through walls in city mode ( say /right, etc) or toggle using x for rcon mode (rcon right, etc).

To initiate: exec rcon_move.cfg, then use X in-game to toggle it on & off.
Show others Toggle {by fokkonaut}Show
show_others_on.cfg
cl_show_others 1
say /showothers 1
say /specteam 0
echo Show others: ON
bind X exec "show_others_off.cfg"

show_others_off.cfg
cl_show_others 0
say /showothers 0
say /specteam 1
echo Show others: OFF
bind X exec "show_others_on.cfg"

This will allow you to toggle showing others on solo servers, in spectator (/pause, /spec) and showing other teams while playing.
Have fun :D
Manual Kill "Protection" {by Valen_4}Show
Taken from here This one is really cool, thanks Valen_4! maybe others will use this great idea someday.

killprotection.cfg
bind "X" exec kill.cfg
bind mousewheelup "+nextweapon"

kill.cfg
echo "<Kill Protection> Press again to kill, or Mouse Wheel Up to cancel"
bind "X" "kill; exec killprotection.cfg"

bind mousewheelup "exec killprotection.cfg"

Pressing x once disables "Kill Protection", pressing x again kills you, Mouse-Wheel Up Re-enables "Kill Protection"

Long/technical description
pressing x once puts you in "killing Mode" that: 1. disables "Kill Protection" 2. bind's Mouse-Wheel Up to Re-enable "Kill Protection" 3. tells you this. now pressing x again kills you & disables "killing Mode, pressing Mouse-Wheel Up disables "killing Mode" & Re-enables "Kill Protection"

To initiate: exec killprotection.cfg
One Key Super toggleShow
SuperOn.cfg

Code: Select all

###          Information ---- Script 1 of 2
# Toggles "Super"(meaning your invincible & not affected by Freeze) on.
###


## this is a comment, it will not execute. To initiate this Script-Bind use: exec SuperOff.cfg

# tells you localy though chat whats going on
echo Super Toggled On

# enables super though Rcon if your allowed(till you kill)
rcon super

# disables the Heath & Ammo HUD element When Super is active
+toggle cl_showhud_healthammo 1 0

# prevents the HUD element from staying off if you quit with super active (See Note About +toggle)
cl_save_settings 0 


# rebinds the desired Key(in this case i) to execute the paired Script
bind i exec SuperOff.cfg

SuperOff.cfg

Code: Select all

###          Information ---- Script 2 of 2
# Toggles "Super"(meaning your invincible & not affected by Freeze) off.
###

## this is a comment, it will not execute. To initiate this Script-Bind use: exec SuperOn.cfg


# tells you localy though chat whats going on
echo Super Toggled Off

# disables super(if you kill it will be disabled aswell)
rcon unsuper


# Enables the HUD When Super is off (See Note About +toggle)
+toggle cl_showhud_healthammo 0 1 

# restores normal Saving
cl_save_settings 1

# rebinds the desired Key(in this case i) to execute the paired Script
bind i exec SuperOn.cfg

A pair of Script-Binds that Toggles Super on & off with one key, providing you have already authenticated Rcon with the right privileges.
the ingame HUD element for Health + Ammo is hidden when Super is active for easy differentiating between the two modes. I use i here as the default bind.
Initiate with: exec SuperOff.cfg


Note About +toggle: in Config's/Script's +toggle is the equivalent to setting a value, so
+toggle cl_showhud_healthammo 1 0
cl_showhud_healthammo 0
are one & the same(in the case of Config's/Script's) as
1. there is no Key Held down time, it's executed instantly & just sets the command to the given value.
2. +toggle does not check the current value, it simply changes the values VIA the key press state, meaning the current value of cl_showhud_healthammo is meaningless.
Here are kamillentee's ScriptBinds, The most advanced i have see, prepare to not understand them(like me).
HammerThrow Dummy {by kamillentee}Show
Bind to HammerThrow dummy to a certain direction without freezing it before.

activate_dummy_mover.cfg

Code: Select all

bind mouse2 "+hook; +toggle cl_dummy_hammer 1 0"
bind d "+right; exec onright.cfg"
bind a "+left; exec onleft.cfg"
deepon.cfg

Code: Select all

bind mouse1 "+fire; +toggle cl_dummy_hammer 1 0"
bind mouse2 +hook
echo Deepfly on
onleft.cfg

Code: Select all

bind a +left
bind d +right
bind mouse1 "toggle cl_dummy 0 1; +toggle cl_dummy_hammer 1 0; +left; exec deepon.cfg"
echo dummy left
onright.cfg

Code: Select all

bind d +right
bind a +left
bind mouse1 "toggle cl_dummy 0 1; +toggle cl_dummy_hammer 1 0; +right; exec deepon.cfg;"
echo dummy right


First you need to choose whether you want to throw the dummy to the right or to the left. You do this by binding bind x exec activate_dummy_mover.cfg and pressing x. The next pressing of either a or d will execute onright.cfg or onleft.cfg.
If you are hammerflying release mouse1 and use mouse2 to continue with the hammerfly until you want to throw your dummy.
Now you can throw the dummy to the specified direction and hammer it , pressing mouse1 now for hammer does multiple things it immediately switches to the dummy while holding +right/+left and you get hit with the hammer of the main tee via deepfly.
That will work exactly one time and then it will rebind deepfly and unbind hookdeepfly. Repeat by pressing x.

Explanations why its done this way:
  • +right/+left is temporary binded on mouse1 because on dummy switch a/d would need to be repressed to work again (which causes the tee to loose momentum)
  • activate_dummy_move.cfg is binding dummy hammerfly on mouse2 because there is a bug that causes a delay for a/d movement when mouse1 is still pressed. It will work without this workaround if you don't deephammerfly before (e.g. on ground)
  • Deepfly is turned on at the end because most of the time it's needed afterwards.
  • it is possible to +toggle the dummy so you can return very fast to the main tee, but keep in mind that rebinding a key that is held with a +toggle command always causes bugs
They are bugs like deepfly delay but only for one tee, when switching either direction of movement or the used tee it works. I have no idea why.
Edge2Edge~3 Freeze Tiles {by kamillentee}Show
edgejump.cfg

Code: Select all

bind d "+jump; +right"
bind a "+jump; +left"
echo edgejump on
bind x exec edgejumpoff.cfg
edgejumpoff.cfg

Code: Select all

bind d +right
bind a +left
echo edgejump off
bind x exec edgejump.cfg


This is usefull to jump from one edge to another through 3 freezes. If you press Ctrl+shift+D you see the your coordinates on the right side of the screen. The decimal place of it is usefull for some tricks.

If you stand on edge and want to jump to the right side with the decimal places of 0.62 or 0.66 or 0.81 you can just press jump and D at the same time and it will be a 100% jump. Reverse is possible too, there you go with the coordinates of 0.34 or 0.31 or 0.16.

Because 0.16 and 0.81 are very near to the freeze you can fail the jump sometimes. To prevent this use this config bind that presses jump and direction key at the same time.

Use bind x exec edgejump.cfg to bind it to a key. Press x another time to use normal arrow keys again

Lets say you Want something set when you start the Client, maybe it's one of the commands the Client scrubs from the settings_ddnet.cfg on saving? Well simply make a file in the Root of the Client folder called autoexec.cfg & add you commands it there, like exec that i use for Script binds.

A lot can be done with Binds & Scripts, some useful & some not so useful, i hope i have inspired you to do greater things!
Now that you're armed with this knowledge what will you do next?

All these & more :) are available to Download from Github

old versionsShow
see Github for the latest & greatest...
DDnet Scripts V2.4.zip
(Version 2.4) Added "Take Hammer on switch" & "One Key Deep-Fly Toggle" Script-Binds, Updated style.
(7.95 KiB) Downloaded 316 times
{outdated}
DDnet Scripts V2.3.zip
(Version 2.3) Added "Take Hammer on switch" Script-Bind,
Updated style.
(6.68 KiB) Downloaded 222 times

{outdated}
DDnet Scripts.zip
(version 2.2) added "Fire Spam.cfg"
(5.59 KiB) Downloaded 223 times

{outdated}
DDnet Scripts.zip
(version 2.1) updated & improved "Precision hooking.cfg" thanks to a new Command & bug fix.
(5.08 KiB) Downloaded 222 times

{outdated}
DDnet Scripts.zip
(version 2) added "cl_shownotifications" & "cl_show_chat_system" for DDnet V11.x & Bind Scripts
(5.06 KiB) Downloaded 250 times

{outdated}
TW Scripts.zip
(version 1)
(2.56 KiB) Downloaded 245 times
Please do tell me what you think. maybe you got a killer Script/Bind you what to share ?
Thanks to: index, for guiding me on this path, your the reason I've made this.
fokkonaut for being smart, KlexMikrowelle for making the video tutorial, & of course Deen for making this wonderful experience!
Last edited by GG Kid on Fri Jan 29, 2021 5:39 pm, edited 30 times in total.
n000b
Posts: 164
Joined: Tue Oct 28, 2014 4:18 pm
Clan: |AFK|

Re: Take Binding to the next level, with Scripting!

Post by n000b »

thanks for the turorial. i think many people can use this knowledge.
fokkonaut
Posts: 855
Joined: Wed May 13, 2015 5:59 pm
Player profile: https://ddnet.tw/players/fokkonaut

Re: Take Binding to the next level, with Scripting!

Post by fokkonaut »

this is nothing new for me. I already have 15+ .cfg files in my config directory. if i press f1 ingame and write exec "binds.cfg" ALL the configs will get loaded and every bind will be set in This order (1. exec "binds.cfg": here are all general binds that are bound e.g. bind d +right. The first line in this cfg is "unbindall". i dont want to have all these default binds and i dont like all the stuff that is bound like /points. 2. the binds.cfg execs all the other configs.)
its simple and brilliant xd
GG Kid
Posts: 266
Joined: Sun Apr 16, 2017 2:33 am
Location: U.S.A.
Player profile: https://ddnet.tw/players/Bolto/
Clan: Kerger

Re: Take Binding to the next level, with Scripting!

Post by GG Kid »

Your welcome n000b, if it's even half as useful as the "Just Bind it!" thread i will be pleased.

fokkonaut glad to see someone using this type of thing already, i understand the use of your Key-control setting scripts, but i'm curious as to what you might be doing with the other 13- scripts, if you would share as to the purpose of so many i would be great full.
fokkonaut
Posts: 855
Joined: Wed May 13, 2015 5:59 pm
Player profile: https://ddnet.tw/players/fokkonaut

Re: Take Binding to the next level, with Scripting!

Post by fokkonaut »

nah i dont want to give them to everybody but ill send u a pm when im home

edit: most of the cfgs are just normal binds like toggle dummy hammer or copy moves but with echos so i can see in chat if its on or off (for example to avoid killing the main tee while playing with dummy and kill)
RE3SES
Posts: 15
Joined: Sat Dec 16, 2017 8:27 am

Re: Take Binding to the next level, with Scripting!

Post by RE3SES »

uhm... what language was used in this? batch? :oops: :oops:
fokkonaut
Posts: 855
Joined: Wed May 13, 2015 5:59 pm
Player profile: https://ddnet.tw/players/fokkonaut

Re: Take Binding to the next level, with Scripting!

Post by fokkonaut »

RE3SES wrote: Sat Dec 16, 2017 8:36 am uhm... what language was used in this? batch? :oops: :oops:
teeworlds console xD its just commands from teeworlds
User avatar
Valen_4
Posts: 5
Joined: Sat Mar 03, 2018 8:11 pm
Location: Argentina
Player profile: https://ddnet.tw/players/Valen-95-
Clan: TElite

Re: Take Binding to the next level, with Scripting!

Post by Valen_4 »

I was wondering if scripting on TeeWorlds is as complete as in TF2.
Is there something like Aliases and Wait on TeeWorlds?
GG Kid
Posts: 266
Joined: Sun Apr 16, 2017 2:33 am
Location: U.S.A.
Player profile: https://ddnet.tw/players/Bolto/
Clan: Kerger

Re: Take Binding to the next level, with Scripting!

Post by GG Kid »

i wish, so no sorry it's a very limited, i even asked one of the Main Developers {heinrich5991} & Deen about this. best solution appears to be using a client that supports LUA like ATH. getting started in Lua . there are so many it's hard to keep up some times, but only a few are really worth using.
dorothybarnes
Posts: 2
Joined: Fri Nov 17, 2017 12:56 pm

Re: Take Binding to the next level, with Scripting!

Post by dorothybarnes »

Personally, I prefer to use zenmode. It is really useful
Hi to every player on this forum! My favourite map is book of ra demo play now. Have you tried it?
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests