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
Delrayne
Beginner


Joined: 01 Feb 2008
Posts: 16

PostPosted: Fri Feb 01, 2008 7:19 pm   

Database usage and help
 
I need help writing a script dealing with database variables. Unfortunately I don't have any knowlege or experience with database variables. Ok, so I play Imperian and I use the predator profession which relies heavily on limb damage. What I want to do is create a database with two items in it, One is a spot for player names, and the other is a spot for the number of hits it takes for the limb to break. What I'm wanting to happen is when I use my target alias, if checks the database to see if that target is already in the database, if it isn't I want it to add the target to the database. Also if the target isn't in the database it needs to turn on a section or a group of triggers, aliases, ect... to pick up the break point. I already have it set up to where it catches how many hits it takes to break the leg. I'll just need a way to transport that into the database. If the name is already in the database, I want it to display the target, and the breakpoint. I know this was long winded and probably not described the best in the world but any help you guys can give would be greatly appreciated. If you need more details or anything like that just let me know. I'll be glad to provide anything I can. Thanks for the help.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Feb 01, 2008 11:30 pm   
 
I assume you want to track the limb status on a per-target basis. Unfortunately the data record variables in zMUD aren't great for this kind of multi-layered data structure. There are a number of solutions, but they're messy.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Delrayne
Beginner


Joined: 01 Feb 2008
Posts: 16

PostPosted: Sun Feb 03, 2008 7:07 am   
 
messy or not, if you guys can help i'll take it. If you just honestly don't want to deal with the headache of it, I understand I'll keep trying or if you can tell me some things to use instead of databases that would help as well. The way I learn is seeing something in another script and finding ways to apply it to things I need. If someone could tell me what to use and how it used it a somewhat similar way that would help tons. Again I appreciate all the help that may be thrown my way.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Feb 03, 2008 6:18 pm   
 
I'm going to suggest using a database variable with string lists.

Code:
#var enemies
#addkey enemies name {head|torso|right arm|left arm|right leg|left leg}

Where the slots in the list are place holders for numbers.

head is list item 1
torso is list item 2
right arm is list item 3
left arm is list item 4
right leg is list item 5
left leg is list item 6

to keep track of this we make a library database variable.
Code:
#addkey limbLib {head=1|torso=2|right arm=3|left arm=4|right leg=5|left leg=6}


Lets have an example.

The enemy is Gaborn, you broke his left arm in three tries. He is not yet in the database.
Code:
#var Target Gaborn
#var hits 3

#trigger {You maul @target's (*) horribly and hear a bone shattering snap!} {#if (%iskey(@enemies,@target)>0) {#addkey enemies @target %replaceitem(@hits,%db(@limbLib,"%1"),@{enemies.@target})} {#addkey enemies @target {%replaceitem(@hits,%db(@limbLib,"%1"),0|0|0|0|0|0)}}}

#show You maul Gaborn's left arm horribly and hear a bone shattering snap!


Because Gaborn was not yet in the database it will show that it takes 3 hits to break his left arm and 0 hits to break the other limbs.
If he HAD been in the database it would only change the value for his left arm to 3 and leave the other values at whatever they had been.

You would need to either remember that 0 means you haven't broken something yet or write it into the rest of your settings. That much I am leaving to you.

Now to look at these values you would do this.
Code:
#show Gaborn's left arm broke after %item(%db(@enemies,Gaborn),%db(@limblib,"left arm")) hits.

Displays

Gaborn's left arm broke after 3 hits.
Code:
#show Gaborn's right arm broke after %item(%db(@enemies,Gaborn),%db(@limblib,"right arm")) hits.

Displays

Gaborn's right arm broke after 0 hits.

Enjoy.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Delrayne
Beginner


Joined: 01 Feb 2008
Posts: 16

PostPosted: Mon Feb 04, 2008 3:54 am   
 
Thanks for the help Arminas. Not exactly what I'm looking for, but looking at the code that you used and how you explained its mechanics I think I may be able to formulate something that will do what I need. Again, thanks for all your help.
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