i had join this forum long back for requesting script and now i want to try scripting which can be possible only with the help of all members and scripters of this forum.So i will like to have support of all the members of this forum and this can also help new scripter who have started there scripting recently or want to start with it and it can also reduce the pressure on most of the scripter
I WILL LIKE TO KNOW
1)how can i learn LUA language, which stuff to read or refer to learn this language.
2)i would also like to know the difference between lua 4, 5, 5.1
P.S i dont know anything about programing or scripting
thanks in advance
So, you'd like to start programming in Lua. Your holy bible should be:
- Lua book (http://www.lua.org/pil/)
- 5.1 reference manual (http://www.lua.org/manual/5.1/)
- PtokaX Wiki (http://wiki.ptokax.ath.cx/doku.php)
www.lua.org
You find all answers to your questions :D
if i may suggest its also good to look into others script and modify things and c how they work.
still i m no one to even suggest u this, but can be helpful ;)
thanks all members for u reply on my post
Quoteif i may suggest its also good to look into others script and modify things and c how they work.
still i m no one to even suggest u this, but can be helpful Wink
i have tried modifying and i can do it upto a extent by then also i am not able to write a script . i just dont qwanna modify scripts i want to create scripts
Quote from: Yahoo on 01 May, 2007, 16:54:51
i just dont qwanna modify scripts i want to create scripts
u r not alone in this.
And also we encourage lua-related discussion here, it's kinda boring to code 'can I have this in PM' issues all the time.
thanks you all the member for your support. the site and the reference manual suggested by the scripter and members are very helpful but the prob is tht they are to big and vast (boaring also) to read with my speed i will require atleast 2 months to read tht whole thing i cant manage tht much time. so can u suggest me any other way through which i can learn the language in small,simple and easy way
thanks in advance
I started with creating a simple bot. You should create one too:
- register at startup
- when a new user connects, greet her
- when a user disconnects, say goodbye
Quote from: bastya_elvtars on 02 May, 2007, 14:29:04
I started with creating a simple bot. You should create one too:
- register at startup
- when a new user connects, greet her
- when a user disconnects, say goodbye
Done :D
Quote from: bastya_elvtars on 02 May, 2007, 14:29:04
I started with creating a simple bot. You should create one too:
- register at startup
- when a new user connects, greet her
- when a user disconnects, say goodbye
here is my try
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
function NewUserConnected(user)
user:SendData(sBot, mesg)
end
OpConnected = NewUserConnected
function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected
how is it, i will like to here all suggestions but plzz be abit explainatory ;)
how do u register a bot?
i even tried to do this profile specific
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
mesg2 ="welcome home"
function NewUserConnected(user)
if user.iProfile ==0 or user.iProfile ==1 then
user:SendData(sBot, mesg2)
else
user:SendData(sBot, mesg)
end
end
function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected
it doesnt work :( what is the change needed.
thks,
If you check whether a user is registered, bRegistered would be a better choice. Registering a bot: hmm, documented.
http://wiki.ptokax.ath.cx/doku.php?id=scriptinghelp:ptokaxapi#the_frmhub_object
Quote from: achiever on 03 May, 2007, 18:50:10
function NewUserConnected(user)
if user.iProfile ==0 or user.iProfile ==1 then
Hint (SPOILER WARNING!!!) :)
This'll never be true in itself, you need to do is similarly to disconnectionQuote from: achiever on 03 May, 2007, 18:50:10
OpDisconnected = UserDisconnected
Quote from: achiever on 03 May, 2007, 18:50:10
here is my try
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
function NewUserConnected(user)
user:SendData(sBot, mesg)
end
OpConnected = NewUserConnected
function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected
This code is actually quite close. It doesn't work because the bot isn't registered, and most clients ignore messages from offline users.
To register your bot:
Main = function()
frmHub:RegBot(sBot)
end
that should do it :)
I think they don't benefit from directly telling them the solution, we should rather give them hnts.
Quote from: CrazyGuy on 03 May, 2007, 22:43:40
This code is actually quite close. It doesn't work because the bot isn't registered, and most clients ignore messages from offline users.
To register your bot:
Main = function()
frmHub:RegBot(sBot)
end
that should do it :)
For speedX example:
function Main()
frmHub:RegBot(sBot)
end
This version is most good :p
If only the second version is the one that's not working (as I've suspected), then see my post. The second version misses a line...
Quote from: Mutor on 03 May, 2007, 23:31:22There is no functional difference here.
Sure? but speedX has been only used mode funtion name() only for this my version would be more homogenous ^^
Bot = frmHub:GetHubBotName()
function Main()
frmHub:RegBot(Bot)
end
function NewUserConnected(user)
if user.bOperator then
user:SendData(Bot, "Welcome home "..user.sName)
else
user:SendData(Bot, "Welcome "..user.sName.." to "..frmHub:GetHubName())
end
end
OpConnected = NewUserConnected
function UserDisconnected(user)
SendToAll(Bot, "Goodbye "..user.sName)
end
OpDisconnected = UserDisconnected
Quote from: Naithif on 03 May, 2007, 19:28:46
Hint (SPOILER WARNING!!!) :)
This'll never be true in itself, you need to do is similarly to disconnection
naithif i did not understand this plzz explain it.
Quote from: bastya_elvtars on 03 May, 2007, 19:28:01
Registering a bot: hmm, documented.
http://wiki.ptokax.ath.cx/doku.php?id=scriptinghelp:ptokaxapi#the_frmhub_object
thks bastya this was really a good 1 :)
Quote from: bastya_elvtars on 02 May, 2007, 14:29:04
I started with creating a simple bot. You should create one too:
- register at startup
- when a new user connects, greet her
- when a user disconnects, say goodbye
Next ??
well i m trying to add some more messages and it should send random message
Quote from: achiever on 03 May, 2007, 18:50:10
i even tried to do this profile specific
sBot ="Fusion"
mesg ="this hub welcomes all regs. Hope u enjoy ur stay"
mesg1 ="Good bye!! c u soon"
mesg2 ="welcome home"
function NewUserConnected(user)
if user.iProfile ==0 or user.iProfile ==1 then
user:SendData(sBot, mesg2)
else
user:SendData(sBot, mesg)
end
end
function UserDisconnected(user)
SendToAll(sBot, mesg1)
end
OpDisconnected = UserDisconnected
Here's your post.
You got a NewUserConnected function that's targets are users. (user, reg, vip)
You got a profile check that's targets are masters, and ops
Hint 1
NewUserConnected takes all users, regs, and vips, and the if statement filters everyone of them except ops and masters. ::)Hint 2
You are missing a line that was present in version 1...
well yes got it
i had missed OpConnected = NewUserConnected
thks
Quote from: Naithif on 05 May, 2007, 01:16:03
Hint 1
NewUserConnected takes all users, regs, and vips, and the if statement filters everyone of them except ops and masters. ::)
This is not exactly true.
NewUserConnected handles all users with a profile with bIsOP = 0 , and unregistered users.
Subtle, yet important difference if you use custom profile permissions ::)
Quote from: CrazyGuy on 05 May, 2007, 13:12:59
This is not exactly true.
NewUserConnected handles all users with a profile with bIsOP = 0 , and unregistered users.
Subtle, yet important difference if you use custom profile permissions ::)
By default, me refers to default profile setting (;D)
Anyway, in 99% this is the case, also if robocop, or leviathan profiles are in use
Should I install the 'spoiler tag' plugin for howto's? ;D
if i want to display the date in the following format
Thursday, May 17, 2007 19:47
what should be my code
os.date("%A, %b %d, %Y %H:%M")
thanks for the code i will test it later
can any 1 tell me wat is wrong with the following code
sBot = frmHub:GetHubBotName()
ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p Date: %A, %b %d, %Y "))
end
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y Time: %I:%M:%S %p "))
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](User, data)
end
end
end
ToArrival = ChatArrival
i am getting the following error
zztime bot.lua:19: '}' expected (to close '{' at line 15) near 'end'
Quote from: Yahoo on 17 May, 2007, 19:49:20
thanks for the code i will test it later
can any 1 tell me wat is wrong with the following code
sBot = frmHub:GetHubBotName()
ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p Date: %A, %b %d, %Y "))
end
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y Time: %I:%M:%S %p "))
end
end,
}
if tCmds[cmd] then
return tCmds[cmd](User, data)
end
end
end
ToArrival = ChatArrival
i am getting the following error
zztime bot.lua:19: '}' expected (to close '{' at line 15) near 'end'
Hint:
You're trying to close too many times ;)
still not getting. can u tell me my mistake
@ B?stya -> Hints are just not working
(And next time if someone got a problem, then paste the script you got the error with, as line 15 is 'end,' no '{'-s there
Quotezztime bot.lua:19: '}' expected (to close '{' at line 15) near 'end'
Your problem is:
Spoiler warning!
'end' used too many times
thanks sir i got the problem
but now i am getting a new error
zztime bot.lua:17: attempt to index global 'user' (a nil value)
zztime bot.lua:20: attempt to index global 'user' (a nil value)
can any1 giv me hint
the edited script looks like this
sBot = frmHub:GetHubBotName()
ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p Date: %A, %b %d, %Y "))
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y Time: %I:%M:%S %p "))
end,
}
if tCmds[cmd] then
return tCmds[cmd](User, data)
end
end
end
ToArrival = ChatArrival
sorry sir i didnt get u can u tell a little more in brief and the full script
as Mutor has said already LUA is Case Sensitive
so change
return tCmds[cmd](User, data)
to
return tCmds[cmd](user, data)
because User is NOT = user
sBot = frmHub:GetHubBotName()
ChatArrival = function(user,data)
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
if cmd then
local tCmds = {
["time"] = function(user,data)
return user:SendData(sBot,os.date("Time: %I:%M:%S %p Date: %A, %b %d, %Y "))
end,
["date"] = function(user,data)
return user:SendData(sBot,os.date("Date: %A, %b %d, %Y Time: %I:%M:%S %p "))
end,
}
if tCmds[cmd] then
return tCmds[cmd](user, data)
end
end
end
ToArrival = ChatArrival
results in
[13:15:16] <Psycho_Chihuahua> time
[13:15:19] <Time> Time: 01:15:19 PM Date: Friday, May 18, 2007
[13:15:19] <Psycho_Chihuahua> !time
[13:15:23] <Time> Date: Friday, May 18, 2007 Time: 01:15:23 PM
[13:15:23] <Psycho_Chihuahua> !date
thanks for all the help
Could someone plzz explain me this.
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
local sBot,h,m = "Time",math.modf((os.time()-os.time(os.date"!*t"))/ 3600)
local s,e,cmd = string.find(data,"%b<>%s%p(%w+)")
the second line is the capture pattern of strings
math.modf function is used, i think for geting the fraction and integer differently (its acually used to spilt the 2 parts if m not wrong)
os.date() this fuction returns the date and time
this all i can guess but,
local sBot,h,m = "Time",math.modf(([b]os.time()-os.time(os.date"!*t"[/b]))/ 3600)
what this ((os.time()-os.time(os.date"!*t"))/ 3600) is even i would like to understand
thks,
now thats some explaination!!!
thks mutor