PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: gathering on 15 December, 2004, 16:01:37

Title: *.txt problem
Post by: gathering on 15 December, 2004, 16:01:37
got a problem is thare away to meke ptokax writ the nick on a person if the text is from a txt file
Title:
Post by: Herodes on 15 December, 2004, 16:17:23
sure there is ..
Nightlitch used smth like
gsub(text, strfind(text, ("regexp_for_string_to_find")), user.sName)

in his Advanced MOTD script ..
Title:
Post by: gathering on 15 December, 2004, 16:39:23
whare shall i write it???
Title:
Post by: Herodes on 15 December, 2004, 16:41:12
what is your text file like ?
Title:
Post by: gathering on 15 December, 2004, 16:44:26
A  
                    < * >                                                             *
 *                  /.-.\         *                   *                  *
          *         /&\                    *
                 ,@.*;@,                                        *                     *                  *
                  /_o.I \    *      
               / ;--.  ,__  ')             *                               *                  *                   *
             ;@ o O,* ' &\
           *  ( '--)_@ ;o ()\      *                 *              Merry Christmas
            / ;--._ ''--._O'@;                                 and a happy new year          *
           /&*,() o ;-.,_  "" )                                    to  all on SVCD                   *
          / ,@ ;+& () o* ;-';\                                
         ( ""--.,_0 +@' &()\                       *                          
         /-.,_      ''--....-' )  *                                                                           *
   *    /@o :;'--,.__   __.'\                                                        *
     ;*,&(); @ &^;  " o;@();         *                   *                  
     /(); o^ ; & ().o@*& ;&\                                              *
   "="==""==,,,.,="=="==="                                          
  __.----.(\-''#####---...___...-----


like this
Title:
Post by: Herodes on 15 December, 2004, 16:52:05
to start with,.. ascii art text isnt the best thing to match a regular expression ... it was too many characters you will need so that you can signal what text is to be replaced ...

Anyway this is the principle to follow...

consider this string :  
str = "Mery Christmas [user]"
If I want to replace "[user]" with my nick "Herodes" I would need to do  this :
str = gsub( str, strfind(str, "%[user%]", "Herodes" )
now the variable str will return :
str = "Merry Christmas Herodes"
Title:
Post by: gathering on 15 December, 2004, 16:55:53
this has to be put in a .lua file right?
Title:
Post by: bastya_elvtars on 16 December, 2004, 17:22:01
what that all shouldlook like? i do not understand at all.
Title:
Post by: gathering on 16 December, 2004, 22:15:15
I just need to get the nick from a user when he is writing the CMD for the *.txt file

like this


going to the toilet

going to the toilet

just like that i need the CMD to put in the TXT file