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
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Thu Oct 28, 2004 10:05 am   

Database triggers problem
 
OK, I'm working on a set of triggers that will add all the mobs in a room to a database if they do not already exist in the database. To do this, I'm using my MUD's 'consider all' function, which results in a line for each mob in the room with a descriptive phrase describing my chances against that specific mob. I created a class and a trigger for each of these possible message (i.e. You would walk all over %1) and each trigger has the following code...

Code:
#IF (%query( (&Name=%1) & (&Zone=%zonenum) & (&Room=%roomvnum)) = "") {#NEW "" {Name=%1|Zone=%zonenum|Room=%roomvnum}}


Now the problem I'm running into is that it's only entering anything into the database for the first mob returned in the list... all the other mobs are summarily ignored. My first version used a variable to store the mob information then add it to the DB, and that's where I thought the issue was, but this trigger code hasn't solved anything.

Here's a sample 'consider all' output:

A young warg pulling a cart should be a fair fight!
A visiting duergar should be a fair fight!
Best run away from a prehistoric earthworm while you can!
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Thu Oct 28, 2004 11:42 am   
 
Your #IF logic is messed up it will only load mobs that already exists to get around that move the statement to an else, or use #IF (NOT) or the easier to read %null() as wrote below

#IF (%null(%query((&name=%1) & (&Zone=%1) & (&room=%vnmum)))) {
#NEW "" {Name=%1|Zone=%zonenum|Room=%roomvnum}
}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Thu Oct 28, 2004 12:02 pm   
 
OK, I've altered the functions a bit to try testing some other possibilities, and here's what I've run into...

THe logic itself works fine (I also tried your logic, no change in end result)...

I added a command to echo the result of the query at the end of the "Best run away..." trigger to see what it was finding, since obviously it wasn't comnig up null, and it turns out that the search it's conducting (using the Name=%1 errata) actually is still searching for the first mob name (A young warg pulling a cart)...

I have a feeling the %1 variable is colliding with the instances in each trigger.
I thought of assigning a different number (or variable) to each of the triggers, but that would not resolve the problem of two mobs with the same consider return (in my example, the warg and duergar)...

Is there a way to ensure that each trigger's captured variable is local to that trigger only? or is there another alternative?

Edit: OK, I'm FURTHER confused, because echoing %1 yields the correct mobname, however running the query yields the young warg record
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Thu Oct 28, 2004 12:12 pm   
 
OK... did MORE testing... and now maybe there's an easier-to-state solution to my problem...

Did a little clearing and some command-line querying... the query

Code:
#SAY %query((&Name="A prehistoric earthworm") & (&Zone=%zonenum) & (&Room=%roomvnum))


will give the asked-for blank response, while the code

Code:
#SAY %query((&Name=A prehistoric earthworm) & (&Zone=%zonenum) & (&Room=%roomvnum))


will return if ANY mob exists in that room/zone...

I'm assuming that

Code:
#SAY %query((&Name=%1) & (&Zone=%zonenum) & (&Room=%roomvnum))


expands to the version WITHOUT quotation marks... how can I add quotes to the query without actually searching for the literal "%1" ?
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
Reply with quote
Thinjon100
Apprentice


Joined: 12 Jul 2004
Posts: 190
Location: Canada

PostPosted: Thu Oct 28, 2004 12:15 pm   
 
OK, I feel silly now... I just added quotes around %1... didn't realize it would still expand it, even within quotes... problem solved... thanks for the help anyway :)

(I'd delete the thread, but I don't think I can...)
_________________
If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :)
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