add_hook("<hook_name>", "[identifier]", <function to be executed>)
for keyboard intput there are the hooks, "key_down" and "key_up". The function you provide has to take one argument, the key that got pressed. Example:local function echoKeyCode(key)
echo(key)
end
add_hook("key_down", "echoTheDamnKeyCode", echoKeyCode) --notice the missing brackets after echoKeyCode
This will simply echo the key code of the key pressed.local function onButtenUp(mouseButton, x, y) --mouseButton: 1=left, 2=wheel, 3=right
[...]
end
add_hook([...])
Whereas mouse_move just takes x and y.Yes, they are called "hooks".
Works like this:
for keyboard intput there are the hooks, "key_down" and "key_up". The function you provide has to take one argument, the key that got pressed. Example:add_hook("<hook_name>", "[identifier]", <function to be executed>)
This will simply echo the key code of the key pressed.local function echoKeyCode(key) echo(key) end add_hook("key_down", "echoTheDamnKeyCode", echoKeyCode) --notice the missing brackets after echoKeyCode
In addition to that there is the function get_shift_key_state() which propably returns true if shift is pressed.
For mouse input there are "mouse_button_up", "mouse_button_down" and "mouse_move".
Functions for "mouse_button_up" and "mouse_button_down" have to take 3 arguments:
Whereas mouse_move just takes x and y.local function onButtenUp(mouseButton, x, y) --mouseButton: 1=left, 2=wheel, 3=right [...] end add_hook([...])
There are also "bout_mouse_down", "bout_mouse_up", "bout_mouse_over", "bout_mouse_outside", "spec_mouse_down", "spec_mouse_up", "spec_mouse_over" and
"spec_mouse_outside" but they are not really needed.
Add "ls <scriptname.lua>" to profile.tbs in your Toribash root directory (typically CGames\Toribash-version\) to autoload the script.
DeScript would load scripts for you, but I think there are a few compatibility issues and DeFransen is banned, so it's unlikely to be updated soon.
someVariable = "foo"
someOtherVariable = "bar"
aNumber = 5
thisIsATable = { "I", "am", "a", "table."}
and your script:dofile("textfile.txt")
obviously replace name by the name of your fileecho(someVariable) -- will echo "foo"
echo(someOtherVariable) -- will echo "bar"
echo(type(aNumber)) -- will echo "number"
echo(type(thisIsATable)) --will echo "table"
echo(table.concat(thisIsATable, " ") -- will echo "I am a table."
advantages: