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


Joined: 02 Jul 2013
Posts: 8

PostPosted: Thu Nov 26, 2020 12:50 am   

Database record variable to "DataBase module"
 
I would like to move a database variable to the Cmud database.(since it would be easier to move between computers and look up the information)

I managed to create triggers that lets me get a variable that i named MonsterDB with the info i need.
When i type #showtable @MonsterDB it looks like this

{
"Jailer Josef": {
"Align": "Angelic",
"WIS": 393,
"STR": 404,
"INT": 399,
"DEX": 405,
"CON": 408,
"Hitpoints":93450,
"Attacks": 10,
"Money": 310,
"Gender": "male",
"WC": 87,
"AC": 188,
"Race": "Human ()",
"Attacks\/Round": 10
},
"Beowolf": {
"Align": "Good",
"WIS": 304,
"STR": 288,
"INT": 252,
"DEX": 278,
"CON": 242,
"Hitpoints":313450,
"Attacks": 14,
"Money": 540,
"Gender": "Male",
"WC": 89,
"AC": 173,
"Race": "half elf ()",
"Attacks\/Round": 8
}
}


This was done with the
#addkey MonsterDB.@name {align=@align}
#addkey MonsterDB.@name {WIS=@wisdom
...
Is there a similar way to do it, So it stores the value in the Database module instead of the @variable database
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4690
Location: Pensacola, FL, USA

PostPosted: Thu Nov 26, 2020 3:51 am   
 
Not that I am aware of, though the .pkg file that houses the variable should not be that hard to transfer.
You could even move it into a separate package file so you don't have to share your other settings as well.
_________________
Discord: Shalimarwildcat
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Thu Nov 26, 2020 2:27 pm   
 
:) never mind. I misread...or did I?

The database module as in filename.db?

If so, I use :-

Code:
// Write dbvar records to DB_FILE (equip) in VIEW item 'type'.
// Insert dbvar KEY (item ID) into records before writing.

#DBLOAD equip
$type_ids=%dbkeys(DBVars/%1)

#WHILE (%numitems($type_ids)>0) {
    $key=%pop($type_ids)

    $object=%db(DBVars/%1,$key)
   
    #ADDKEY $object id $key
    #NEW %1 $object
}


DBVars is a class of equipment types. Ie., I split my equipment into: weapon, armor, boat, food, etc.
It obviously assumes equip.db is already defined.

Each item of eq. in each type var is read into $object and the item's key is added to the record before being written away.
Reply with quote
croww
Newbie


Joined: 02 Jul 2013
Posts: 8

PostPosted: Thu Nov 26, 2020 5:30 pm   
 
Hpoonis2010
That seems like the thing i am trying to do. Now i just need to understand it.

Thanks
(edit)
Ok didn't get it to work, but it showed me the DBPUT command and i can use that instead of ADDKEY and get the info direct to the Database module.
Also it helped that i needed the DBLOAD command.
(my code is really spagetti code, But it seems to work)
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