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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Sun Nov 18, 2007 11:32 pm   

help with my MXP database script?
 
I'm trying to make my database work off clicking the objects/mobs/ect in the room to add to the database. This is the code as it is:

dbarmouradd alias:
Code:
#var armor.name %remove((a),%replace(%trim(%subregex(%-1,"[\d[:punct:]]")),worn),)
#var armor.vnum %roomnum
#var armor.zone %zonenum
#if (%query((&name=@armor.name && &zone=@armor.zone),items)) {
    #var armor {}
    #DBRESET
    #show {Armour exists}
    } {#NEW item {name=@armor.name|vnum=@armor.vnum|zone=@armor.zone|type=armor}
      #DBRESET
      #show {Armor added:%db(@armor,name)}
      #var armor {}
      }


my trigger that incorporates this is:
pattern:^~(a~)%e[1;37m(&armor.name)%e[0m.$
Code:
#if (%class( gagger)) {#gag} {#if (@database) {#gag
#mxp 1 ~(a~)<send 'dbarmouradd %1'><color greenyellow>%1</color></send>}}



So what happens is I can click on the object on the screen, but nothing is ever added to the database. I use cmud 1.34.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Mon Nov 19, 2007 10:05 am   
 
The code seems to work fine. My guess is that you dont' have the database window open or the database isn't loaded. Without this you database commands won't work. You may also want to ensure that you query command is returning correctly.

As an aside you can make you alias more efficient. I replaced the %-1 with %params so you only get what's passed to the alias and you can simplify your name cleanup. I used local variables since you clear after you add the variable.

Code:
#LOCAL $armor

#addkey $armor name %replace( %trim( %subregex( %params, "[\d[:punct:]]")), worn)
#addkey $armor vnum %roomnum
#addkey $armor zone %zonenum
#addkey $armor type armor

#if (%query( (&name=$armor.name && &zone=$armor.zone), items)) {
  #DBRESET
  #show {Armour exists}
  } {
  #NEW item $Armor
  #DBRESET
  #show {Armor added:%db( $armor, name)}
  }


Now you're trigger patter doesn't need to name the variable so, you have it be
Code:
pattern:^~(a~)%e[1;37m(%w)%e[0m.$


If it's more than one word you can use '*'
_________________
Asati di tempari!
Reply with quote
chris-74269
Magician


Joined: 23 Nov 2004
Posts: 364

PostPosted: Wed Nov 21, 2007 1:24 am   
 
eh something is screwed up with my database, it still doesn't work with that new code. However, i have another form of addign that works through a right click menu, that uses this code:
Code:

#var armor.name %remove((a),%replace(%trim(%subregex(%selline,"[\d[:punct:]]")),worn),)
#var armor.vnum %roomnum
#var armor.zone %zonenum
#if (%query((&name=@armor.name && &zone=@armor.zone),items)) {
    #var armor {}
    #DBRESET
    #show {Armour exists}
    } {#NEW item {name=@armor.name|vnum=@armor.vnum|zone=@armor.zone|type=armor}
      #DBRESET
      #show {Armor added:%db(@armor,name)}
      #var armor {}
      }


however, it adds duplicates. Is something with cmud broken in this regard?
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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