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
Korlan
Newbie


Joined: 16 Nov 2000
Posts: 9

PostPosted: Fri Sep 26, 2003 11:48 pm   

Database Trigger for Mining
 
Ok, I've been puting off posting this for a long time because I know that there is probably a previous post out there that has this answer, I've been searching but still haven't found the right one (Every post I find consists of long multiple triggers to catalogue data... all I need is a single liner). I've tried to make a trigger but it just ends up catching the input and doing nothing, so I've been entering this data into a spread sheet manually, thousands of entries later and I believe enough is enough. I was told when I was younger that "it's better to keep quiet and be thought of as a fool, than to open your mouth and remove all doubt", but I've just gotta open my mouth.

What I need- A trigger that will open up my stored database (called "ores") when I successfully mine a chunk of ore, check the database if the name exists (In the "Name" field). If the name does exist, then increase the ore's associated amount (the "Amount Found" field) by one. If the name does not exist then add a new name to the "Name" field and set the "Amount Found" to one.

An example of the single line pattern that sets off the trigger -
You uncover some chalcanthite ore!

Of course, chalcanthite is the ore name and is switched with other names depending on what you find (ie You uncover some gold ore!).

If you give me an answer could you please give me a description of what is happening at each line, as bad as I am at this I do like to learn and know what is going on. And if you know of a post to refer me to, please make sure its not a complicated multiline trigger because I've seen plenty of these and have no idea how or where I should modify it to suit my problem.

Thanks. If you can help me out you've really made my day.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Sep 27, 2003 7:01 pm   
 
You don't need a trigger to open your stored database. Just open it and leave it open. I've assumed (since you didn't say) that you have other databases also open, which is why the View fields are "All|or" instead of just "All".

Pattern:
You uncover some (*) ore!
Value:
#IF (%query( &Name = "%1", "All|or")) {
#VAR temp1 {%query( &Name = "%1", "All|or")}
#VAR temp2 {%db( @temp1, Amount Found)}
#ADD temp2 1
#DBPUT @temp1 {Amount Found=@temp2}
} {
#NEW All|or {Name=%1|Amount Found=1}
}

Explanation
  • Check whether %1 is already in the database

    • If it is

      • Put the record number in @temp1

      • Put the value of Amount Found in @temp2

      • Add 1 to @temp2

      • Put the updated information in the database

    • If it's not

      • Create a new record using %1 as the Name, with Amount Found equal to 1
Reply with quote
Korlan
Newbie


Joined: 16 Nov 2000
Posts: 9

PostPosted: Sun Sep 28, 2003 5:39 am   
 
Thanks light bulb that did the trick. I didn't know how much info to provide as I am amateurish (At best) with triggers, and am new to database usage on zMUD.
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