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
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Sun Nov 07, 2004 9:47 pm   

db query
 
I have a equipment db for my leveling equipment. I want to be able to query the db so that it wears the highest item for each wear slot depending on what my curent level is.

ex of my db

Name----------------Level-----Type
Hallowed light..... ..1.....Light
Anthenas green light..30....Light
some other light.....100...Light


this is the query i'm using

record=%query( ( (&Level>%1) & (&Type="Light") & (&Level<=@current_level)), All|ti)

%1 being the level of the currently worn light

This will work ok if i run the script say at level 30 and again at level 100 as it will return only one record number.

If i forget to wear new equipment and lets say i'm still wearing level 1 stuff it will return two records.

I can have it so it chooses the last item in @record and use that.But that way is dependant on how the db is sorted.
I was wondering if there was a neater way do do this by having the query narrow the search down more. Is there a way to get query to just choose the max level item depending on your current level. Ive had a look at %dbmax and various others but unable to see how i could work this into the query.


I can't see the wood for the trees so to speak ;)

Mortie
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Nov 08, 2004 1:39 am   
 
You could do this faster with %dbmax it you have set up views for different types of equipment. Personally I like to be able to look at all the stats for items before I make that swap. All too often the highest level item you know about is not the best for that slot. Even more often you have to change 3-6 peices of eq at the same time in order to actually get a benefit without a loss. So I set up views for each eq type in my DB.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Mon Nov 08, 2004 7:07 pm   
 
Thanks for the reply.

I should have changed the query statement i posted to reflect that i do have seperate views aswell.

I will be creating a script around this db which automatically changes my equipment depending on a number of factors.

I use a fixed set of items which i carry with me all the time in bags. I have improvements for each item slot at certain levels e.g 1 41 81 121 etc.

I currently have aliases which i use to change over my equipment when i attain these levels. eg alias 41eq which removes all previous items, puts them in bags and gets out the new items at level 41. This was fine for awhile but i would like to have something which is a bit more intuitive and flexible.On attaining certain levels i am able to wear items 10, 20, 30 and so on levels earlier than its given level. This would mean updating my aliases each time.
This and the fact ive been steadily moving all my scrips to database usage.Its now the turn of my leveling equipment script.

I think im half way there

I changed it so that instead of using %query im now testing it with

#query ((&Level>=1) & (&Level<=@current_level)) Light|ti 1


This will update the view and then i can see its giving me the right level with %dbmax.

I read that this also sets the current db record, aswell as returning a value. How do i extract that record number?

I prefer to use %query as it returns the record number and doesnt update the gui view. I rarely use the gui to look
at my databases. I like to run commands from the prompt to get the info i need.

Is there a way to use %query or is the above method the best way?

Mortie
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Nov 08, 2004 10:14 pm   
 
You can get the record number and other details about the record from the %rec predefined variable. I believe the %query function does narrow the view the same way the #QUERY command does.

You might also be able to adjust the sorting of your views so that it sorts descending on Level. I think that will cause the order that records are returned in the %query to change, therby cutting down the steps. Since you don't use the GUI of the database this sorting shouldn't cause you any change in your normal habits. A quick test with my database showed this to be the case.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
mortie
Wanderer


Joined: 26 Sep 2002
Posts: 73
Location: United Kingdom

PostPosted: Mon Nov 08, 2004 11:21 pm   
 
Thanks Vijilante for your help.

I changed the sorting order and tested with both methods and decided on %query. As you mentioned it cuts down on steps. I used a query like this to test:-

%word( %query( ( (&Level>%1) & (&Level<=@current_level)), Light|ti), 1, |)
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