This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

trivia by souperman problem with my memory shell :(

Old posts that have not been replied to for several years.
Locked
u
up^to^you

trivia by souperman problem with my memory shell :(

Post by up^to^you »

hi... i use trivia by souperman and i like it very much, usually i ask my question in his forum but curently i cant reach his site (dont know why) and this is emergency problem for me. You know, that script use only one file for question but my shell have problem with memory ( i cant load a big file size) because it often get killed after a few questions showed, but it would not be happen if i decrease my userfile size, so...i try to write myself a modify at that part but it didnt work :(
this bellow is scripts that i wrote/modify on trivia script in order to devide that userfile question into 2 part (2 files) that will be choose randomly every 10 minutes

first thing i set:
set tgqdb "/usr/bla/bla/bla/trivia.question"

into:

set tgqdb ""

then i write these things:

#TEST

set filerandomtimer 10

timer $filerandomtimer randomfile

proc randomfile {} {
global filerandomtimer botnick

if {$tgqdb == "/usr/home/bla/scripts/question1"} {
set tgqdb "/usr/home/bla/scripts/question2"
}
} else {
set tgqdb "/usr/home/bla/scripts/question1"
timer $filerandomtimer randomfile
}
}
#

but this script did'nt work and i dont know where's wrong, when i try to load my bot in shell there's a message error like this:

[02:12] Tcl error in file 'trivegg':
[02:12] wrong # args: should be "proc name args body"
while executing
"proc randomfile {} {
global filerandomtimer botnick

if {$tgqdb == "/usr/home/bla/scripts/question1"} {
set tgqdb "/usr/home/bla/scri..."
(file "scripts/test.tcl" line 259)
invoked from within
"source scripts/test.tcl"
(file "bot" line 205)
[02:12] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
-bash-2.05b$

Is there any 1 can help me pls? i dont know much about tcl, but i dont wanna my bot get killed anymore, so i'll apreciate any help from you guys :(
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Use somthing like this.

Code: Select all

set tgqdb "/usr/home/bla/scripts/question1"

set filerandomtimer 10

proc randomqfile {} {
  global filerandomtimer tgqdb
  if {$tgqdb == "/usr/home/bla/scripts/question1"} {
    set tgqdb "/usr/home/bla/scripts/question2"
  } else {
    set tgqdb "/usr/home/bla/scripts/question1"
  }
  timer $filerandomtimer randomqfile
}

timer $filerandomtimer randomqfile
You could further split the files again, and use this instead. This one uses 5 files.

Code: Select all

set tgqdb "/usr/home/bla/scripts/question1"

set filerandomtimer 10

#Set this to the number of question files you have
set rannumfile 5

proc randomqfile {} {
  global filerandomtimer tgqdb rannumfile
  set tgqdb "/usr/home/bla/scripts/question[expr [rand $rannumfile] + 1]"
  timer $filerandomtimer randomqfile
}

timer $filerandomtimer randomqfile
In this, you need to name your files.
/usr/home/bla/scripts/question1
/usr/home/bla/scripts/question2
/usr/home/bla/scripts/question3
/usr/home/bla/scripts/question4
/usr/home/bla/scripts/question5
u
up^to^you

hmm....??

Post by up^to^you »

thanks for Oizoken who help me out from this trouble :)

after i delete unneed bracket "}" before }else{

this scripts can be loaded but..there's a new problem said :

test.tcl /usr/home/bla/scripts/file1 does not exist, failed to load. so the game is cannot be run

Actually this file has already exist but maybe my bot didnt know it because i set tgqdb ""

so...what should i do??

is there any way so my eggdrop can load that file?

do i should set tgqdb "" to "/usr/home/bla/scripts/file1" ?

and if i set tgqdb "" to "/usr/home/bla/scripts/file1"

then...it seems random script that i made didnt run, because it said message like this:

[04:31] Tcl error in script for 'timer591':
[04:31] can't read "tgqdb": no such variable

:cry: :-? help me will ya?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

The reason is says no much cariable, is in reality, it doesn't.

Code: Select all

set a "hello"
proc test {} {
  set a "goodbye"
}
test
puts stdout "$a"
These are 2 different varaibles, because they are called at different levels of the script.

To change the value of a in the proc test, you need to tell the proc to use the variable a, defined as hello.

You do this, using the global command

IE

Code: Select all

set a "hello"
proc test {} {
  globak a
  set a "goodbye"
}
test
puts stdout "$a"
Now the scriptw ould output "goodbye" rather than hello.

As such, you need to apply this to your scripts.
u
up^to^you

Post by up^to^you »

ic....thx ppslim :)
u
up^to^you

weird

Post by up^to^you »

hmm....i try to use both of your suggest scripts code ppslim, the fisrt i use the second code, because it looks more flexible for future update if i have another userquestion more than 2, but...seems this code didnt work well, because my bot just read file question from question1 only and never read the question2 file.
what's wrong eh? hmm....i also confuss with this prob. :-? :-?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

This is most likely, due to the fact, it reads the file on start-up.

Once the file is loaded, there is no reason for it to read the file again.

This is why you have the memory issues. Due to the fact, it has a large files contents in memory at all times.

Without a maor re-write, there is probably not much you can do (this is based on the way most scripts work).
Locked