Heya peeps im quite new to Lua and was wandering if there is a list/collection of functions.
If not then maby ppl could start sharing their functions in this thread...
hmm i think it can be found in LUA guide... it was somewhere in forum... chek the Useful links section..
cant seem to find anything :(
maby im missing it..
if anyone comes across any links to or lists of functions could you please post it in here and ill check back tommorow.
Many Thanks
Great to see you here .)
This is a great manual for LUA-coding
http://www.lua.org/manual/4.0/manual.html#pm
To scritp see the section How To Do.
Best regards, nErBoS
Thanks for that link m8
Im hoping in time i will be able to put some constructive input in to this forum but for now im a noob ( to lua anyway ) striving to take in as much as i can.
I guess im going to be living here for a good while now. :)
so the search goes on............
c'mon all you Great script writers share your knowlage and zip your functions up and post them here and give us noobs a kick start in understanding Lua in ptokax.
:) :) :) :) :)
:( :( :( :( :(
well i guess ive gotta learn the hard way as i did with VB
thx to the 2 that did respond :)
What sort of functions are you looking for?
i have a whole archive with functions...and a head full with knowleage about lua
i'm not too active right now though since i'm waiting for my new mother board to come so I can start using my own computer again..
but if you are looking for something please ask here!!
cheers mate
here comes some good functions and a good structure:
function DataArrival(tUser, sData)
if (strsub(sData, 1, 1) == "<" ) then
-- create a table
local tArgs = {}
-- Save sData in an array
tArgs = tHelpFunctions:GetArgs(sData)
-- Check if the user has used any of the hubprefixes
tArgs = tHelpFunctions:CheckIfHasPrefix(tArgs)
-- add sData as a variable to tArgs
tArgs.sData = sData
if tArgs.sPrefix then
tUser.SendMessage = tUser.SendData
local returnvalue = call(UserCommands[tArgs.sCmd],{UserCommands,tUser,tArgs}, "x", nil)
if returnvalue then
return returnvalue
else
return 0
end
else -- messages that isn't commands ends up here
end
end
end
tSettings = {
tCmdPrefixes = {"!","+","gs:","?","#","?"},
}
tHelpFunctions = {
CheckIfHasPrefix = function(self,tArgs)
sToCheck = tArgs.sCmd
local i
local err
for i = 1, getn(tSettings.tCmdPrefixes) do
if strsub(sToCheck, 1, strlen(tSettings.tCmdPrefixes[i])) == tSettings.tCmdPrefixes[i] then
tArgs.sCmd = strsub(sToCheck, strlen(tSettings.tCmdPrefixes[i])+1, strlen(sToCheck))
tArgs.sPrefix = tSettings.tCmdPrefixes[i]
break
end
end
return tArgs
end,
GetArgs = function(self,sData)
local tArgs = {}
_,_,sData = strfind(sData, "%b<>%s+(.+)|")
tArgs.sMessage = sData
sData = strlower(sData)
gsub(sData, "(%S+)", function (w) tinsert(%tArgs,w) end)
tArgs.sCmd = tArgs[1]
tremove(tArgs, 1)
return tArgs
end,
}
UserCommands = {
help = function(self, tUser, tArgs)-- for all users
-- Do your own help function here :)
return 1
end,
}
Thx for the reply m8...
im just looking for a whole collection of functions to get me started in understanding how LUA works in relation to VB then maby ill get to grips with it. :-)
start here (http://board.univ-angers.fr/thread.php?threadid=44&boardid=4&styleid=1&sid=4b7748f53b03fd8283dde54bdf3f909e)
then move to lesson 2 then 3 etc etc
thx m8 i read them when i joined but they dont tell me what im really wanting to know
EG:-
data=strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data,"%b<>%s+(%S+)") -- this converts it into cmd (the incoming data)
how does it do it. what does
s=
e=
if i wanted to brake data sent to the hub bot down what functions do i use to split this:-
$To: HubBot From: User $ +command theText
bot=HubBot
user=User
CmdPrf=+
command=command
text=theText
And the same for main chat...... ????
is there and texts that will help understand Lua In ptokaks hub software ??
yes.. the manual (http://www.lua.org/manual/4.0/manual.html)
strfind (s, pattern [, init [, plain]])
Looks for the first match of pattern in s. If it finds one, then strfind returns the indices of s where this occurrence starts and ends; otherwise, it returns nil. If the pattern specifies captures (see gsub below), the captured strings are returned as extra results. A third, optional numerical argument init specifies where to start the search; its default value is 1, and may be negative. A value of 1 as a fourth, optional argument plain turns off the pattern matching facilities, so the function does a plain ``find substring'' operation, with no characters in pattern being considered ``magic''. Note that if plain is given, then init must be given too.
so.. theres no need to remove the end pipe as you can put it in the regexp too
"this converts it into cmd" nothing gets converted. it just tries to extract the first word
you either want to use a bunch of strsubs and plain strfinds like in VB
or one strfind and a proper regexp.. ie
$To: HubBot From: User $ +command theText
local s, e, to, cmd, args = strfind(data, "^$To: (%S+) From: %S+ $%b<> %+(%a+)%s*(.*)%|$")