PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: yepyepyep4711 on 28 March, 2004, 03:10:21

Title: ScreenCleaner - that good old cls command
Post by: yepyepyep4711 on 28 March, 2004, 03:10:21
Hi guys,

for what it's worth, my first script in lua ever. Do you remember that "cls" command from the old days? Well here it is. Imagine you typed a password in the main by mistake, someone posted something you find offensive or don't want the wolrd at large to read for whichever reason, just type !cls and the main chat will be wiped clean (well people can always scroll back, but that'll do the trick for most of them)

Enjoy!

--ScreenCleaner.lua 1.0 by yepyepyep4711
--!cls will wipe the main chat clean
--the command will be added to the rightclick menu of the OPs (optional)

botname = "ScreenCleaner"
rightclick = 1 -- if anything else than 1 rightclick menu won't appear
function DataArrival (curUser, sData)
command=strsub(sData,1,strlen(sData)-1)
s,e,cmd = strfind(command,"%b<>%s+(%S+)")
if curUser.bOperator then
if cmd=="!cls" then
SendToAll(botname, "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n")
end
end
end

function OpConnected(curUser)
if rightclick == 1 then
curUser:SendData("$UserCommand 255 7")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
end
end

PS: I'm sure it's no "elegant code", but it works ;p
Title:
Post by: ??????Hawk?????? on 28 March, 2004, 03:38:51
didnt seem to work for me..

i cant get the  user menu working. but that might be my client.


the !cls  works with this and wipes the whole main chat


--ScreenCleaner.lua 1.0 by yepyepyep4711
--!cls will wipe the main chat clean
--the command will be added to the rightclick menu of the OPs (optional)

botname = "ScreenCleaner"
rightclick = 1 -- if anything else than 1 rightclick menu won't appear
function DataArrival (curUser, sData)
command=strsub(sData,1,strlen(sData)-1)
s,e,cmd = strfind(command,"%b<>%s+(%S+)")
if curUser.bOperator then
if cmd=="!cls" then
temp = "\r\n"
  for i=1,10000,1 do
temp = temp.."\r\n"
  end
SendToAll(botname, temp)
end
end
end

function OpConnected(curUser)
if rightclick == 1 then
curUser:SendData("$UserCommand 255 7")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
end
end


Title:
Post by: tezlo on 28 March, 2004, 04:24:07
seems a bit brutal when you can just type /clear
Title:
Post by: ??????Hawk?????? on 28 March, 2004, 04:55:08
the  /clear  only wipes it from your client .  not everyone elses...
Title:
Post by: yepyepyep4711 on 28 March, 2004, 05:55:49
ok, the version from Hawk is much better. Mine has the inconvenient of that huge line of \r\n that *must* be kept together otherwise the script won't work. On the other hand, 10000 will slow the excution of the script and won't flush the main completely anyway. I've tried 50000, it still doesn't flush it entirely, but took way too much cpu time (and don't forget the bandwidth for big hubs). So I'd rather advise toward 200. That way the script stays responsive, which I find good, because most of the time when you want to hide something you want to do it quick ;)

So for all of you that just want a quick grab of the last version, here goes:
--ScreenCleaner.lua 1.1 by yepyepyep4711 and Hawk
--!cls will wipe the main chat clean
--the command will be added to the rightclick menu of the OPs (optional)

botname = "ScreenCleaner"
rightclick = 1 -- if anything else than 1 rightclick menu won't appear
function DataArrival (curUser, sData)
command=strsub(sData,1,strlen(sData)-1)
s,e,cmd = strfind(command,"%b<>%s+(%S+)")
if curUser.bOperator then
if cmd=="!cls" then
temp = "\r\n"
for i=1,200,1 do
temp = temp.."\r\n"
end
SendToAll(botname, temp)
end
end
end

function OpConnected(curUser)
if rightclick == 1 then
curUser:SendData("$UserCommand 255 7")
curUser:SendData("$UserCommand 0 3")
curUser:SendData("$UserCommand 1 2 Clear Screen$<%[mynick]> !cls|")
end
end
Title:
Post by: Tarot on 28 March, 2004, 08:56:55
lol it clear the hole main hihihihihihiihihih
Title:
Post by: Corayzon on 29 March, 2004, 04:08:29
Quote temp = "\r\n"
for i=1,10000,1 do
temp = temp.."\r\n"
end

SendToAll(botname, temp)

this is a bit silly...and what is the real need...

4*10000 bytes to each user seems a bit to much for something that just cleans the screen :/

wouldnt a smart way to go about this be something like... SendDataToAll("/clear|") :SSS