Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts Goto page 1, 2, 3  Next
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Tue Jul 14, 2009 7:36 am   

Recycling the numbers of deleted rooms
 
You can read the topic relating to this script on this forum thread.

I have made the script for both CMUD 2.37 (.mdb files - MSAccess database) and CMUD 3.xx (.dbm files - SQLite database).
Since CMUD 3.xx is still BETA, for the time being I will not post the script for CMUD 3.xx since the structure of .dbm files might sustain changes.

Here's the VBScript code for CMUD 2.37 (for .mdb files - MSAccess database):
I have used it numerous times and didn't notice any undesirable side effects.
Anyway, BACKUP your map file before using this script!!!

Code:
'==========================================================================
'
' VBScript Source File
'
' NAME     : Recycle_room_&_exit_numbers.vbs
' AUTHOR   : Marian Cascaval (aka Bothkill)
' E-MAIL   : MarianCascaval@yahoo.com
' DATE     : <February 5, 2009>
' COMMENT  : In the process of creating maps with CMUD 2.xx, every room you create
'            is assigned a number (you can check the number of every room by
'            hovering the mouse over the room).
'
'            The problem appears when you delete a room (or more rooms).
'            The numbers of deleted rooms are not used for creating new rooms,
'            but are skipped.
'
'            To understand the problem, let's see an example:
'            1. create a new map
'            2. create a room (this is #1)
'            3. delete room #1
'            4. create a new room (this #2); although there is only one room
'               on the map, this room is #2.
'       
'           As you can see, numbers of deleted rooms are not recycled.
'           Not such a great issue, but is annoying when you delete
'           a great number of rooms and later when creating new ones you reach
'           unrealistic room numbers.
'       
'           You can check your Mud .mdb map file to see it for yourself.
'           The "your-Mud".mdb file is a Microsoft Accesss database file
'           CMUD uses for storing your Mud map.
'       
'           Open the table "ObjectTbl" and compare the last record in the
'           "ObjId" column (this is where the room numbers are) with the
'           total number of records in that table.
'           If you have deleted a lot of rooms while creating that map
'           you will notice a considerable difference between the two values.
'       
'           The problem goes worse as regards Exit numbers.
'           You cannot see Exit numbers on the map, but you can see them
'           in the .mdb map file:
'           "ExitId" column in "ExitTbl" table.
'       
'           Here, the difference between the last record and the total number
'           of records is even greater than in the case of room numbers.
'       
'           This script (VBScript) recycles the numbers of deleted rooms and exits.
'       
'           This script is useful if you have ever deleted rooms in your map.
'           If you don't know if you have ever deleted rooms in your room, you can
'           still run this script, since it will inform you if recycling was done.
'       
'       
'           !!! IMPORTANT !!!
'           =================
'           Although I have tested this script in all possible scenarios I could
'           think of, I urge you to BACKUP your .mdb file BEFORE running the script.
'       
'           IF you have scripts that depend on room numbers (i.e. #TELEPORT #23)
'           then almost certainly your script will not work as before (i.e. you will
'           be TELEPORTed to another room than previously intended).
'           A recommendation on this:
'           Always use within scripts SHORT NAMES of rooms and not ROOM NUMBERS
'           (i.e. #TELEPORT "room-name" "zone-name").
'           The short-names of rooms can be set by setting the map in create mode,
'           right-click on room, click on properties, click on "Other" tab
'           and setting the name in the "Short Name of room" field.
'       
'           After running the script, TEST your .mdb map file to see IF everything is OK.
'       
'       
'           TECHNICAL INFO:
'           ===============
'           There are the following important tables and columns in your .mdb file
'           that deal with these numbers:
'       
'           Table "ObjectTbl"
'              Columns
'       
'           ...this is not complete...
'       
'       
'       
'==========================================================================

   ' =======================================================================
   '   Script for selecting a file by using a Windows Common Dialog box
   '
   '              Thanks go to Jerry Lees for this script
   ' The script can be found at    http://itknowledgeexchange.techtarget.com
   ' =======================================================================

Option Explicit

Dim objFSO, initFSO

   ' Create an instance of the File Browser
   
Set objFSO = CreateObject("UserAccounts.CommonDialog")

   ' Setup the File Browser specifics
   
objFSO.Filter = "Access Databeses (*.mdb)|*.mdb|"
objFSO.FilterIndex = 1
objFSO.InitialDir = "C:\"

If MsgBox("                This script recycles"& Chr(13) &"" & _
         "  numbers of deleted Rooms and Exits"& Chr(13) &"" & _
         "in map files (.mdb) made by CMUD 2.37.",vbOKCancel,"Message") _
         = 2 Then
   MsgBox "Operation canceled.",,"Message"
   Wscript.Quit
End If

MsgBox "Select a database (*.mdb) file.",,"Message"

   ' Show the file browser and return the selection (or lack of) to initFSO
   
initFSO = objFSO.ShowOpen

If initFSO = False Then
    MsgBox "Operation canceled because no file was selected.",,"Message"
    Wscript.Quit
Else
   MsgBox "           Operation takes time"& Chr(13) &"depending on the size of database."& Chr(13) &""& Chr(13) &"  Unless there are error messages,"& Chr(13) &"     there will be 6 info messages."& Chr(13) &"            Wait for all of them."& Chr(13) &""& Chr(13) &"                    Click OK"& Chr(13) &"            to begin operation.",,"Message"
End If

   ' =========================================
   ' End of Script for selecting a file
   ' =========================================

   ' Declare constants and variables for database access

Dim objConn
Dim objRS

Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "Microsoft.Jet.OLEDB.4.0"
objConn.Open objFSO.FileName

Set objRS = CreateObject("ADODB.Recordset")  ' The Recordset
Set objRS.ActiveConnection = objConn

Const adLockOptimistic = 3
Const adOpenKeyset = 1

   ' Declare non database-access-related variables

Dim number_to_recycle,number_to_replace
Dim total_records,max_number,last_number
Dim recycle_flag
Dim max_ExitId,max_ExitIdTo
Dim a_counter
recycle_flag = False

   ''''''''''''''''''''''''''
   ''----------------------''
   '' RECYCLE ROOM NUMBERS ''
   ''----------------------''
   ''''''''''''''''''''''''''

   ' Determine max number in ObjId column

objRS.Open "SELECT MAX(ObjId) AS Largest FROM ObjectTbl"
objRS.MoveFirst   
max_number = objRS("Largest")
objRS.Close
   
   ' Open Recordset

objRS.Open "SELECT ObjId, RefNum FROM ObjectTbl", ,adOpenKeyset,adLockOptimistic

total_records = objRS.RecordCount

   ' Determine if and from what record, room numbers need recycling

For number_to_recycle = 1 To total_records
   objRS.Move number_to_recycle - 1,1 
   If objRS("ObjId") > number_to_recycle Then
      While number_to_recycle <= total_records       
         Call Recycle_room_numbers
         number_to_recycle = number_to_recycle + 1
      Wend
      recycle_flag = True
      Exit For
   End If
Next

   ' Set the flag for recycle meesage

If recycle_flag Then
   MsgBox "Room numbers recycled.",,"Message no.1"
   recycle_flag = False ' Set the flag as False for the next recycling message
Else
   MsgBox "Room numbers need not recycling.",,"Message no.1"
End If

   ' Recycle the next-to-create room number in ObjID column from VersTbl table

objRS.MoveLast
last_number = objRS("ObjId")
objRS.Close
objRS.Open ("SELECT ObjID FROM VersTbl"), ,adOpenKeyset,adLockOptimistic
objRS.MoveFirst
IF last_number + 1 <> objRS("ObjID") Then
   objConn.Execute ("UPDATE VersTbl SET ObjID="& last_number + 1 &"")
   MsgBox "Number of next-to-create Room recycled.",,"Message no.2"
   recycle_flag = False ' Set the flag as False for the next recycling message
Else
   MsgBox "Number of next-to-create Room need not recycling.",,"Message no.2"
End If
objRS.Close

   ''''''''''''''''''''''''''
   ''----------------------''
   '' RECYCLE EXIT NUMBERS ''
   ''----------------------''
   ''''''''''''''''''''''''''

   ' Recycle exit numbers

objRS.Open ("SELECT ExitId, ExitIdTo FROM ExitTbl"), ,adOpenKeyset,adLockOptimistic

total_records = objRS.RecordCount

For number_to_recycle = 1 To total_records
   objRS.Move number_to_recycle - 1,1
   If objRS("ExitId") > number_to_recycle Then
      While number_to_recycle <= total_records       
         Call Recycle_exit_numbers
         number_to_recycle = number_to_recycle + 1
      Wend
      recycle_flag = True
      Exit For
   End If
Next

If recycle_flag Then
   MsgBox "Exit numbers recycled.",,"Message no.3"
Else
   MsgBox "Exit numbers need not recycling.",,"Message no.3"
End If
objRS.Close

   ' Recycle the next-to-create exit number in ExitID column from VersTbl table

objRS.Open ("SELECT ExitId FROM ExitTbl"), ,adOpenKeyset,adLockOptimistic
objRS.MoveLast
last_number = objRS("ExitId")
objRS.Close
objRS.Open ("SELECT ExitID FROM VersTbl"), ,adOpenKeyset,adLockOptimistic
objRS.MoveFirst
IF last_number + 1 <> objRS("ExitID") Then
   objConn.Execute ("UPDATE VersTbl SET ExitID="& last_number + 1 &"")
   MsgBox "Number of next-to-create Exit recycled.",,"Message no.4"
Else
   MsgBox "Number of next-to-create Exit need not recycling.",,"Message no.4"
End If
objRS.Close

   ' If there are exit numbers in ExitIdTo column in ExitTbl table
   ' which are greater than the max number in ExitId column in ExitTbl table
   ' they become -1

   ' Determine max number in ExitId column

objRS.Open "SELECT MAX(ExitId) AS Largest_ExitId FROM ExitTbl"
objRS.MoveFirst
max_ExitId = objRS("Largest_ExitId")
objRS.Close

   ' Determine max number in ExitIdTo column

objRS.Open "SELECT MAX(ExitIdTo) AS Largest_ExitIdTo FROM ExitTbl"
objRS.MoveFirst
max_ExitIdTo = objRS("Largest_ExitIdTo")
objRS.Close

   ' Exit numbers in ExitIdTo column in ExitTbl table
   ' greater than max number in ExitId column in ExitTbl table
   ' become -1

If max_ExitIdTo > max_ExitId Then
   For a_counter = max_ExitId + 1 To max_ExitIdTo
      objConn.Execute ("UPDATE ExitTbl SET ExitIdTo=-1 WHERE ExitIdTo="& a_counter &"")
   Next
   MsgBox "Exit connections have been cleaned.",,"Message no.5"
Else
   MsgBox "Exit connections need not cleaning.",,"Message no.5"
End If

   ' Close connection to database

objConn.Close
MsgBox "Operation completed.",,"Message no.6"

   ' END OF SCRIPT

   ' -----------
   ' Subroutines
   ' -----------

   ' Subroutine Recycle_room_numbers

Sub Recycle_room_numbers

   objRS.Move number_to_recycle - 1,1

   ' Recycle numbers in ObjId and RefNum columns from ObjectTbl table

   number_to_replace = objRS("ObjId")
   
   objRS("ObjId") = number_to_recycle
   objRS("RefNum") = number_to_recycle
   objRS.Update

   ' Recycle numbers in FromID and ToID columns from ExitTbl table
         
   objConn.Execute ("UPDATE ExitTbl SET FromID="& number_to_recycle &" WHERE FromID="& number_to_replace &"")
   objConn.Execute ("UPDATE ExitTbl SET ToID="& number_to_recycle &" WHERE ToID="& number_to_replace &"")
     
End Sub

   ' Subroutine Recycle_exit_numbers

Sub Recycle_exit_numbers

   objRS.Move number_to_recycle - 1,1
   
   ' If exit number_to_recycle is found in ExitIdTo column then it becomes -1
   
   objConn.Execute ("UPDATE ExitTbl SET ExitIdTo=-1 WHERE ExitIdTo="& number_to_recycle &"")
   
   ' Recycle exit numbers in ExitId column
   
   number_to_replace = objRS("ExitId")
   objConn.Execute ("UPDATE ExitTbl SET ExitId="& number_to_recycle &" WHERE ExitId="& number_to_replace &"")
   objConn.Execute ("UPDATE ExitTbl SET ExitIdTo="& number_to_recycle &" WHERE ExitIdTo="& number_to_replace &"")

End Sub


Last edited by bothkill on Thu Jul 16, 2009 1:24 pm; edited 3 times in total
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Tue Jul 14, 2009 2:11 pm   
 
Ugh. The file structure for the .dbm files will probably NOT change. :P I don't have/use the .mdb database anymore, and pretty sure the guy who requested it uses the beta as well. I've been wanting a script like this for a while. :\ Any chance you could at least pm the beta version?

Also, since you seem to be good at this, think you're able to write up a script to recycle database numbers? (I'm referring to when you delete a row in the internal database, it just increments the number instead of recycling the number. Gets annoying when your database is up to 17402 with only 132 records...)

Thanks!

Charneus
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Tue Jul 14, 2009 3:43 pm   
 
Ideally you should be putting these in the package library. You can have both versions in there and give them both CMUD version requirements if you wish.
_________________
Asati di tempari!
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Tue Jul 14, 2009 9:21 pm   
 
Thanks for posting this Bothkill.

I use the Beta version 3.08, but I'd be willing to give it a trial run on my database (after I back it up of course...) :)

One dumb question for you. How do I run this? Do I just copy and paste it into an alias in Cmud and then set the script type to Visual Basic? Do I need to have Visual Basic installed on the computer like you need Python installed to use the Python language?

I gave it my best shot to read through the code to figure out what was going on. Unfortunately I don't think I understood what you were doing, despite your excellent comments in the code. If I have a DB that is like this:

Rec#: In use:
1 Yes
2 No
3 No
4 No
5 Yes
6 Next Number to use when mapping

Would it recycle it so that it was like this:

Rec#: In use:
1 Yes
2 Yes
3 Next Number to use when mapping

Or would it only recycle when the non-used number occur at the end and there are no used numbers at the end, such as this:

Rec#: In use:
1 Yes
2 No
3 No
4 No
5 Next Number to use when mapping

One other additional thing I was thinking about was to be able to group the record numbers by zone. Sometimes I map out a zone then it gets modified and I go back and update the map. So it turns out I have something like this:

Rec# Zone#
1 1
2 1
3 1
4 1
5 2
6 2
7 2
...
...
563 59
564 59
565 1
565 1
566 60
566 60

It would be nice if I could group them by zones as it goes through to reclaim unused numbers.
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Wed Jul 15, 2009 7:09 am   
 
charneus wrote:
since you seem to be good at this

Sorry, to disappoint you but I'm not a programmer. Programming is only a hobby which I practiced only a few times in my life.
For dealing with this recycling issue, I had to search the Internet for VBScript and database tutorials.
Real programmers could do this kind of stuff much faster and much better.
I was forced to learn the basics of VBScript and database because no real programmer was interested in solving this recycling issue.

charneus wrote:
a script to recycle database numbers? (I'm referring to when you delete a row in the internal database

It would be helpful to indicate the table you're referring to.
Then I'll see if I will be able to do something about it.
Then again, real programmers could do this kind of stuff in no time. Anyway, if no one tries I will try it for myself.

Tech wrote:
Ideally you should be putting these in the package library.

I use CMUD at a very basic level, so I don't know what this "package library" thing is about.

charneus wrote:
Any chance you could at least pm the beta version?

ReedN wrote:
I use the Beta version 3.08

OK, I will also post here the script for the CMUD 3.xx but I need some time to clean the code a little bit and do some more testing.

ReedN wrote:
How do I run this? Do I just copy and paste it into an alias in Cmud and then set the script type to Visual Basic? Do I need to have Visual Basic installed on the computer like you need Python installed to use the Python language?

Probably there are many ways, but I use it like this:
Make a new .txt file. Copy and Paste the code into the .txt file. Change the file extension from .txt to .vbs.
Double click the .vbs file.
I use Win XP which has VBScript pre-installed.

ReedN wrote:
I gave it my best shot to read through the code to figure out what was going on.

The script recycles all the unused room numbers no matter how they are distributed relative to the used numbers.
This process is a little bit complicated since there is necessary to re-number all the used numbers and all their "dependencies".
The only down-side is the one mentioned in the section "!!! IMPORTANT !!!" in the code.

ReedN wrote:
One other additional thing I was thinking about was to be able to group the record numbers by zone.

For understanding this issue I have to look again into the tables' structure of the database.
Anyway this issue has more to do with regrouping and nice-looking than recycling Wink. When all recycling is done, the next step is beautification!
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Wed Jul 15, 2009 1:39 pm   
 
The Shared Package Library is potentially one of the most powerful features of CMUD. It's a single repository available to registered CMUD users to be able to access scripts and modules that other CMUD users have put together. There are already quite a few packages in the library, and is one of the reasons you don't see too many 'Finished CMUD Scripts' as they are usually put in the library.

With features like a rating system, version control and CMUD version required it's quite a powerful feature.
_________________
Asati di tempari!
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Fri Jul 17, 2009 3:56 pm   
 
Ok, I've uploaded the script for CMUD BETA 3.xx to the Package Library.

Thanks to Tech for telling me about this Library.

Awaiting your reactions regarding the script results Shocked .
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Jul 17, 2009 7:02 pm   
 
Thanks, I'll give it a try.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Jul 18, 2009 2:44 am   
 
I've having a hard time with getting this working. I installed it from the package library and I see it in my packages directory, but it's a pkg file. How do open it? I tried opening it with the package editor (File->View Package), but that didn't work. I must be doing something wrong here.

I've never been able to figure out how to use the scripts I've downloaded from the package library. The Cmud help files tell how to install or uninstall items, but there's nothing in there on how you access it and use it once it has been downloaded.
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sat Jul 18, 2009 5:24 am   
 
In the PE: File->Open. Select a package and it will be added to your current session. Use it like any other your own package been loaded with a session.
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Jul 18, 2009 5:56 am   
 
Yep, I tried that, it's blank. Nothing is in the package except for the text description of the package.

Perhaps just post it here to avoid the issues.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Jul 18, 2009 8:17 pm   
 
I was looking in more detail at your code above and I believe you've omitted the NoteTbl when you do the renumbering. Perhaps this is because you don't populate the Notes field in your map. If I don't include the notes in the renumbering it will break my whole map.

I'm also curious about this:

Code:
   ' Exit numbers in ExitIdTo column in ExitTbl table
   ' greater than max number in ExitId column in ExitTbl table
   ' become -1

If max_ExitIdTo > max_ExitId Then
   For a_counter = max_ExitId + 1 To max_ExitIdTo
      objConn.Execute ("UPDATE ExitTbl SET ExitIdTo=-1 WHERE ExitIdTo="& a_counter &"")
   Next
   MsgBox "Exit connections have been cleaned.",,"Message no.5"
Else
   MsgBox "Exit connections need not cleaning.",,"Message no.5"
End If

Why did you find this necessary to do? From what I understand this means you essentially found an invalid link. Was the invalid link from your script or from Cmud?
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Sat Jul 18, 2009 11:13 pm   
 
ReedN wrote:
I've having a hard time with getting this working.

You're right.
The package was supposed to have a function which contained the script.
For some reason, the package didn't upload the function too.
I've tried to fix this and now the package contains the function.
Now, opening the package with Package Editor should allow you to see the function containing the script.


ReedN wrote:
...I believe you've omitted the NoteTbl when you do the renumbering...

Right again.
I use Notes, but forgot about them. And yes, they are a mess now.
I'll try to fix this.


ReedN wrote:
Why did you find this necessary to do? From what I understand this means you essentially found an invalid link. Was the invalid link from your script or from Cmud?

From what I remember, the links to rooms having a value larger than the maximum post-recycling room number, get invalid due to renumbering and this issue got to get addressed.
It went like this:
The script also recycles Exit links.
Let's say we have this scenario:
Before renumbering: at the end of the room table there is a deleted room (no. 100). You made this room before, made some links to it (from 98 to 100, from 99 to 100 etc), but eventually you deleted it. But the links remain to that room number in the ExitTbl (from 98 to 100, from 99 to 100, it's just the fact that room 100 is deleted that makes you not see those links).
After renumbering: That deleted room number (no.100) will be used in the future (is recycled). Let's say you create a new room elsewhere (i.e. in other place than the original room no.100 was). This new room gets number 100 and then the links (from 98 to 100, from 99 to 100 etc) get validated again since room no.100 is alive again. But the new room no.100 is not where the old room no.100 was, so you will have some links you surely don't want Wink .
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Jul 18, 2009 11:23 pm   
 
bothkill wrote:

From what I remember, the links to rooms having a value larger than the maximum post-recycling room number, get invalid due to renumbering and this issue got to get addressed.
It went like this:
The script also recycles Exit links.
Let's say we have this scenario:
Before renumbering: at the end of the room table there is a deleted room (no. 100). You made this room before, made some links to it (from 98 to 100, from 99 to 100 etc), but eventually you deleted it. But the links remain to that room number in the ExitTbl (from 98 to 100, from 99 to 100, it's just the fact that room 100 is deleted that makes you not see those links).
After renumbering: That deleted room number (no.100) will be used in the future (is recycled). Let's say you create a new room elsewhere (i.e. in other place than the original room no.100 was). This new room gets number 100 and then the links (from 98 to 100, from 99 to 100 etc) get validated again since room no.100 is alive again. But the new room no.100 is not where the old room no.100 was, so you will have some links you surely don't want Wink .

Wow, something I hadn't even considered. This is interesting diving into this. I'm determined to get it sorted/recycled... hopefully I eventually get there.
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Sat Jul 18, 2009 11:25 pm   
 
I'll fix those Note thing in a few minutes.
Stay tuned.

Did you manage to get the package right?
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Sat Jul 18, 2009 11:36 pm   
 
Updated the script to take care of Notes.
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Jul 18, 2009 11:40 pm   
 
Yes, I was able to download it from the package library this time. Thanks for updating the notes. I'll give it a run through and report back anything of note.

Thanks again!
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Sat Jul 18, 2009 11:47 pm   
 
There are a lot of bugs with this Shared Package Library.

It didn't upload correctly the updated version.
It also doesn't remember the CMUD Version required, that's why I had to write it in the description.
It also doesn't show what I write in the "What's new" section.

Trying again. Wait for the version 0.3.

Run the script only if it contains the word "NoteTbl".
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sat Jul 18, 2009 11:52 pm   
 
Yeah, it was a trial getting it to update, but I have the latest now.
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Jul 19, 2009 1:41 am   
 
Tried running it myself (downloaded the driver and all) and it came up with this error:

Quote:
Script: C:\Users\Charneus\Documents\recycle.vbs
Line: 99
Char: 1
Error: ActiveX component can't create object: 'UserAccounts.CommonDialog'
Code: 800A01AD
Source: Microsoft VBScript runtime error


Any suggestions? :P

Charneus

By the way, if it takes 15 minutes to do 8000 rooms, man, I'm in for a while. I've got a 28,500 room map. *sigh*
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sun Jul 19, 2009 3:38 am   
 
I ran it verbatim and I didn't get that error. It has been running for 100 minutes at this point and I just got the first progress boxes saying it has finished recycling the first set of items. It is now doing exits. I have well over 20k rooms.

That particular item: 'UserAccounts.CommonDialog' is used to open a dialog box. I'm not sure why it's giving you an error. All I did was ctrl-a to select everything, then I copied it into a text editor.

Edit: I'll also note that my disk is very active during this script. I'm not sure why it should be so heavily utilized since this should all be able to fit in memory for execution.
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Sun Jul 19, 2009 6:55 am   
 
charneus wrote:
it came up with this error


According to this site "UserAccounts.CommonDialog" is working only under Windows XP.
So, I'll presume you're not using Win XP.

I'm thinking of the following work-around:
Comment the lines dealing with the database selection window (i.e. from line no.95 "Dim objFSO, initFSO" until line no. 126 "End If", right before "End of Script for selecting a file").
Modify the line no.139 so it contains the path to your database file:
I.e. change the line:
Code:
objConn.Open "Driver={SQLite3 ODBC Driver};Database="& objFSO.FileName &";StepAPI=;Timeout="

to
Code:
objConn.Open "Driver={SQLite3 ODBC Driver};Database="PATH_TO_YOUR_FILE";StepAPI=;Timeout="

I hope this works.

ReedN wrote:
It has been running for 100 minutes at this point...
...my disk is very active during this script


It takes so much time only the first time recycling is done.
For example, if you have 20k-room map and you need to recycle only the room no.1, boy, sure it will take some time, since all the room and exit numbers have to be re-written.
But after recycling is done for the first time, then it will take no time to recycle your, let's say, next new 100 rooms (presuming you will not delete room no.1 Smile ).

The hard disk usage is due to the fact that for every change in the database, the script accesses the file.
Maybe it will be best if the file loads into RAM and the script operates on it from there, but I don't know how to do this Sad .

But overall, I think this script really needs to be transformed into an executable.
If no one try this, I'll try to make it (but it will take some time).
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Sun Jul 19, 2009 7:10 am   
 
It took 6 hours for me.

I think the items in this post are pertinent regarding the PRAGMA statements.
http://forums.zuggsoft.com/forums/viewtopic.php?p=149418#149418

Do you know how to call those PRAGMA statements:

PRAGMA journal_mode = OFF; PRAGMA synchronous=0;

in Visual Basic?
Reply with quote
bothkill
Apprentice


Joined: 13 Mar 2005
Posts: 125
Location: Bucharest

PostPosted: Sun Jul 19, 2009 8:31 am   
 
Nice findings!

I added these two statements to line 139 where database connectivity is set for the first time:
Code:
objConn.Open "Driver={SQLite3 ODBC Driver};Database="& objFSO.FileName &";StepAPI=;Timeout="

so that it looks:
Code:
objConn.Open "Driver={SQLite3 ODBC Driver};Database="& objFSO.FileName &";StepAPI=;Timeout=;PRAGMA journal_mode=OFF; PRAGMA synchronous=0"

but didn't notice any improvement on time consumptionSad .
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sun Jul 19, 2009 2:45 pm   
 
bothkill wrote:
According to this site "UserAccounts.CommonDialog" is working only under Windows XP.
So, I'll presume you're not using Win XP.

I'm thinking of the following work-around:
Comment the lines dealing with the database selection window (i.e. from line no.95 "Dim objFSO, initFSO" until line no. 126 "End If", right before "End of Script for selecting a file").
Modify the line no.139 so it contains the path to your database file:
I.e. change the line:
Code:
objConn.Open "Driver={SQLite3 ODBC Driver};Database="& objFSO.FileName &";StepAPI=;Timeout="

to
Code:
objConn.Open "Driver={SQLite3 ODBC Driver};Database="PATH_TO_YOUR_FILE";StepAPI=;Timeout="

I hope this works.


First, I'm assuming PATH_TO_YOUR_FILE is to be replaced with the path to my file (i.e. C:\Users\Documents\ etc.). Either way, I tried it verbatim and with the path, and both came back with the error of 'Line: 139. Char: 54: Error: Expected end of statement.'

So it did fail once again.

And yeah, you're right - I work with Windows 7 (which has the same structure as Windows Vista. I suppose I need to find the replacement for Vista and hope that it works. *sigh* I look forward to this working, though!

Charneus

PS. By the way, not sure which table it is in the internal database. I just don't like using #NEW MyEQ {Name=blahblahblah|Stats=blahblahblah} and having it be record number 4002421. :P
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net