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
dcb
Novice


Joined: 02 Sep 2004
Posts: 42

PostPosted: Sun Dec 05, 2004 4:39 pm   

Help please...
 
This was taken from the finished scripts area however i'm having problems making it work with my mud. I was wondering if someone could help me taylor it to my mud thanks.

Here is what I have.

A databased called ID with the following fields.
Name
Type
Value (changed from cost below)
Weight
Damage
Hit
Dam
Affects

The script seems to "try" to work but everytime i id something i get the message Failed to make/find new record in database.

A new record is created however the information is always written to the first record and it never steps down to the next record in the database. This means that the information always overwrites the first record and creates a new blank record.

Also it is stated that #LOOPDB and #ADDKEY, is used
but this could be done with #NEW instead and be faster. Perhaps if someone could show us this method as well it could be very helpful ?

Any help would be appriciated. Here is a the actual output of my mud.

You feel informed:
Name: 'cloudy white loop giant', Item type: ARMOR
Item is: WARRIOR THIEF PALADIN ANTI_PAL BARBARIAN MONK RANGER NoBits
Worn by: Medium races Large races Charmies
Weight: 1, Value: 19200
AC-apply is 2 Resistance to damage is 0
Can affect you as:
Affects : HIT -N- DAM By 1
Affects : SAVE_VS_MAGIC By 2


Advanced Database Scripting
In order to script the database the window must be open and the database must already be created with the proper fields. Let's start with the whole script and then I will try to explain how it works. I will use indenting in the larger settings for readability.
#CLASS Identify
#CLASS Identify|IDTrigs
#TRIGGER {Name: &IDedItem.Name} {Affects=""}
#TRIGGER {Type: &IDedItem.Type} {}
#TRIGGER {Cost: &IDedItem.Cost} {}
#TRIGGER {Weight: &IDedItem.Weight} {}
#TRIGGER {Damage: &IDedItem.Damage} {}
#TRIGGER {Hit: &IDedItem.Hit} {}
#TRIGGER {Dam: &IDedItem.Dam} {}
#TRIGGER {Affects (*) by (%n)} {#ADDITEM Affects {%1=%2}}
#TRIGGER {$} {
#IF (!%null(@IDedItem)) {
#T- IDTrigs
#ADDKEY IDedItem Affects {@Affects}
#DBLOAD ID
#VIEW All
#DBFIRST
#IF (%numrec!="") {
StoreID
} {
CapturingID=%concat( "ID", %secs)
#VAR @CapturingID @IDedItem {_nodef} {Identify}
#ADDITEM IDsPending @CapturingID
}
}
}
#CLASS Identify
#VAR IDedItem {} {}
#VAR CapturingID {} {}
#VAR Affects {} {}
#VAR IDsPending {}
#VAR ItemSource {}
#TRIGGER {^You get (*) from the coprse of (*).$} {
#ADDKEY ItemSource {%1} {%zonename() - %2}
}
#TRIGGER {^You pick up (*).$} {
#ADDKEY ItemSource {%1} {%zonename() - %roomname()}
}
#ALIAS ID {#T+ IDTrigs;#ALARM {+5} {#T- IDTrigs};IDedItem="";cast identify}
#ALIAS StoreID {
#DBRESET
CapturingID=%query((&Name=@IDedItem.Name))
#DBRESET
Affects=""
#FORALL @CapturingID {
#DBGET {%i}
#IF ((&Type=@IDedItem.Type)&(&Affects=@IDedItem.Affects)) {
#ADDITEM Affects {%i}
}
}
#IF (@Affects="") {
#DBRESET
CapturingID=%query(&Where="New Item")
#DBRESET
#IF (@CapturingID) {
#DBGET {%item(@CapturingID,1)}
} {
#NEW All {Where=New Item}
#DBRESET
CapturingID=%query(&Where="New Item")
#DBRESET
#IF (@CapturingID) {
#DBGET {%item(@CapturingID,1)}
} {
#ECHO Failed to make/find new record in database
}
}
#IF (%rec) {
#LOOPDB {@IDedItem} {#ADDKEY %rec {%key} {%val}}
#IF (%iskey(@ItemSource,@IDedItem.Name)) {
#ADDKEY %rec {Where} {%db(@ItemSource,@IDedItem.Name)}
} {
#ADDKEY %rec {Where} {Unknown}
}
#DBSAVE
}
} {
#ECHO Item appears to duplicate record%if(%numitems(@Affects)>1,s) @Affects.
#IF (%numitems(@Affects)=1) {
#DBGET {@Affects}
#IF (&Where="Unknown") {
#IF (%iskey(@ItemSource,@IDedItem.Name)) {
#ADDKEY %rec {Where} {%db(@ItemSource,@IDedItem.Name)}
#DBSAVE
#ECHO Where updated to %db(@ItemSource,@IDedItem.Name).
}
} {
#ECHO Where currently &Where -- source indicates %db(@ItemSource,@IDedItem.Name).
}
}
}
}
#ALIAS OpenIDdb {
#DBLOAD ID
#VIEW All
#DBFIRST
Affects=0
#IF (%numrec="") {
#MENU {Windows|Database}
#WHILE ((%numrec="")&(@Affects<10000)) {
#ADD Affects 1
#DBLOAD ID
#VIEW All
#DBFIRST
}
}
}
#BUTTON 0 {IDsPending:%if(%btnenable(StoreIDs,%numitems(@IDsPending)),%numitems(@IDsPending),0)} {OpenIDdb;#IF (@Affects!=10000) {IDedItem=@{%item(@IDsPending,1)};#UNVAR %pop(IDsPending) Identify;StoreID} {#ECHO Failed open/load database.}} {} {} {%numitems(@IDsPending)} {} {} {} {} {} {Pos} {1} {880} {32800} {} {Gauge||10|5|0|11} {} "" {} {} {StoreIDs}
#CLASS 0

So what does it all actually do?
First lets follow the steps that it takes when in operation.
You enter: id whatever
The alias turns on the triggers class, creates an alarm to turn
them off for security, blank the main variable, and then sends
the mud command.
Since the name trigger is likely to be first we blank the Affects variable here.
Once a blank line is received we check to see if we got ID information
When we do: turn of the triggers, put the affects into the main
variable, then test whether the DB window looks open and ready
to receive data. This test is done by checking %numrec, as with
all database functions when the window isn't open it returns nul.
If the test succeeds we StoreID otherwise create a variable and
put the name for it in a list for later storage.
Storing it in the DB (StoreID):
First %query to see if there is any items in the DB that look to be the same.
If it looks to be unique we start storing
Check for existing blank 'New Item' records
If we find any we fetch it into %rec
Otherwise make a new one and fetch it to %rec
Finally add all the data, I used #LOOPDB and #ADDKEY,
but this could be done with #NEW instead and be faster.
Else it looks to be a duplicate report the possible matches.
If we found only one report or update the Where field and
the appropiate ItemSource value.
The StoreIDs button:
This button is a push/gauge. It displays the number of pending
IDs in the caption and also automatically turns off it ability to be
pushed.
Script wise it assumes that IDs are stored because the DB wasn't open
and needs to be opened. This is done in OpenIDdb.
If opening the DB didn't timeout of 10000 cycles (on some systems this might
not be long enough).
Then it transfers the data to the variable StoreID expects to find it in,
and cleans up all the temporary variables and lets StoreID do the rest.
Else it reports the error.
Opening the DB window and making sure the right DB is loaded:
First we actually assume the window is open and will respond to
commands.
Next test %numrec for nul.
If it is then we use #MENU to open it. We only want to do this once.
Next we loop to give zMud time to open the window and load the database.
A counter is used to abort the loop and signal error to the button.
Reply with quote
dcb
Novice


Joined: 02 Sep 2004
Posts: 42

PostPosted: Mon Dec 06, 2004 7:49 pm   wow
 
no replies at all. Is there anyone out there that can help?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Dec 06, 2004 10:52 pm   
 
Certainely I can help since I wrote it. Albeit it is not a finished script, if it were to go in the help it would be. I am sorry I did not reply sooner, but my weekend was quite busy.

The script uses a field of "Where" in the database for creating new items. From your post on the other thread, where I asked for input about how good it is as a help page (I was not expecting anyone to post problem on usage there), you mentioned that you do not have a Where field in your DB. Since this field is used when creating the new records and to verify that a record was created; the lack of this field is causing the script to fail. You can either add a "Where" field to your database or locate all references to "Where" and "&Where" in the script and change them to a valid field. If you choose the latter then note that the script has some tracking connected to a variable that is not captured as part of this script--"ItemSource". I would suggest that tracking where you found a particular item is relevant to the database as often items have the same name but differring stats; and the only way to keep track of them, in a meaningful fashion, is by recording where they were found. Again this was not finished, I simply wanted some feedback to see if this was a move in the right direction. The scripts for ItemSource were not included.

I also note that there are a number of fields that the script, as supplied, that do not have triggers to capture (thank you for posting some output from the MUD). If you have made any modifications you should supply them. The triggers that were included with this script are designed to be as generic as possible. This script is however ripped out of my personal script set, with only minimal modification to seperate the triggers from the script. In my personal set all identify information is captured and parsed, the biggest difference being that the parsing is able to handle the format of many different muds. The next large diffence is that everything is translated into the DB format I like. I am sure you have had to make modifications to capture the other fields. If you haven't already done this then please keep in mind just how generic these triggers are designed to be.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
dcb
Novice


Joined: 02 Sep 2004
Posts: 42

PostPosted: Wed Dec 08, 2004 8:55 am   
 
Okay here is my finished script and it works 99%. i'm hoping you'll be able to get the other 1% working as it's very annoying! What happens is if i [ ID ITEM ] and my spell misses i get the following response.

You lost your concentration and are unable to cast identify!

this appears to have a affect on the script because if i repeat the command [ ID ITEM ] and it hits, nothing happens.

Now if i repeat the command again and it hits the record is created.

so basically everytime i miss the spell the script fails to fire and i have to repeat the command twice before the record is created. Understand?

Okay, here is my finished script.
Please reference the mud output below.
One point of interest in my modified script is i have an entry 3 times for HIT -N- DAM and there is a very specific reason for this so don't think it's a error or a duplicate entry. It works exactly as it should.

#CLASS {Identify}
#TRIGGER {^You get (*) from the coprse of (*).$} {#ADDKEY ItemSource {%1} {%zonename() - %2}}
#TRIGGER {^You pick up (*).$} {#ADDKEY ItemSource {%1} {%zonename() - %roomname()}}
#CLASS 0

#CLASS {Identify|IDTrigs}
#TRIGGER {Object &IDedItem.Name, Item type: &IDeditem.type} {Affects=""}
#TRIGGER {AC-apply is &{IDedItem.ac} Resistance to damage is &{IDedItem.damageres}} {}
#TRIGGER {Damage: &IDedItem.Damage} {}
#TRIGGER {Hit: &IDedItem.Hit} {}
#TRIGGER {Dam: &IDedItem.Dam} {}
#TRIGGER {Affects (*) by (%n)} {#ADDITEM Affects {%1=%2}}
#TRIGGER {$} {#IF (!%null(@IDedItem)) {#T- IDTrigs;#ADDKEY IDedItem Affects {@Affects};#DBLOAD ID;#VIEW All;#DBFIRST;#IF (%numrec!="") {StoreID} {CapturingID=%concat( "ID", %secs);#VAR @CapturingID @IDedItem {_nodef} {Identify};#ADDITEM IDsPending @CapturingID}}}
#TRIGGER {CON by &{IDeditem.CON}} {}
#TRIGGER {DAMAGED by &IDeditem.damaged} {}
#TRIGGER {DAMROLL By &IDeditem.dam} {}
#TRIGGER {DEX By &IDeditem.dex} {}
#TRIGGER {HIT -N- DAM By &IDeditem.hitndam} {}
#TRIGGER {HITROLL By &IDeditem.hit} {}
#TRIGGER {HIT_POINTS By &IDeditem.hps} {}
#TRIGGER {INT By &{IDeditem.int}} {}
#TRIGGER {Mana By &{IDeditem.mana}} {}
#TRIGGER {MOVE By &IDeditem.mvs} {}
#TRIGGER {STR By &IDeditem.str} {}
#TRIGGER {WIS By &{IDeditem.wis}} {}
#TRIGGER {Damage Dice is &IDeditem.damagedice} {}
#TRIGGER {Item is: &IDeditem.class} {}
#TRIGGER {Weight: &{IDeditem.weight}, Value: &{IDeditem.value}} {}
#TRIGGER {HIT -N- DAM By &IDeditem.hit} {}
#TRIGGER {HIT -N- DAM By &IDeditem.dam} {}
#TRIGGER {ARMOR By &IDeditem.armor} {}
#TRIGGER {Worn by: &IDeditem.wornby} {}
#TRIGGER {AGE By &{IDeditem.AGE}} {}
#TRIGGER {MANA REGEN By &IDeditem.MANA_REGEN} {}
#CLASS 0
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Dec 08, 2004 10:49 am   
 
In the original this alias is used to preform the id casting. It uses an alarm to cover failure within a 5 second period.
Code:
#ALIAS ID {#T+ IDTrigs;#ALARM {+5} {#T- IDTrigs};IDedItem="";cast identify}
This trigger is designed to detect the end of the ID information and checks to see that some was captured.
Code:
#TRIGGER {$} {#IF (!%null(@IDedItem)) {#T- IDTrigs;#ADDKEY IDedItem Affects {@Affects};#DBLOAD ID;#VIEW All;#DBFIRST;#IF (%numrec!="") {StoreID} {CapturingID=%concat( "ID", %secs);#VAR @CapturingID @IDedItem {_nodef} {Identify};#ADDITEM IDsPending @CapturingID}}}
The trigger doesn't specifically cover failures. You should chang the ID alias so that the alarm is named
Code:
#ALIAS ID {#T+ IDTrigs;#ALARM "TempID" {+5} {#T- IDTrigs};IDedItem="";cast identify}
and add a failure mechanism either in the above trigger or in a seperate trigger. Your failure mechanism should include the command "#UNTRIGGER TempID"
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
dcb
Novice


Joined: 02 Sep 2004
Posts: 42

PostPosted: Sat Dec 11, 2004 5:47 pm   Woot!
 
Okay script works PERFECTLY! Thanks soooo much for your help!

This is probably one of the BEST scripts i have I love it.

Are you going to be doing any more advanced scripts like this one?
Reply with quote
dcb
Novice


Joined: 02 Sep 2004
Posts: 42

PostPosted: Wed Dec 29, 2004 7:23 am   Another modification.... need help
 
The following alias works 100% if you "cast identify" but what if you can't cast identify. What if you have to recite a scroll of identify? I've tried this and tried many things to get it to work but i'm just not quite getting it.

#ALIAS ID {#T+ IDTrigs;#ALARM {+5} {#T- IDTrigs};IDedItem="";cast identify}
If we replace the following with:

#ALIAS ID {#T+ IDTrigs;#ALARM {+5} {#T- IDTrigs};IDedItem="";recite identify}

the script seems to work okay all except a CapturingID is never created and nothing is ever written to the database.

What am i missing ?

Thanks!
Reply with quote
dcb
Novice


Joined: 02 Sep 2004
Posts: 42

PostPosted: Fri Dec 31, 2004 5:39 pm   Still no reply
 
Has anyone looked at this ?
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Jan 03, 2005 10:47 am   
 
The output must be slightly different between the 2. Make sure you have the proper triggers setup to actually capture the data.

CapturingID is only supposed to be created when IDing is preferomed without the database open. IDedItem should contain what was actually captured for a given ID.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
dcb
Novice


Joined: 02 Sep 2004
Posts: 42

PostPosted: Thu Jan 06, 2005 4:08 am   
 
Acutally, the output is identical if you cast identify or recite a identify scroll. There is no difference at all. The only difference i can see at all is the capturingid is never created if you use recite the scroll. All the information is caputred in the other vars but alas i'm just plain stuck with this one.
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