mIRC Home    About    Download    Register    News    Help

Print Thread
#93839 12/08/04 04:51 PM
G
Gremel
Gremel
G
What I am trying to come up with is a script that pulls to random things from and puts them in the final result. What I was wodnering is which way would be better? I was thinking of these two methods.

Mehtod One: A alias that basically would allow me to type /slap nick and it would perform two $read. The end reult would be:

/me slaps{first $read} with a baseball bat. {second $read}
/me cuffs{first $read} with a trout. {second $read}

I know this method is possible and know how to do it, but I am wondering which would be faster and easier. This method or the following:



Method Two: Making two seperate hash tables with entries like:
1 slaps
2 slaps
etc.

1 with a baseball bat.
2 with a trout.
etc.

What I was then thinking was having a $rand to coem up with a number and then search for it in the hash table and return the value that corresponds with it. I was also thinking I could even combine the two tables be making the sentences be double digit numbers ie) 51, 52, etc.

Problem with this method is I am not certain if it would work, though I think it would as it sounds like it would. Second problem is I don't know how to put it together. So I come here for help.

Could anyone tell me which way would be better and faster and if the has table, which I hope it is as I would love to get more experiecne with them, how to put it together please.

Joined: Dec 2002
Posts: 787
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 787
Anyway will make little, or no difference since the speed would be millisecond differences.

Single hash file.. add them using.

/hadd -m tablename N action¬comment

Note; action and comment are seperated by, ¬ which is $asc() number 172

Where, tablename is the hashtables name, N is the Nth number added, 1, 2, 3, 4, or you can just use $calc($hget(tablename,0).item + 1) to calculate the Nth number automatically in a sequence, action would be i.e. slaps, hits, knocks, and comment would be with baseball bat, with hammer, ect.

Then you would use.. //echo -> $hget(tablename,$rand(1,$hget(tablename,0).item)).data

to return a random entry in the form.

action¬comment

then you simple use, $gettok($hget(tablename,$rand(1,$hget(tablename,0).item)).data,1,172) to get the 'action' and $gettok($hget(tablename,$rand(1,$hget(tablename,0).item)).data,2-,172) to get the comment.

Hope this helps, if you need more explaining, just ask.

G
Gremel
Gremel
G
Sorry to say it but you totally lost me there frown

Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
I would aproach this using the $read command. For this to work I would need two files (e.g. verb.txt and withObj.txt). I think you can see that the first file holds single words like "slaps", "hits", "tickles" etc. The second file holds phrases like "a base ball bat", "a trout", "five ostrich feathers" etc.

So the command would be:
/me $read(verb.txt) $$1 with $read(withObj.txt) !!! *grin* *silly face*

where $$! is the highlighted nick for the nicklist (or command line or whatever). Of course, you could find a way of inserting a random nick (such as $nick(#,rand(1,$nick#(0))) which then gives:

/me $read(verb.txt) $nick(#,rand(1,$nick#(0))) with $read(withObj.txt) !!! *grin* *silly face*

Cheers,

DK

(editted to remove symptoms of severe DK-itis)!

Last edited by Darwin_Koala; 13/08/04 06:38 AM.
Joined: Dec 2002
Posts: 787
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 787
hmmz yea did seem kinda long winded, sowwie wink

Eamonn.

Joined: Feb 2004
Posts: 714
Z
Hoopy frood
Offline
Hoopy frood
Z
Joined: Feb 2004
Posts: 714
There are 2 typos in the following command:
/me $read(verb.txt) $nick(#,rand(1,$nick#(0))) with $read(withObj.txt) !!! *grin* *silly face*

This is the correct command:
/me $read(verb.txt) $nick(#,$rand(1,$nick(#,0))) with $read(withObj.txt) !!! *grin* *silly face*

Zyzzyx smile

Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
LOL, see, even when I edit for typos, more typos appear! Thst's DK-itis for you!

Thanks for correcting them :-)

Cheers,

DK.


Link Copied to Clipboard