|
thegto Beginner
Joined: 12 Jun 2007 Posts: 20
|
Posted: Thu Jul 19, 2007 7:43 am
plese help with database scripts |
Here is pattern
Quote: |
| Names : wood spoon cook |
| Type : Weapon Level : 85 |
| Worth : 500 Weight : 8 |
|
Here is scripts that I do the same thing as help file
Code: |
#ALIAS identify {#T+ identify;#VAR Item "";cast id %1}
#TRIGGER {~|(%s)Names(%s)~:(%s)(%*)(%s)~|} {#addkey item {name=%4};#echo %4} identify
#TRIGGER {~|(%s)Type(%s)~:(%s)(%w)(%s)Level(%s)~:(%s)(%d)(%s)~|} {#VAR ItemType %4;#ADDKEY item {level=%8};#echo %4 %8} identify
#TRIGGER {~|(%s)Worth(%s)~:(%s)(%w)(%s)Weight(%s):(%s)(%d)(%s)~|} {#ADDKEY item {cost=%4|weight=%8};#echo %4 %8} identify
#TRIGGER {$} {#T- identify;#IF (!%null(@Item)) {#NEW @ItemType @Item}} identify
|
The problem is @item is empty after ran this script and I can't see @ItemType any where,
and also #echo doesn't show any thing as well.
but if I test only one trigger it works normally ..
Are there any basics tutorial or complete scripts that I can learn ?
Thank in advance
Tai |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Thu Jul 19, 2007 10:37 pm |
I was able to run this and it works fine except you third trigger doesn't match.
You have
Code: |
#TRIGGER {~|(%s)Worth(%s)~:(%s)(%w)(%s)Weight(%s):(%s)(%d)(%s)~|} {#ADDKEY item {cost=%4|weight=%8};#echo %4 %8} identify |
For what you are having zMUD check for a word instead of a number. As far as weapons are concerned, it shoudl be this.
Code: |
#TRIGGER {~|(%s)Worth(%s)~:(%s)(%d)(%s)Weight(%s):(%s)(%d)(%s)~|} {#ADDKEY item {cost=%4|weight=%8};#echo %4 %8} identify |
The other thing to note is that since you not actually using them, you don't need to put parentheses around the spaces '%s'. That means you can do this.
Code: |
#TRIGGER {~|%sWorth%s~:%s(%d)%sWeight%s:%s(%d)%s~|} {#ADDKEY item {cost=%1|weight=%2};#echo %1 %2} identify |
|
|
_________________ Asati di tempari! |
|
|
|
thegto Beginner
Joined: 12 Jun 2007 Posts: 20
|
Posted: Fri Jul 20, 2007 6:04 am |
Yay thank you very much .....it looks ok but I still have a bit problem...
here is the new one
Code: |
#ALIAS identify {#T+ identify;#VAR Item "";cast id %1}
#TRIGGER {^~|%sNames%s~:%s(%*)%s~|$} {#addkey item {name=%1};#echo %1} identify
#TRIGGER {^~|%sType%s~:%s(%w)%sLevel%s~:%s(%d)%s~|$} {#VAR ItemType %1;#ADDKEY item {level=%2};#echo %1 %2} identify
#TRIGGER {^~|%sWorth%s~:%s(%d)%sWeight%s~:%s(%d)%s~|$} {#ADDKEY item {cost=%1|weight=%2};#echo %1 %2} identify
#TRIGGER {$} {#IF (!%null(@Item)) {#T- identify;#NEW @ItemType @Item}} identify
|
I have a problem with this pattern
Quote: |
| Worth : 1,000 Weight : -210 |
|
Trigger cannot fire when found this pattern ?
and when I run this script it always show this line
(!0) {#T- identify;#NEW Weapon nameaardwolf dagger (256942)level20} is this normal to run this scripts and got this result ?
If I have the same item name but it's difference some value such as price/weight , will this script make a new one in the database or will replace the old one ?
btw, I can see my items can be stored in my database |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Jul 20, 2007 7:37 am |
It may have to do with pretty printing but it looks like zMUD isn't pickup up your trigger line properly. Which is why you get (!0) etc... Try going to the settings editor and look at that trigger, it should be fairly obvious where it's breaking from there. When in doubt put each command on its own line.
The reason '1,000' won't match is because %d tells zMUD to look for decimal numbers and because of the comma, '1,000' doesn't qualify.
There are several weighs you can get around this. I guess the easiest to understand is to change the trigger slightly so it matches anything then strip the comma out, then set it to the variable. So you end up with something like this.
#TRIGGER {^~|%sWorth%s~:%s(*)%sWeight%s~:%s(%d)%s~|$} {#ADDKEY item {cost=%subchar("%1",",","")|weight=%2};#echo %1 %2} identify
'*' Tells zMUD to match any number (even none) of characters or white space. The codes untested but should give you the general idea. |
|
_________________ Asati di tempari! |
|
|
|
thegto Beginner
Joined: 12 Jun 2007 Posts: 20
|
Posted: Fri Jul 20, 2007 11:35 am |
yes it works :)
just only this line "(!0) {#T- identify;#NEW Weapon nameaardwolf dagger (256942)level20}" I don't know how to fix
but I can save info to database that it is fine I think :P
to use (*) and (%*) are they same one ?
I see some people use %-1 , what is it used for ? I can't see in help files ..
thank you for your advice |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Jul 20, 2007 3:20 pm |
(%*) isn't anything. It doesn't match.
%-1 is used in aliases. It contains all the parameters you typed after the alias - "SomeAlias one two three four five" - %-1 will be "one two three four five". %-2 will be "two three four five" and so on.
Instead of Tech's %subchar and (*) part, you can just use %n. %n matches a number with commas, but also strips the commas. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Fri Jul 20, 2007 4:34 pm |
Fang Xianfu wrote: |
(%*) isn't anything. It doesn't match.
%-1 is used in aliases. It contains all the parameters you typed after the alias - "SomeAlias one two three four five" - %-1 will be "one two three four five". %-2 will be "two three four five" and so on.
Instead of Tech's %subchar and (*) part, you can just use %n. %n matches a number with commas, but also strips the commas. |
%* matches EVERYTHING it is very dangerous to use this and usually you just want to match almost everything.
You should think of it as * and %* are identical EXCEPT %* is dangerous so that you should not use it.
The odds are anywhere you see someone use %* they SHOULD have used * instead.
If you search for posts by Zugg containing %* you will probably find some examples of why NOT to use it.
Edit: Actually I did a search and it was not very evident. So here are some examples and more explicit explanations.
http://forums.zuggsoft.com/forums/viewtopic.php?t=20626&start=0&postdays=0&postorder=asc&highlight=
http://forums.zuggsoft.com/forums/viewtopic.php?t=5067&start=0&postdays=0&postorder=asc&highlight= |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Last edited by Arminas on Fri Jul 20, 2007 6:05 pm; edited 1 time in total |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Fri Jul 20, 2007 5:18 pm |
I actually thought of %n but the documentation only mention the +/- and I wasn't at home to test it.
So I went with what I knew would work. |
|
_________________ Asati di tempari! |
|
|
|
thegto Beginner
Joined: 12 Jun 2007 Posts: 20
|
|
|
|
thegto Beginner
Joined: 12 Jun 2007 Posts: 20
|
Posted: Sat Aug 11, 2007 11:56 pm |
Hi
I got a broblem ......... again
I tried to connect to iwuv database from this tutorial
http://www.conradshome.com/iwuvzmud/
I can test connect like this picture
and then I make an Alias
#alias ifind {I put scripts from the website here }
BUT when I test it .....
ifind strength = 1 AND level = 20
I got an error
Is this my zMUD not connect to database ... or this scripts error ? |
|
|
|
|
|