Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Mon Sep 27, 2010 10:23 pm   

Grabbing an db item based on the value in 3.x?
 
%isvalue help file

According to this we should be able to grab a key with a value using %isvalue, however, this doesn't actually work in practice. I remember awhile back being told that trying to grab the position of something in a db variable was the wrong way to go about it anyways, because of something about a hash system it uses or whatever. So I'm genuinely curious if it's even possible to get the associated key to a value anymore if all you have is the value?

Edit:
aka if you use
Code:

<class name="isvalue test" id="176">
  <var name="test_isvalue" type="Record" id="177">
    <value>Name=Zugg|Race=Dwarf|Level=10</value>
    <json>{"Level":10,"Race":"Dwarf","Name":"Zugg"}</json>
  </var>
</class>


#SHOW %item(@test_isvalue, %isvalue(@test_isvalue,"Dwarf"))

You get:
Dwarf

Not:
Race=Dwarf

Edit: Fixed title
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23377
Location: Colorado, USA

PostPosted: Tue Sep 28, 2010 12:14 am   
 
Just use the new %dbkey function:
Code:
#SHOW %dbkey(@test_isvalue, %isvalue(@test_isvalue,"Dwarf"))

That will show "Race"

There is no way to get the "Race=Dwarf" value anymore since the data is no longer stored like it used to be. You either get "Race" via %dbkey or "Dwarf" via %db or %item.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Sep 28, 2010 12:26 am   
 
I'd actually prefer just getting race. Thanks Zugg, I wasn't sure if there was a function like that, suppose I should have done a bit more research. :-/
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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