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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
karthic
Wanderer


Joined: 28 Aug 2001
Posts: 86
Location: USA

PostPosted: Thu Jan 03, 2002 10:38 pm   

wanna help me shorten this slow databse script
 
These are the 16 different types of lines that i need to pick up.. and format/store to thier proper variables...
-------------------------------------------
You see FIRSTNAME LASTNAME, a RACE.
You see FIRSTNAME LASTNAME of elanthia, a RACE.
You see FIRSTNAME LASTNAME, a RACE GUILD.
You see FIRSTNAME LASTNAME of elanthia, a RACE GUILD.

You see TITLE FIRSTNAME LASTNAME, a RACE.
You see TITLE FIRSTNAME LASTNAME of elanthia, a RACE.
You see TITLE FIRSTNAME LASTNAME, a RACE GUILD.
You see TITLE FIRSTNAME LASTNAME of elanthia, a RACE GUILD.

then.. you've got others for thieves..
You see a fellow thief, FIRSTNAME LASTNAME, a RACE.
You see a fellow thief, FIRSTNAME LASTNAME of elanthia, a RACE.
You see a fellow thief, FIRSTNAME LASTNAME, a RACE GUILD.
You see a fellow thief, FIRSTNAME LASTNAME of elanthia, a RACE GUILD.
You see a fellow thief, TITLE FIRSTNAME LASTNAME, a RACE.
You see a fellow thief, TITLE FIRSTNAME LASTNAME of elanthia, a RACE.
You see a fellow thief, TITLE FIRSTNAME LASTNAME, a RACE GUILD.
You see a fellow thief, TITLE FIRSTNAME LASTNAME of elanthia, a RACE GUILD.

this catagory the title.. is a fake one.. and the secondtitle is a real title.... both need to be stored.. but this section prolly needs to be different from the others
You see You see TITLE (a thief SECONDTITLE) FIRSTNAME LASTNAME, a RACE.
You see You see TITLE (a thief SECONDTITLE) FIRSTNAME LASTNAME of elanthia, a RACE.
You see You see TITLE (a thief SECONDTITLE) FIRSTNAME LASTNAME, a RACE GUILD.
You see You see TITLE (a thief SECONDTITLE) FIRSTNAME LASTNAME of elanthia, a RACE GUILD.
------------------------------------------------



This is the script i use to do it...


#IG
#var thiefaddin {}
#var ttempclass "None"
#var tempname {}
#var tempname2 {}
#var temprace {}
#var tempcit {}
#var citizen {}
#var firstpersonname {}
#var secondpersonname {}
#var tempclass {}
#var tempcircle {}
#var firsttitle "None"
#var secondtitle "None"
@tempname = %trim( %1)
@tempname2 = %trim( %2)
#if (%ends( @tempname2, Mage)) {
#MATH name2total %numwords( @tempname2)-1
#math name2total %pos( %word( @tempname2, @name2total), @tempname2)-1
@tempclass = %right( @tempname2, @name2total)
} {@tempclass = %item( @classlist, %ismember( %word( @tempname2, %numwords( @tempname2)), @classlist))}
@twoclass = @tempclass
@tempname2 = %trim( %remove( @tempclass, @tempname2))
@temprace = %item( @racelist, %ismember( @tempname2, @racelist))
@tempname2 = %trim( %remove( @temprace, @tempname2))
@citizen = %trim( %item( @citlist, %ismember( %word( @tempname, %numwords( @tempname)), @citlist)))
#if (@citizen <> "None") {
#var citpos %pos( @citizen, @tempname)
#MATH citpos @citpos-1
@tempname = %left( @tempname, @citpos)
@tempname = %remove( "of the", @tempname)
@tempname = %remove( "of Aesry", @tempname)
@tempname = %remove( " of ", @tempname)
@tempname = %remove( " the ", @tempname)
@tempname = %remove( @citizen, @tempname)
@tempname = %trim( @tempname)
}
@secondpersonname = %word( @tempname, %numwords( @tempname))
@tempname = %trim( %remove( @secondpersonname, @tempname))
@firstpersonname = %word( @tempname, %numwords( @tempname))
@tempname = %trim( %remove( @firstpersonname, @tempname))
#if (@tempclass != "None" and @tempclass != "Thief") {#delITEM boxteefs @firstpersonname}
#if (%ismember( @firstpersonname, @boxteefs)) {@tempclass = "Thief"}
#if (%pos( fellow, @firstpersonname)) {} {
#if (%ends( @tempname, ")")) {
@tempclass = "Thief"
@tempname = %trim( %remove( ")", @tempname))
@thiefaddin = %pos( "(a thief", @tempname)
#AD thiefaddin 8
@firsttitle = %trim( %copy( @tempname, @thiefaddin, 20))
@tempname = %trim( %remove( @firsttitle, @tempname))
@tempname = %trim( %remove( "(a thief", @tempname))
@secondtitle = @tempname
#var tempname {}
} {
#if (@tempname) {#if (@tempclass =~ "Thief") {#if (%ismember( @tempname, @thieftitles)) {@firsttitle = @tempname} {@secondtitle = @tempname}} {@firsttitle = @tempname}}
}
#if (%ismember( @firstpersonname, @boxteefs)) {@tempclass = "Thief"}
#if (@tempclass != "None" and @tempclass != "Thief") {#delITEM boxteefs @firstpersonname}
#if (%ismember( @firsttitle, @thieftitles)) {@tempclass = "Thief"}
#if (@tempclass =~ "Thief") {#addITEM boxteefs @firstpersonname}
#if (@firsttitle != "None") {
#if (%ismember( @firsttitle, @barbtitles)) {@tempclass = "Barbarian"}
#if (%ismember( @firsttitle, @bardtitles)) {@tempclass = "Bard"}
#if (%ismember( @firsttitle, @clerictitles)) {@tempclass = "Cleric"}
#if (%ismember( @firsttitle, @empathtitles)) {@tempclass = "Empath"}
#if (%ismember( @firsttitle, @moontitles)) {@tempclass = "Moon Mage"}
#if (%ismember( @firsttitle, @paladintitles)) {@tempclass = "Paladin"}
#if (%ismember( @firsttitle, @rangertitles)) {@tempclass = "Ranger"}
#if (%ismember( @firsttitle, @thieftitles)) {@tempclass = "Thief"}
#if (%ismember( @firsttitle, @tradertitles)) {@tempclass = "Trader"}
#if (%ismember( @firsttitle, @warriortitles)) {@tempclass = "Warrior Mage"}
}
#if (@secondtitle != "None") {
#if (%ismember( @secondtitle, @barbtitles)) {@ttempclass = "Barbarian"}
#if (%ismember( @secondtitle, @bardtitles)) {@ttempclass = "Bard"}
#if (%ismember( @secondtitle, @clerictitles)) {@ttempclass = "Cleric"}
#if (%ismember( @secondtitle, @empathtitles)) {@ttempclass = "Empath"}
#if (%ismember( @secondtitle, @moontitles)) {@ttempclass = "Moon Mage"}
#if (%ismember( @secondtitle, @paladintitles)) {@ttempclass = "Paladin"}
#if (%ismember( @secondtitle, @rangertitles)) {@ttempclass = "Ranger"}
#if (%ismember( @secondtitle, @thieftitles)) {@ttempclass = "Thief"}
#if (%ismember( @secondtitle, @tradertitles)) {@ttempclass = "Trader"}
#if (%ismember( @secondtitle, @warriortitles)) {@ttempclass = "Warrior Mage"}
} {@ttempclass = "None"}
#var tempcircle "0"
#if (@firsttitle != "None") {
#if (%ismember( @firsttitle, @fivetitles)) {@tempcircle = 5}
#if (%ismember( @firsttitle, @tentitles)) {@tempcircle = 10}
#if (%ismember( @firsttitle, @twentytitles)) {@tempcircle = 20}
#if (%ismember( @firsttitle, @thirtytitles)) {@tempcircle = 30}
#if (%ismember( @firsttitle, @fiftytitles)) {@tempcircle = 50}
#if (%ismember( @firsttitle, @seventytitles)) {@tempcircle = 70}
#if (%ismember( @firsttitle, @nintytitles)) {@tempcircle = 90}
#if (%ismember( @firsttitle, @onetitles)) {@tempcircle = 100}
#if (%ismember( @firsttitle, @onetwentytitles)) {@tempcircle = 125}
#if (%ismember( @firsttitle, @onefiftytitles)) {@tempcircle = 150}
#if (@firsttitle = "Novice") {@tempcircle = 1}
#if (@firsttitle = "Mentor") {@tempcircle = 1}
#if (@tempcircle < 1) {#if (@tempclass != "None") {
#var unktitles %additem( @firsttitle, @unktitles)
#var unktitles %additem( @tempclass, @unktitles)
} {#if (%ismember( @firsttitle, @unktitles)) {#noop} {
#var unktitles %additem( @firsttitle, @unktitles)
#var unktitles %additem( @tempclass, @unktitles)
}}}
}
#if (@temprace = "Kaldaran") {#var temprace "Kaldar"}
#if (@temprace = "Dwarven") {#var temprace "Dwarf"}
#if (@temprace = "Elven") {#var temprace "Elf"}
#if (@twoclass <> @Tempclass and @twoclass <> "None") {@tempclass = @twoclass}
#if (@tempclass != "None" and @tempclass != "Thief") {#delITEM boxteefs @firstpersonname}
#if (@tempclass =~ "Thief") {#ADDITEM boxteefs @firstpersonname}
#echo @firstpersonname @secondpersonname @temprace @tempclass @citizen @firsttitle @secondtitle @tempcircle @ttempclass
@tempna = %query( &Fname=@firstpersonname)
#if (@tempna) {
#dbget @tempna
#If (&circle < @tempcircle) {&circle = @tempcircle}
#If (@tempclasss != "None") {&class = @tempclass}
#If (@citizen != "None") {&citizen = @citizen}
#If (@ttempclass != "None") {&fakeclas = @ttempclass}
&race = @temprace
&time = %time( )
&place = %sort( %dups( %additem( "Crossing", &place)))
&lastplace = "Crossing"
} {
#NEW people {fName=@firstpersonname|Lname=@secondpersonname|Race=@temprace|class=@tempclass|Circle=@tempcircle|fakeclas=@ttempclass|citizen=@citizen|time=%time( )|place="Crossing"|lastplace="Crossing"}
}
SLEEP
}
#dbsave
#IG


-------------------------------------------


Now ... this script can take several seconds to run, with a database of over 4000 items... i believe the slowness is in the finding the item in the database.. but anyone know of a way to make this faster? cause i have a script that runs RIGHT after this on the next line... but since i HAVE to disable all triggers while its runnin(if i dont... it will trigger again.. and the database cant deal with multiple query's.. and it messes up the data...)
or... is there a way pause mud output during trigger exectutation? that might fix it..

thanks

oh.. this is what it triggers off of...

You see (*), {a|an} (*).

karthic



karthic
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Jan 04, 2002 12:53 am   
 
First fix the typo:
#dbget @tempna
#If (&circle < @tempcircle) {&circle = @tempcircle}
#If (@tempclasss != "None") {&class = @tempclass} ///extra s

#if (@tempclass =~ "Thief") {#addITEM boxteefs @firstpersonname} ///dunno what the ~ is doing here
#if (@firsttitle != "None") {


Next move all checks done on the basis of @firsttitle!="None" into one set of {}'s
Another suggest is to else chain those checks that are mutually exclusive. #IF (cond) {bardtitle} {#if (cond) {warriortitle} {#if ....}}} Obviously if it is a bard it can't be a warrior, and if it is a warrior then it wont have been a bard.

The final suggestion and this may sound reaally wierd is change the #dbsave command. It seems that is a very slow process. My suggestion for optimization is to add a variable dbnotsaved, just set it to 1 here. In the atdisconnect alias add #IF (@dbnotsaved) {#DBSAVE;dbnotsaved=0}
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: Fri Jan 04, 2002 5:55 am   
 
The bulk of your delay comes from this section of the script:

quote:

#if (%ismember( @firsttitle, @barbtitles)) {@tempclass = "Barbarian"}
#if (%ismember( @firsttitle, @bardtitles)) {@tempclass = "Bard"}
#if (%ismember( @firsttitle, @clerictitles)) {@tempclass = "Cleric"}
#if (%ismember( @firsttitle, @empathtitles)) {@tempclass = "Empath"}
#if (%ismember( @firsttitle, @moontitles)) {@tempclass = "Moon Mage"}
#if (%ismember( @firsttitle, @paladintitles)) {@tempclass = "Paladin"}
#if (%ismember( @firsttitle, @rangertitles)) {@tempclass = "Ranger"}
#if (%ismember( @firsttitle, @thieftitles)) {@tempclass = "Thief"}
#if (%ismember( @firsttitle, @tradertitles)) {@tempclass = "Trader"}
#if (%ismember( @firsttitle, @warriortitles)) {@tempclass = "Warrior Mage"}
}
#if (@secondtitle != "None") {
#if (%ismember( @secondtitle, @barbtitles)) {@ttempclass = "Barbarian"}
#if (%ismember( @secondtitle, @bardtitles)) {@ttempclass = "Bard"}
#if (%ismember( @secondtitle, @clerictitles)) {@ttempclass = "Cleric"}
#if (%ismember( @secondtitle, @empathtitles)) {@ttempclass = "Empath"}
#if (%ismember( @secondtitle, @moontitles)) {@ttempclass = "Moon Mage"}
#if (%ismember( @secondtitle, @paladintitles)) {@ttempclass = "Paladin"}
#if (%ismember( @secondtitle, @rangertitles)) {@ttempclass = "Ranger"}
#if (%ismember( @secondtitle, @thieftitles)) {@ttempclass = "Thief"}
#if (%ismember( @secondtitle, @tradertitles)) {@ttempclass = "Trader"}
#if (%ismember( @secondtitle, @warriortitles)) {@ttempclass = "Warrior Mage"}
} {@ttempclass = "None"}



I would suggest that you put the TITLE into the database rather than converting title to class during data entry.

I don't know exactly what you're going to do with this information, but it'd be more efficient to convert title to class on a case by case basis in a database querying script.

Troubadour
Reply with quote
Reddytedy
Apprentice


Joined: 13 Oct 2000
Posts: 114
Location: USA

PostPosted: Fri Jan 04, 2002 7:13 am   
 
Karthic,
Mind getting with me sometime to share some ideas on zmud with DR.. the DRzMUD list on yahoo groups is kinda thin right now and we need some new people to come in and start tossing scripts out. I have alot of things I wanna do but since my hard drive crashed with all my zmud scripts I hafta start rebuilding <kicks himself for not backing up those scripts>

Player of a few on DR

AIM is TedyHere if ya wanna get ahold of me and I can help debug scripts with ya.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
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