Lua Script in T2
Here's a modified t2 client that lets you run lua script...
installation:
extract to tribes2/gamedata folder
a vl2 should automatically get put to your gamedata/base/ folder, this contains console to interact with lua
t2dll.dll, tribes2_client.exe, tribes2_server.exe should be placed into gamedata/ folder
t2dll.dll contains code, must be in same folder as tribes2_client.exe and tribes2_server.exe for them to work
lua/init.lua is executed on startup
ingame press f1 to activate lua console
tscript interface with lua:
luaEval(string) - evaluate lua code
luaEval can return a value if you use return keyword:
luaEval("return 1+1") will return 2
lua commands to interface with tscript:
print(stuff), will print to the lua console
tsEval(string), will evaluate the tscript code, returns the result
ex: tsEval("commandtoserver('messagesent',\"hi\");")
tsCall(function,arg,arg,...) calls a tscript function (a string) with string arguments, returns the result of funciton call
ex: tsCall("commandtoserver",tsCall("addtaggedstring","messagesent"),"hi")
tsGetVar(string) returns the value of the global variable
ex: print(tsGetVar("$fps::real"))
in terms of performance:
tscript running fibonnaci: fib(30) takes 8.3 seconds
lua running fibonnaci: fib(30) takes 0.5 seconds
have fun ~
Edit: updated with new, possibly actually working, version
installation:
extract to tribes2/gamedata folder
a vl2 should automatically get put to your gamedata/base/ folder, this contains console to interact with lua
t2dll.dll, tribes2_client.exe, tribes2_server.exe should be placed into gamedata/ folder
t2dll.dll contains code, must be in same folder as tribes2_client.exe and tribes2_server.exe for them to work
lua/init.lua is executed on startup
ingame press f1 to activate lua console
tscript interface with lua:
luaEval(string) - evaluate lua code
luaEval can return a value if you use return keyword:
luaEval("return 1+1") will return 2
lua commands to interface with tscript:
print(stuff), will print to the lua console
tsEval(string), will evaluate the tscript code, returns the result
ex: tsEval("commandtoserver('messagesent',\"hi\");")
tsCall(function,arg,arg,...) calls a tscript function (a string) with string arguments, returns the result of funciton call
ex: tsCall("commandtoserver",tsCall("addtaggedstring","messagesent"),"hi")
tsGetVar(string) returns the value of the global variable
ex: print(tsGetVar("$fps::real"))
in terms of performance:
tscript running fibonnaci: fib(30) takes 8.3 seconds
lua running fibonnaci: fib(30) takes 0.5 seconds
have fun ~
Edit: updated with new, possibly actually working, version
Comments
I have a much bigger purpose...why do you think i hmm whenever u put interesting codes in?
(plus 50 $)
There are other benefits, too.
Neat.
Sometimes, it's just easier to lie.
It works.