mIRC Home    About    Download    Register    News    Help

Print Thread
#208203 15/01/09 09:53 PM
Joined: Jan 2009
Posts: 4
N
nicoo Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Jan 2009
Posts: 4
Hey,

I have this code for a scramble game (actually it's longer but this is only relevant)

Code:
on $*:TEXT:/^[!@.]scram(ble)?$/Si:#: {
  if (%scram.scramword) { .msg $chan Theres already a scramble game going! The current scrambled word is $qt(%scram.scramword) }
  else {    
    set %scram.origword $read(wl.txt)
    set %scram.scramword $scramble(%scram.origword)
    .msg $chan Scrambled word is $qt(%scram.scramword)
  }
}
on *:TEXT:*:#: {
  if (%scram.scramword) {
    if ($1 == %scram.origword) {
      writeini Scramble.ini points $nick $iif($readini(Scramble.ini,points,$nick),$calc($readini(Scramble.ini,points,$nick) + 5),5)
      .msg $chan That's correct! Great job $nick $+ ! You now have $readini(Scramble.ini,points,$nick) Points.
      unset %scram.*
      set %scram.origword $read(wl.txt)
      set %scram.scramword $scramble(%scram.origword)
      .msg $chan Scrambled word is $qt(%scram.scramword)
    }
  }
}

alias scramble {
  var %c
  while ($calc(1+$numtok(%c,32)) <= $len($1)) %c = $instok(%c,$mid($1,$v1,1),$r(0,$v1),32)
  return %c
}


And it works for 1 or 2 times ok. But after that it crashes. If I replace "$read(wl.txt)" with "test" it does work. So I guess the problem is reading wl.txt, however, the first or second time that also works.

Can anyone please help me with my problem? Thanks in advance!

Greetz,
Nicoo

Btw, this script is mostly from hawkee.com

Last edited by nicoo; 15/01/09 09:54 PM.
Joined: Jan 2007
Posts: 1,155
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,155
Script works fine for me but I don't have your text file. Im curious what's in it. If the text file is ok it's probably another script that is crashing your mIRC.

Try just running words from the text file through the scramble alias.

Run this to check scrambling every word in your text file.
Code:
alias test_s {
if (!$window(@test_s)) { window -e @test_s }
var %ty = $lines(wl.txt), %tn | while (%ty) {
%tn = $read(wl.txt,%ty)
echo @test_s %tn :-: $scramble(%tn)
dec %ty
}
}

Joined: Jan 2009
Posts: 4
N
nicoo Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Jan 2009
Posts: 4
Thank you for your reply.

It seems that the script crashes (also your alias) if I have a space (" ") in one of my lines. That's why it worked for 1 or 2 times but as soon there was a line with 2 words it crashed.

I assume this is not supposed to happen? Is there a possible explanation for this? And, most important, can I fix it?

I already tried to use an old mIRC (6.0.3 I believe it was), but that didn't work either.

Hopefully someone can help me. Thanks in advance.

Joined: Jan 2007
Posts: 1,155
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,155
Well it depends on how the text file is written, I guess you could $remove($1,$chr(32)) in your scramble code ... Seems better to just remove any spaces in your text file. smile

Joined: Jan 2009
Posts: 4
N
nicoo Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Jan 2009
Posts: 4
I tried some things and it seemed that the 'problem' was in: "$istok(..,..,32)" not really in $read

Now I changed all my spaces in my text file to underscores (_). And at the check I use:
Code:
if ($1- == $replace(%scram.origword,$chr(95),$chr(32))) {

That works great.

So: tuha_okny is thank you. Thank you cool




Joined: Jul 2006
Posts: 4,019
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,019
mIRC is not crashing, when there's space in $1-, it's simply making an infinite loop, you can use control + pause to break it instead of waiting smile.
Also you might want to change the scramble alias so it use each word separately


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2009
Posts: 4
N
nicoo Offline OP
Self-satisified door
OP Offline
Self-satisified door
N
Joined: Jan 2009
Posts: 4
Ok, that's why.

Wish I knew that control+pause earlier, now I closed it 25 times with ctrl+alt+delete grin (takes a little bit longer lol)

For now this works fine for me but using each word separately would be better indeed. I will see what I will use.

Thank you for your reply.

Joined: Apr 2003
Posts: 341
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 341
This again brings up the issue that mIRC does NOT correctly parse spaces! This *needs* to be fixed! A space is a character, no different than a letter or number.

My hope that is will be fixed some day? Next to nil. But it's an embarrassment that it can't.

Joined: Jul 2006
Posts: 4,019
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,019
mIRC does correctly parse space, the only thing that should be fixed is the scramble alias.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Almost every post from you is nothing but bitching in the most annoying, rude and offensive ways. Your comments reek of bitterness and aren't constructive in any way (in some cases they are even dangerously irresponsible). If mIRC (or IRC in general) really upsets you so much, then by all means take a long break - you'll be doing everybody a favour.


Link Copied to Clipboard