Author Topic: Ptokax text commands?  (Read 7455 times)

0 Members and 1 Guest are viewing this topic.

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
Ptokax text commands?
« on: 18 November, 2005, 15:49:52 »
Hi,

My hub has been runned by ynhub earlier and i figure out that ptokax woudn't been bad.. :)

Now here's my problem. With Ynhub i could create a text commands that:
- Only shows in main and is broadcasted to everyone..
ex: If someone want's to tell the entire hub in main that his go to bed i had a ASCII picture for that...

Is that possible in ptokax?

Please help me

Deeds

PtokaX forum

Ptokax text commands?
« on: 18 November, 2005, 15:49:52 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 730
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
(No subject)
« Reply #1 on: 18 November, 2005, 15:55:11 »
So basically it displays a text file. I. e. +bed show an ASCII art and shows: "Joe is going to bed.", where joe is the actual user's name. Or not?
Everything could have been anything else and it would have just as much meaning.

Offline UwV

  • Scripter
  • Lord
  • ******
  • Posts: 321
  • Karma: +38/-0
  • Music = Love
    • homepages
(No subject)
« Reply #2 on: 18 November, 2005, 15:55:54 »
a three step plan..

1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

 & don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #3 on: 18 November, 2005, 16:18:45 »
-----------------------------------
a three step plan..

1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime

-----------------------------------

Well UwV...
It's not that simple,,,, yes now i got the text command.
But it's sent in pm and only to "the one that writing"!

I would like to have it in MAIN and sent to everyone...

Offline Dessamator

  • Scripter
  • Emperor
  • ******
  • Posts: 1 262
  • Karma: +13/-9
(No subject)
« Reply #4 on: 18 November, 2005, 17:42:48 »
There are quite a lot of scripts that do that, just Search the forum
Ignorance is Bliss.

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #5 on: 18 November, 2005, 17:54:43 »
Do you got any good examples that works?

Offline ??????Hawk??????

  • Emperor
  • **
  • Posts: 1 044
  • Karma: +12/-2
    • Leeds Laptop Repairs
(No subject)
« Reply #6 on: 18 November, 2005, 18:35:40 »
Quote
Originally posted by d-deeds
Do you got any good examples that works?

Yes  we got loads of good Examples ...  


You could too IF only you used the forums Search..

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #7 on: 18 November, 2005, 19:41:30 »
i didn't find very much...
but i find "hawk"s  script with ascii,,, this is probably not what i search for? or isit?

/deeds


-- Yet another version AsciiTexter Bot
--  By ??????Hawk?????? 03/07/2005
-- Create an   ascii folder within the scripts folder and copy all your ascii files in.

AsciiBotName =  botname   --// Set Bot name here

SendTo = { --> 1=on/0=off
[0] = 1, -- Masters
[1] = 1, -- Operators
[2] = 1, -- Vips
[3] = 1, -- Regs
[4] = 1, -- Moderator
[5] = 1, -- NetFounder
[-1] = 1, -- Users
}  



function ChatArrival(curUser, data)
   data = string.sub(data,1,string.len(data)-1)
   local _,_,PRFX,text = string.find( data, "%b<>%s+(%S)(%S+).*" )   
      if PRFX == Prefix and text and AsciiTable[text] then         
            local handle,Er = io.open("ascii/"..text..".txt", "r")
            if handle then                        
               local line = handle:read("*l")
               TempAsciifile = "\r\n"
                  while line do
                     TempAsciifile = TempAsciifile.."\r\n"..line
                     line =handle:read("*l")
                  end
               handle:close()
            end
            SendToAll(AsciiBotName, "<"..curUser.sName..">\r\n"..TempAsciifile)
         return 1
      end
end



function Main()
   Prefix = "+"
   AsciiTable = {}
   local sDirectory = "ascii"
      local sFileName = "nn.txt"
      local sLine = nil;
      os.execute("dir /b /a-d \""..sDirectory.."\" > \""..sFileName.."\"");
      local ahFile,e = io.open(sFileName,"r")  
      sLine = ahFile:read("*l");
   sLine = string.sub(sLine, 1, (string.len(sLine)-4))
   AsciiTable[sLine] = 1
         while ( sLine ) do
            sLine = ahFile:read("*l");
            if sLine ~= nil then
               sLine = string.sub(sLine, 1, (string.len(sLine)-4))
               AsciiTable[sLine] = 1
            end
         end
      ahFile:close()
         os.remove(sFileName);
end

Offline ??????Hawk??????

  • Emperor
  • **
  • Posts: 1 044
  • Karma: +12/-2
    • Leeds Laptop Repairs
(No subject)
« Reply #8 on: 18 November, 2005, 19:45:57 »
for your needs you are "probably " best following UwV's suggestion..


Quote
Originally posted by UwV
a three step plan..

1. enable textfiles support ..
2. put a file named "bedtime.txt" in ptokaxfolder/txt and paste your ascii of the bed in there.
3. use command !bedtime


??????Hawk??????
« Last Edit: 18 November, 2005, 19:48:25 by ??????Hawk?????? »

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #9 on: 18 November, 2005, 19:49:46 »
yes but then it's not useful..

the idea is that a person can tell the entire hub something in main with a command...

Uwv's sugestion is very good, but it's sent to the one that writing and in pm... :)

/deeds

Offline ??????Hawk??????

  • Emperor
  • **
  • Posts: 1 044
  • Karma: +12/-2
    • Leeds Laptop Repairs
(No subject)
« Reply #10 on: 18 November, 2005, 19:58:25 »
ahhh  ic  ..  

the script you posted should work for you  ..

create a folder in your scripts folder called  '   ascii  '
and put all your ascii text files in it  ...


??????Hawk??????

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #11 on: 18 November, 2005, 20:08:27 »
well... it works...

but i can't get any message in main,,, well,,, nothing happends at all... i can't even see the command i've typed in main +bed

Offline ??????Hawk??????

  • Emperor
  • **
  • Posts: 1 044
  • Karma: +12/-2
    • Leeds Laptop Repairs
(No subject)
« Reply #12 on: 18 November, 2005, 20:30:33 »
Quote
Originally posted by d-deeds
well... it works...

but i can't get any message in main,,, well,,, nothing happends at all... i can't even see the command i've typed in main +bed

does the file   bed.txt  exist in the ascii folder  ... ?

AND  did you restart scripts when you put the text file in  ..  ?


??????Hawk??????

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #13 on: 19 November, 2005, 01:19:38 »
yes and yes...

Offline GeceBekcisi

  • Scripter
  • Lord
  • ******
  • Posts: 311
  • Karma: +10/-1
  • You don't need eyes to see, you need vision..
(No subject)
« Reply #14 on: 19 November, 2005, 03:49:09 »
This sample code can show you where to start, because LUA is really very easy and is fun to work with.
Code: [Select]
-- Reads 'sFile' and sends it to main when command
-- '!bed', '+bed', '?bed', '#bed' is sent to main chat
-- by GeceBekcisi

sBotName = frmHub:GetHubBotName()
sFile = "ascii/bed.txt"

function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
if cmd == "bed" then
local filedata ="\r\n\r\n"
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata..curUser.sName.." goes to bed and says: Good night all!\r\n")
return 1
end
end
Play with code, and please feel free to ask about anything. Best regards
« Last Edit: 19 November, 2005, 03:56:09 by GeceBekcisi »
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #15 on: 19 November, 2005, 04:31:35 »
THANKS GECEBEKCISI!!!!

That did work just perfect...

Just one tiny little thing...
how do i change in the script so the text "nick goes to bed and says: Good night all! " comes before the ascii? :)


Thank you again VERY MUCH!!
/deeds

Offline GeceBekcisi

  • Scripter
  • Lord
  • ******
  • Posts: 311
  • Karma: +10/-1
  • You don't need eyes to see, you need vision..
(No subject)
« Reply #16 on: 19 November, 2005, 06:13:48 »
You're welcome mate and here it goes: Just change
Code: [Select]
local filedata ="\r\n\r\n"
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata[COLOR=red]..curUser.sName.." goes to bed and says: Good night all!\r\n"[/COLOR])
to
Code: [Select]
local filedata ="\r\n\r\n"[COLOR=red]..curUser.sName.." goes to bed and says: Good night all!\r\n"[/COLOR]
for line in io.lines(sFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
I hope you see how easy it is in fact ;)
Best Regards
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

Offline d-deeds

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
(No subject)
« Reply #17 on: 19 November, 2005, 15:52:11 »
So if i would use two of them they would look like this:
(but if i use that one, only "+rock" works???)

------------------------------

-- Reads 'sFile' and sends it to main when command
-- '!bed', '+bed', '?bed', '#bed' is sent to main chat
-- by GeceBekcisi

sBotName = frmHub:GetHubBotName()
sFile = "ascii/nn.txt"

function ChatArrival(curUser, data)
   local data = string.sub(data,1, -2)
   local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
   if cmd == "nn" then
      local filedata ="\r\n\r\n"..curUser.sName.."  Goes to bed, and wish you all.. \r\n"
      for line in io.lines(sFile) do
         filedata = filedata..line.."\r\n"
      end
      SendToAll(sBotName, filedata)
      return 1
   end

end

sBotName = frmHub:GetHubBotName()
sFile = "ascii/rock.txt"

function ChatArrival(curUser, data)
   local data = string.sub(data,1, -2)
   local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)")
   if cmd == "rock" then
      local filedata ="\r\n\r\n"..curUser.sName.."  headbangs and hope that the rest of the hub are with him? \r\n"
      for line in io.lines(sFile) do
         filedata = filedata..line.."\r\n"
      end
      SendToAll(sBotName, filedata)
      return 1
   end

end

Offline GeceBekcisi

  • Scripter
  • Lord
  • ******
  • Posts: 311
  • Karma: +10/-1
  • You don't need eyes to see, you need vision..
(No subject)
« Reply #18 on: 19 November, 2005, 21:34:00 »
Hmm first of all, you need to understand you can define unique functions and you must define unique strings only once in a script (unless you need to define a string again), with only one equation mark..

If I type
Code: [Select]
sString = "StringValue1"sString will be equal to "StringValue1" whenever I call it in my script. But if I type
Code: [Select]
sString = "StringValue1"
...
sString = "StringValue2"
sString will be equal to "StringValue2" whenever I call it in my script. And also if I type
Code: [Select]
sString = "StringValue1"
...
sString = "StringValue1"
sString will be equal to "StringValue1" whenever I call it in my script. So there is no need to write it again.


And also, in a script two functions of same name will confuse PtokaX, so here you go:
Code: [Select]
-- Reads files and sends it to main when command typed to main chat
-- by GeceBekcisi

sBotName = frmHub:GetHubBotName()
sBedFile = "ascii/nn.txt"
sRockFile = "ascii/rock.txt"

function ChatArrival(curUser, data)
local data = string.sub(data,1, -2)
local s,e,cmd = string.find(data, "%b<>%s[%!%+%?%#%+](%S+)" )
if cmd == "bed" then
local filedata = "\r\n\r\n"..curUser.sName.." goes to bed and says: Good night all!\r\n"
for line in io.lines(sBedFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
return 1
end
if cmd == "rock" then
local filedata = "\r\n\r\n"..curUser.sName.." headbangs and hope that the rest of the hub are with him? \r\n"
for line in io.lines(sRockFile) do
filedata = filedata..line.."\r\n"
end
SendToAll(sBotName, filedata)
return 1
end
end

And please use [C0DE] and [/C0DE] (and don't forget to replace C0DE with CODE when posting ;)) to wrap script codes when posting.
Best regards.
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

PtokaX forum

(No subject)
« Reply #18 on: 19 November, 2005, 21:34:00 »