PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: ???M?N??R?????? on 14 October, 2004, 10:49:53

Title: I'm e "newbie" of SCRIPT !!! for DCDM client
Post by: ???M?N??R?????? on 14 October, 2004, 10:49:53
Hi at ALL !!!! I m an italian Boy , so i speak little ENGLISH !
So , i ask u for an HELP!!!

I have DCDM Client , but  i   don t understand the Script of this!!!I want to personalize my DCDM with the SCRIPT !!

But i don t understand , if that script ARE .lua  but , with extension !!!
example :

dcpp:setListener( "chat","ciao",
   function (hub,user,text)

Thsi code there isn t in .lua code!!!or not!?!?
So I ask u a DOC for this type of script !!!?!?

Title:
Post by: Herodes on 14 October, 2004, 11:25:42
use Notepad to write your script ...

then dont save with .txt but save with .lua extension ...

then put it in the scripts folder ...

After that there are two ways to start it ...

in the chat of dcdm/bcdc write :    

/luafile your_file's_name.lua

or

in the startup write :

dofile("your_file's_name.lua")

near the bottom ...
Title:
Post by: ???M?N??R?????? on 14 October, 2004, 15:48:47
k !!! ^_^
Now , i want know , if is possible!!! , the parameter of :  

function (chat , user , txt ) !!!!! .....and much morE???
Function (pm , user ) ????.......

I understand  fuction (chat ,user , txt ) ,but i don know other parameter !!!
 
there is a LIST , a DOC , for KNOW the PARAMETER to PASS at FUNCTION?!?! !!!! :??
Title:
Post by: Herodes on 14 October, 2004, 16:05:02
dcpp:setListener( "chat", "bier",
function( hub, user, text )
local s = string.lower( text )
if string.find( s, "[^a-z]bier+[^a-z]" ) or string.find( s, "[^a-z]biertje[^a-z]" ) then
hub:sendChat( "bier? ja lekker! :)" )
end
end
)
This is the example listener from startup.lua ....

watch it carefully ..

setListener is found in the startup.lua ... and it is like this ...
dcpp.setListener = function( this, ltype, id, func )
if not dcpp._listeners[ltype] then
dcpp._listeners[ltype] = {}
end
dcpp._listeners[ltype][id] = func
end
a general description to setup a listener is like this ...
dcpp:setListener(what_to_listen, the_name_of_this_listener,  function(argument1, argument2 ,.... )
-- Whatever you want this listener to do ...
end
)
Why you ask "where the variable 'this' went??" u ask .. well there is the trick ...

dcpp.setListener = function( this, ltype, id, func )is the same with saying dcpp:setListener(ltype,id,func)
the " : " passes the dcpp table as an arggument to the function ..

more ltypes are :

chat /// f( hub, user, "message" )

ownChat   //// f( hub, "message" )

ownChatOut /// f( hub, "message" )

pm /// f( hub, user, "message" )

hubPm /// f( hub, user, "message which may include a " )

connected /// f( hub )

disconnected /// f( hub )

userConnected /// f( hub, user )

userMyInfo /// f( hub, user, "$MyINFO $ALL ... 1234$|" )

userQuit /// f( hub, user )

timer /// called every second, use dcpp:getHubs()[k]:getAddress() to select a hub
  f()

more info on their use look in startup.lua ... go in Ctrl+F and search it .... or the rest of the default scripts ...

Also some others made by ppl around here and in other forums may help ...
Title:
Post by: ???M?N??R?????? on 14 October, 2004, 20:56:11
Thankz !!!! HERODES !! ^__________^  

Now iI try !!!!! :p
Title:
Post by: Herodes on 15 October, 2004, 13:34:57
QuoteOriginally posted by ???M?N??R??????
Thankz !!!! HERODES !! ^__________^  

Now iI try !!!!! :p
you are welcome ...
good luck ...
Title:
Post by: ???M?N??R?????? on 16 October, 2004, 10:13:09
RE-Thankz!!!! :P !!!!
If I have any problem , I ask U !!! :))

mmmmmm , now i Think :P  ,   the parameter of :

hub:sendChat ( "" ) ?? are the same of  function(=>hub , user , text ) .. ??

so , exmaple user: sendPM ("") , is correct?
Title:
Post by: Herodes on 16 October, 2004, 13:58:46
no it is not ...

show me the script u are working on and i will try to help ...
Title:
Post by: ???M?N??R?????? on 16 October, 2004, 15:31:53
For example , i Want DO (and i know it isn t EASY) an ANti Spam for my  y hub with DCDM!!! So , i want Scanner ALL pvt of user ,and when i found a  hub adress  i KICK this user !!! but I DOn t KNOW the function for scanner PVT !!!! :??

HELPPPPPP  :(  :(
Title:
Post by: Herodes on 16 October, 2004, 19:03:49
you cant scan pm's in yhub ... and that anti spam scirpt you are talking of is not simple in nature ...

spam/flood can be expressed in more ways that MainChat and PMs ... like $MyINFO , $Search ....

before you start your script you need to know what is it exactly that you need to script ...

make up your mind and then I'll help you to find out if it is possible to do it ...
Title:
Post by: ???M?N??R?????? on 17 October, 2004, 02:21:39
mmmmmmmmmmm .......Its not Easy really?!!?!
but , i don t KNOW :  $MyINFO , $Search ....  !!!! U have a guide?!?! or a texto for the lesson of  like $MyINFO , $Search .... ?!?!!?

so , for scan MAIN CHAT is possible , the impossible is the PVT !!! AZZ
Title:
Post by: ???M?N??R?????? on 19 October, 2004, 14:43:03
HEYYYYY !!!!

do u have a guide for   $MyInfo  or  $Search ?!?!?!!!

Quotebefore you start your script you need to know what is it exactly that you need to script ...

but , I asked U a Guide , or a little lesson !!!! :P :P
Title:
Post by: Herodes on 19 October, 2004, 18:25:30
Look in the DC Protocol Documentation (http://wza.digitalbrains.com/DC/doc/Introduction.html) ... under the Command Types (client to server) (http://wza.digitalbrains.com/DC/doc/Command_Types_(client_to_server).html) part ...

as for grabbing stuff from it do a search in this forum for " $MyINFO $ALL%s(%S+) " and you will meet some nice strfind lines ... use those ...
but remember that the scripts in here are Lua4 client-side uses Lua5 ..
so strfind = string.find and so on ..
regular expressions remain the same ...