PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: NemeziS on 05 March, 2005, 17:28:12

Title: Special Jokebot
Post by: NemeziS on 05 March, 2005, 17:28:12
Hi!

I have a text file with some jokes this scheme:
---------------------
Joke1 text
Joke1 text
- La la la, - told person2
- Bla, Bla, Bla, - told person1
Joke1 text. Joke end.
---------------------
Joke2 text
Joke2 text
Joke2 text. Joke end.
---------------------
- La la la, - told person2
- Bla, Bla, Bla, - told person1
Joke3 text
Joke3 text
Joke3 text. Joke end.
---------------------

In the text file each joke is separated from other joke by "---------------------"
So I need a script that will read a joke randomly from a file on +showjoke command.
I tried JokeBot by Cloud but nothing worked good.
Could somebody write a script for showing jokes from a file with jokes separated from each other?

The joke must look like this:
[19:05:42]  [U]Random joke from jokelist:[/U]

      Joke1 text
      Joke1 text
        - La la la, - told person2
        - Bla, Bla, Bla, - told person1
      Joke1 text. Joke end.


I don't need a timer functoin. But jokes must be shown on +showjoke command.

Thanx a lot. :)

Best regards,
NemeziS
Title:
Post by: bastya_elvtars on 05 March, 2005, 17:40:40
You might want to use an array with jokes, in the following format:

Jokes={
[[Joke1 text

Joke1 text

- La la la, - told person2

- Bla, Bla, Bla, - told person1

Joke1 text. Joke end.]],

}

etc.

and use SendToAll(Jokes[(math.random(getn)Jokes)])
or like this.
Title:
Post by: NemeziS on 05 March, 2005, 17:48:57
I'm afraid it is not an easy way. I've got too many jokes. It's more than 7000. I don't think it is a good idea.  :(

My text file is rather big. It's size in Mb is ~= 6 Mb (I'm not sure.)

Best regards,
NemeziS
Title:
Post by: bastya_elvtars on 05 March, 2005, 19:18:28
Yeah, then we have to find a way to insert to an array from file. Gonna see later.
Title:
Post by: NemeziS on 05 March, 2005, 19:51:11
I tried to get some strings from Jumble game script. But I didn't get success.  :(  Maybe you can try too.

Best regards,
NemeziS
Title:
Post by: NemeziS on 08 March, 2005, 17:29:24
Hi, bastya_elvtars!
Have you tryed to write this one yet?  :P ( [in lua4 wanted] )

Please help!  :(
Best regards,
NemeziS