Toribash
Original Post
[tut]Lua Academy Of Lua
Dedicatory:
To blam, who almost teached me lua. dude ur the best.
To illepodus(idk how to write it) for making his bot,
that inspired me in my serverbot.
To Jok, hampa, developers, my clan, and to u. for reading.

Ok guys, this will be like a daily tutorial, were
i will write many things, i would love that
u comment cause i appreciate that.

Lets start some basic lua.

Lua is an easy programming language to script.
Toribash uses it and if u unleash ur imagination
u can make cool things.

Here im leaving a script i made today for explaining u
a basic concept of lua:
--Heeeyy! its me 6d23.
--You are new to lua?
--Wanna learn sum new?
--Then welcome!
--A computer is like ur brain
--Can handle many things.
--lets say ur talking with ur
--friends
myname= "6d23"
myfriend= "blan" --yeah Blan, all rights reserved =D
--These are variables, they store things.
--but when u know a friend, u store more things.
--We will explain that in next part, today.
--just this.
--now, like all chat we got a start.
function start()
--so here u tell them.. hey blan how many is 1+1?
awnser= 1+1
--he proseses it very quick and...
echo(awnser) --he sais.
--[[
what is echo??
echo is for printing(saying) in the game
something others cant see.
lamely u cant say sum other can see.
the only thing u can use is:
/whisper name text
/cp text
u cant use them like just /cp hi here
u must use a command.
and if u say more than 3 very quickly its
considered spam.
u think tahts an limitation?
NO FUCK NO.
u will learn EVERYTHING.
u will not give up bitch!
so syntax of echo:
echo(text)
]]
--u can also use this:
echo("hi")
--hey when its in "" its a string, it contains text, we will learn other type of variables.
--also we can use commands (for cp or like that) thats what we explained:
run_cmd("lm judo.tbm") -- here we will load a mod :D
end
start()
--a hook...
add_hook("enter_freeze", "ef", enterfreeze)
--[[
list of events (u can find it in startup.lua)
"new_game",
 "new_mp_game",
 "enter_frame",
 "end_game",
 "leave_game",
 "enter_freeze",
 "exit_freeze",
 "key_up",
 "key_down",
 "mouse_button_up",
 "mouse_button_down",
 "mouse_move",
 "player_select",
 "joint_select",
 "body_select",
 "draw2d",
 "draw3d",
 "play",
 "camera",
 "console",
 "bout_mouse_down",
 "bout_mouse_up",
 "bout_mouse_over",
 "bout_mouse_outside",
 "spec_mouse_down",
 "spec_mouse_up",
 "spec_mouse_over",
 "spec_mouse_outside"
 
 
syntax of hook is:
add_hook(event, identifier, function)
the identifier helps u erase da hook.
]]
--if u dont understand ask plz i love to help.
--i will continue with next tut.

Lets see...
today ive got some ideas for helping u...
--[[
Toribash Lua Example v.2.0
What it does?
says Good Luck
to 1 (only the 1st, using Tori) guy.
the thing is the "whisper command"
cool huh?
]]
spamcount=0
function entfra()
local a= get_player_info(0)
spamcount= 0
if spamcount < 3 then
spamcount= spamcount+1
run_cmd("whisper " .. a.name .. " Good luck")
else
echo("Spam Reached")
end
end
 
function start()
echo("Welcome")
end
start()
 
add_hook("enter_frame", "ef", entfra)
Hope it helps u

Here other:
--[[
Key identifying example.
when someone press Q it says "Lua owns".
]]
 
function ckey(key) --yep, key will come from the nothing, u can put other like..
-- keypressed, userkey, string, moo, wtf, lua, nonsense or watever.
if key==string.byte("q") then
echo("Lua owns")
end
end
 
add_hook("key_down", "moo" , ckey)
See you in the next tutorial...

Log:
February 13: Part 1
Last edited by 6d23; Feb 16, 2010 at 02:20 AM.