|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Wed Apr 23, 2008 6:39 pm
Equip Database Help |
Could someone help me with this equip database, I'm trying to use Dharkael's Python script. This is what I have so far.
Code: |
<alias name="id">
<value>#T+ Identify;equipClear;#var stuff %comcreate("Sqlite.ZMUD.WSC")
#call @stuff.Open("C:\Equip.sqlite")
c 'identify' %1;RecordAdd</value>
</alias>
<alias name="equipClear">
<value>#VAR EquipCon 0;#VAR EquipWis 0;#Var EquipStr 0;#VAR EquipHP 0;#VAR EquipMana 0;#VAR EquipDamroll 0;#VAR EquipHitroll 0;#VAR EquipAC 0;#VAR EquipDex 0;#VAR EquipInt 0;#VAR EquipName "";#VAR EquipWear "";#VAR EquipLevel 0</value>
</alias>
<class name="Identify">
<var name="EquipStr" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipWis" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipCon" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipDamroll" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipHitroll" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipAC">-10</var>
<var name="EquipDex" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipFlags">glow magic bless anti-evil</var>
<var name="EquipWear">finger</var>
<trigger priority="1900">
<pattern>^Flags: (*)$</pattern>
<value>#Var EquipFlags %1</value>
</trigger>
<trigger priority="1910">
<pattern>^Object: (*) Type: (%w)$</pattern>
<value>#VAR EquipName %1</value>
</trigger>
<trigger priority="1920">
<pattern>^Weight: (%d) Value: (%d) Level: (%d)$</pattern>
<value>#VAR EquipLevel %3</value>
</trigger>
<trigger priority="1930">
<pattern>^Location: take (%w)$</pattern>
<value>#VAR EquipWear %1</value>
</trigger>
<trigger priority="1940">
<pattern>^Affects constitution by (%d)$</pattern>
<value>#MATH EquipCon (@EquipCon + %1)</value>
</trigger>
<trigger priority="1950">
<pattern>^Affects intelligence by (%d)$</pattern>
<value>#MATH EquipInt (@EquipInt + %1)</value>
</trigger>
<trigger priority="1960">
<pattern>^Affects strength by (%d)$</pattern>
<value>#MATH EquipStr (@EquipStr + %1)</value>
</trigger>
<trigger priority="1970">
<pattern>^Affects dexterity by (%d)$</pattern>
<value>#MATH EquipDex (@EquipDex + %1)</value>
</trigger>
<trigger priority="1980">
<pattern>^Affects wisdom by (%d)$</pattern>
<value>#MATH EquipWis (@EquipWis + %1)</value>
</trigger>
<trigger priority="1990">
<pattern>^Affects damroll by (%d)$</pattern>
<value>#MATH EquipDamroll (@EquipDamroll + %1)</value>
</trigger>
<trigger priority="2000">
<pattern>^Affects hitroll by (%d)$</pattern>
<value>#MATH EquipHitroll (@EquipHitroll + %1)</value>
</trigger>
<trigger priority="2010">
<pattern>^Affects mana by (%d)$</pattern>
<value>#MATH EquipMana (@EquipMana + %1)</value>
</trigger>
<trigger priority="2020">
<pattern>^Affects hp by (%d)$</pattern>
<value>#MATH EquipHP (@EquipHP + %1)</value>
</trigger>
<trigger priority="2030">
<pattern>^Affects ac by (-%d)$</pattern>
<value>#MATH EquipAC (@EquipAC + %1)</value>
</trigger>
<var name="EquipHP" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipMana" type="Integer" usedef="true">
<value>0</value>
<default>0</default>
</var>
<var name="EquipName" usedef="true">ring wizardry</var>
<var name="EquipLevel" type="Integer" usedef="true">
<value>297</value>
<default>0</default>
</var>
<trigger priority="2090">
<pattern>^Affects intelligence by (-%d)$</pattern>
<value>#MATH EquipInt (@EquipInt + %1)</value>
</trigger>
<trigger priority="2100">
<pattern>^Affects ac by (%d)$</pattern>
<value>#MATH EquipAC (@EquipAC + %1)</value>
</trigger>
<trigger priority="2110">
<pattern>^Affects constitution by (-%d)$</pattern>
<value>#MATH EquipCon (@EquipCon + %1)</value>
</trigger>
<trigger priority="2120">
<pattern>^Affects damroll by (-%d)$</pattern>
<value>#MATH EquipDamroll (@EquipDamroll + %1)</value>
</trigger>
<trigger priority="2130">
<pattern>^Affects dexterity by (-%d)$</pattern>
<value>#MATH EquipDex (@EquipDex + %1)</value>
</trigger>
<trigger priority="2140">
<pattern>^Affects hitroll by (-%d)$</pattern>
<value>#MATH EquipHitroll (@EquipHitroll + %1)</value>
</trigger>
<trigger priority="2150">
<pattern>^Affects hp by (-%d)$</pattern>
<value>#MATH EquipHP (@EquipHP + %1)</value>
</trigger>
<trigger priority="2160">
<pattern>^Affects mana by (-%d)$</pattern>
<value>#MATH EquipMana (@EquipMana + %1)</value>
</trigger>
<trigger priority="2170">
<pattern>^Affects strength by (-%d)$</pattern>
<value>#MATH EquipStr (@EquipStr + %1)</value>
</trigger>
<trigger priority="2180">
<pattern>^Affects wisdom by (-%d)$</pattern>
<value>#MATH EquipWis (@EquipWis + %1)</value>
</trigger>
<alias name="RecordAdd">
<value>#DBFIRST
#WHILE (!%null(%rec)) {#call @stuff.Execute("insert table" @EquipWear "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)",@EquipLevel,@EquipName,@EquipInt,@EquipWis,@EquipCon,@EquipStr,@EquipDex,@EquipHP,@EquipMana,@EquipMove,@EquipDamroll,@EquipHitroll,@EquipAC,@EquipFlags);#DBNEXT};#SHOW "Item added to database."
#T- Identify</value>
</alias>
<trigger priority="3570">
<pattern>^Affects move by (%d)$</pattern>
<value>#MATH EquipMove (@EquipMove + %1)</value>
</trigger>
<trigger priority="3580">
<pattern>^Affects move by (-%d)$</pattern>
<value>#MATH EquipMove (@EquipMove + %1)</value>
</trigger>
<var name="EquipInt">0</var>
<var name="EquipMove"/>
</class>
<var name="stuff"></var> |
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Wed Apr 23, 2008 6:52 pm |
That's a script alright, but what exactly is the problem you're having?
How can we help? |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Wed Apr 23, 2008 6:55 pm |
Well it doesn't seem to add anything into the database.
|
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Apr 23, 2008 8:35 pm |
I only have a moment to glance at it, but take a look at the RecordAdd alias. Might it be possible that you need some spaces within your strings? Specifically, a space between 'table' and the quotation mark, and another space between the quotation mark and 'VALUES'. It looks to me like you are trying to concatenate strings there, and spaces will not be automatically inserted during concatenation.
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Wed Apr 23, 2008 9:25 pm |
Alias ID:
You cast Identify then immediately call your RecordAdd alias without waiting for the results, even if your RecordAdd alias was correct It would have no information to add.
Alias RecordAdd:
Are you trying to use the CMUD database or the Sqlite Component?
The two are very different things.
#DBFIRST
#WHILE (!%null(%rec))
#DBNEXT
Have nothing to do with the Sqlite Component
Assuming You're want to use the Sqlite component.
Have you actually created any of these tables you're trying to add information to?
The SQL syntax to enter info into a table is
Code: |
#call @stuff.Execute("INSERT INTO tablename VALUES(?,?,?)",@var1,@var2,@var3) |
Where tablename is the name of the table that you're trying to add info to.
This table must have already been defined.
Also rather than defining a new table for each type of equipment.
Add all the equipment into one table and use the type as one of the columns
If the table is called EquipTbl
Then the the INSERT would look like
Code: |
#Call @stuff.Execute("INSERT INTO EquipTbl VALUES(?,?,?,?)",@somevar,@someother,@something,@somejunk) |
Of course your table will have many more fields.
I would suggest that you try reading through this thread
and this one to try to gain an understanding of how this component works.
At least until you can clearly understand how it differs from the CMUD database component.
Instead of trying to get this entire script going at once, make sure you understand how each part works before expecting it to work in the whole.
I would concentrate on understanding and making sure your RecordAdd alias works, Use Dummy Information in your @EquipXXX variables.
Once you can Add information and retrieve it then we can worry about setting up your triggers properly to take advantage of your alias. |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Thu Apr 24, 2008 1:43 am |
Ok, so my RecordAdd alone doesn't work, so i tried a lasterror thing you showed on your original Python Script thread and got.
Code: |
#call @equip.Execute("insert into table Equip values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",@EquipLevel,@EquipName,@EquipWear,@EquipStr,@EquipInt,@EquipWis,@EquipCon,@EquipDex,@EquipHP,@EquipMana,@EquipMove,@EquipAC,@EquipHitroll,@EquipDamroll,@EquipFlags);#echo Error after adding value1: @equip.LastError
Error after adding value1: near "table": syntax error
|
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Apr 24, 2008 1:50 am |
The syntax is not
Try
Code: |
INSERT INTO TABLE Equip |
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Thu Apr 24, 2008 1:52 am |
Yeah, I fixed that part already and still got the same thing.
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Apr 24, 2008 2:07 am |
Well if you fix THAT part there should be a new error message.
Show the code that you're currently using in the alias.
And the error messages you're getting |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Thu Apr 24, 2008 2:26 am |
Code: |
#ALIAS {RecordAdd} {
#call @equip.Execute("insert into table Equip values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",@EquipLevel,@EquipName,@EquipWear,@EquipStr,@EquipInt,@EquipWis,@EquipCon,@EquipDex,@EquipHP,@EquipMana,@EquipMove,@EquipAC,@EquipHitroll,@EquipDamroll,@EquipFlags)}
Error after adding value1: near "table": syntax error
|
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Apr 24, 2008 2:39 am |
Okay so what exactly are typing in to get this error?
I mean I don't see the code you're using to retrieve the error message.
If thats the Alias how are you using this alias what exactly are you typing in to get this message? |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Thu Apr 24, 2008 2:41 am |
Code: |
#call @equip.Execute("insert into table Equip values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",@EquipLevel,@EquipName,@EquipWear,@EquipStr,@EquipInt,@EquipWis,@EquipCon,@EquipDex,@EquipHP,@EquipMana,@EquipMove,@EquipAC,@EquipHitroll,@EquipDamroll,@EquipFlags);#echo Error after adding value1: @equip.LastError |
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Apr 24, 2008 2:48 am |
Okay I see now. My fault: Change the beginning of the string to INSERT INTO Equip
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Thu Apr 24, 2008 3:11 am |
Ok, got the recordadding part done. How would I go about with using my id alias with the record adding now?
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Fri Apr 25, 2008 4:28 am |
Bah, I was really hoping someone else would take it from here :p
There are many threads on here that demo how to write a trigger-set to capture Identifications.
At the very least you should post examples of you casting identify on various objects including any prompts that follow,
so it can be seen how your MUD delineates identifications. |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Fri Apr 25, 2008 5:22 pm |
Armor Identify
Code: |
Object: surcoat Type: armor
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Flags: magic bless anti-evil oiled
Weight: 6 Value: 0 Level: 238
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Armor class: 50
Location: take about
Condition: [perfect]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Affects hp by 150
Affects mana by 100
Affects ac by -20
Affects damroll by 1
Affects mana by 29
Affects ac by -16
|
Primary Weapon
Code: |
Object: mace truth justice Type: weapon
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Flags: glow magic bless anti-evil nosell
Weight: 20 Value: 200000 Level: 98
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Average Damage: 56
Condition: [perfect]
Proficiency: mace
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Affects wisdom by 3
Affects mana by 130
Affects hitroll by 20
Affects damroll by 20
|
Off-hand
Code: |
Object: elven gem sword Type: weapon
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Flags: bless anti-evil anti-mag anti-cle anti-sag anti-psi anti-nec oiled no_flag_remove
Weight: 10 Value: 1000 Level: 300
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Average Damage: 93
Condition: [perfect]
Proficiency: main gauche
main gauche weapon
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Affects damroll by 12
Affects hitroll by 12
Affects hp by 300
|
And one with spells
Code: |
Object: birka staff mana Type: armor
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Flags: glow owner magic bless anti-thi anti-war anti-kni anti-ran anti-asn anti-mon no_flag_remove
Weight: 3 Value: 10000 Level: 245
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Owner - Kober
Armor class: 40
Location: take hold
Condition: [perfect]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Affects barkskin
Affects fly
Affects mana by 450
Affects hp by 250
Affects hitroll by 12
Affects intelligence by 2
Affects wisdom by 2
Affects ac by -15
|
The prompt that follows all of them is:
Hp: 7883/8011 (98%) Mn: 7218/11657 (61%) Mv: 1423 Xp: 1,797,202 AC:-1537 |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Sat Apr 26, 2008 1:16 pm |
I'd say you need to remove the call to the Recordadd alias in your Id alias
and build a prompt trigger in your identify class
In that prompt trigger is where I would call Recordadd and it looks like you already have a call in RecordAdd to #T- to then disable the identify class.
Basically the problem with calling Recordadd in your Id alias is
you need time to your identify triggers to collect data before inserting it into your database. |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Sun Apr 27, 2008 6:58 pm |
Thanks for the help Dharkael. It works
|
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Sun May 04, 2008 10:05 pm |
Ok, now how would I go about adding local variables to it?
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun May 04, 2008 10:08 pm |
Adding their values to the database, or adding them to your script in some way? Because I don't think that there's anything that requires local variables here. You need to store your values in global variables so they're available for RecordAdd, and you're not doing any logic that requires them.
|
|
|
|
wheelman Novice
Joined: 30 Jan 2006 Posts: 41
|
Posted: Sun May 04, 2008 10:13 pm |
Adding them to my script, than adding the values to the database.
|
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Sun May 04, 2008 10:16 pm |
I think what Fang is trying to get across is that there appears to be no need or benefit to be had by using local variables in this case.
The values from your identify triggers must be stored in a global variable to be accessed by RecordAdd and those are the only variables at play in this scenario |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
|
|
|
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
|
|